Posts

Showing posts from February, 2014

c++ - Dynamically increase and decrease char arrays? -

i have send data udp. buffer field of type char. have encrypt/decrypt send. here's code encrypting/decrypting. const unsigned buffer_size = 128; char data[buffer_size]; cout << "enter something." << endl; cin.getline(data, buffer_size); cout << data; char outchar[buffer_size]; for(int = 0; < strlen(data); i++) { //outchar[i] = data[i]; outchar[i] = encr[(int)data[i]]; cout << outchar[i]; } cout << "correct far" << endl; char transchar[buffer_size]; for(int j = 0; j < strlen(outchar); j++) { transchar[j] = decr[(int)outchar[j]]; cout << transchar[j]; // prints out decrypted text , unused space! } the problem here using fixed size of char means there lot of unused space in buffer. in code provided, gets printed screen. is there anyway dynamically increase , decrease buffer (char array) size not unused space? edit: don't think clear: every letter has encrypted , decry

Java Dice Roller Loops -

so having issue figuring out how create loop , bring class on in dice game application have create school project. game has keep user score each round 18 max score , if user rolls on 10 in 1 round points lost , starts next round @ 1 point. game has validate when user enters y roll or r stop. on appreciated. im having problems setting loop in continue game after y entered or tell user game has stopped after r entered. after y entered loop print out "round1" roll:6 [y or r], user entered y, print out "round 2" , on , dont know how validate user input. import java.util.scanner; import java.util.random; import java.lang.boolean; public class player { public static void main(string[] args){ string player; string playeranswer; boolean answer = true; int roundscore; int totalscore; int playerscore; int round; scanner user = new scanner(system.in); system.out.println("enter first name pl

css - Zurb Foundation vertical navbar? -

hello guys started using zurb foundation , need vertical navbar top bar vertically. playing around here wit css no luck. searched on google couldn't find such thing. easy convert top-bar vertical navbar? try pen .top-bar{ height:100%; width:150px; } ul.right > li{ display:block; float:none; border-bottom:1px solid #444; } ul.right > li:last-child{ border-bottom:none; } .has-dropdown ul.dropdown{ position:absolute !important; left:100% !important; top:0px; border-left:1px solid #444; } update :added right chevron pen.

delphi - In II7, what is the difference between an "Application", a "Module" and a "Handler"? -

currently, understanding follows. when request received iis, transitions between several states (begin_request, execute_request_handler, end_request, etc). a "module" dll (dynamic link library) extends functionality of iis @ 1 or more of request states. example, "php module" dll hooks iis @ execute_request_handler state parse , execute php scripts. the above rather easy digest (and similar how apache provides extensions). however, not have clear understanding of "handlers", "handler mappings" , "applications". what "handler"? "handler mapping"? what difference between "module" , "handler"? what difference between "module" , "application"? with last question, if enable isapi dll built delphi, difference between , application? can isapi dll added executable iis in 2 different ways, 1 via regular route , 1 via adding "application"? (note: understand

ruby - Rake Crashes since change to ZSH -

i started having issue. i'm totally unaware have changed behavior, it's driving me crazy not working. have provided details can current system environment. system details os: mavericks shell: zsh (5.0.2) oh zsh ruby: 2.0.0-p451 rake: 10.1.1 command-line tools: apple llvm version 5.0 (clang-500.2.79) (based on llvm 3.3svn) target: x86_64-apple-darwin13.1.0 thread model: posix -- crash report -- > process: ruby [63404] path: > /system/library/frameworks/ruby.framework/versions/2.0/usr/bin/ruby > identifier: ruby version: 96 code type: x86-64 > (native) parent process: zsh [62217] responsible: iterm [95439] > user id: 502 > > date/time: 2014-03-09 20:48:03.772 -0400 os version: mac os > x 10.9.2 (13c64) report version: 11 anonymous uuid: > 5865e4ef-2686-b0aa-d22c-0089d3aa89c7 > > sleep/wake uuid: 2b1e7b16-10b4-42e9-9537-24305d033046 > > crashed thread: 0 dispatch q

Bootstrap - flexible for every screen size or device -

today have 1 questions regarding bootstrap on different screen size or devices. example want create website suitable desktop, laptop, mobile , tablet. inside html class, should set container become fluid-container ? or need apply .col-lg col-sm col-xs ? because wish website can display on devices , screen size. thank , sorry if question duplicated. because fail search article related regarding issue. assuming you're using bootstrap 3, don't use fluid-container, it's been replaced container. this: <div class="wrapper"> <div class="row"> <div class="col-md-6">50%</div><div class="col-md-6">50%</div> </div> <div class="row"> <div class="col-md-3">25%</div><div class="col-md-3">25%</div><div class="col-md-3">25%</div><div class="col-md-3">25%</div>

java - Reading and appending to a json file -

i have json file follows: { "profiles": { "example1": { "name": "example1", "lastversionid": "example1" }, "example2": { "name": "example2", "lastversionid": "example2", "playeruuid": "00000000000000000000000000000000" }, }, "selectedprofile": "example", "clienttoken": "000000000000000000000000000", "authenticationdatabase": { "000000000000000000000000000": { "username": "example@gmail.com", "accesstoken": "000000000000000000000000000", "userid": "000000000000000000000000000", "uuid": "000000000000000000000000000", "displayname": "example" } } } i need append follows: { "profiles": {

java - Find JAVA_HOME and set it on RHEL -

i had installed java while ago on rhel machine. now, i'm trying run program requires java_home variable set. best way figure out installation directory of java installation , set java_home? here results of running java- version : java version "1.7.0_25" java(tm) se runtime environment (build 1.7.0_25-b15) java hotspot(tm) 64-bit server vm (build 23.25-b01, mixed mode) i have /usr/lib/jvm directory, empty. first, try echo $java_home command line. since java on path already, java_home may set. what best way figure out installation directory of java installation running command which java point java installed. and set java_home you can edit ~/.bashrc , ~/.bash_profile , or /etc/profile set java_home . setting in ~/etc/profile set system wide, , not want. sake of example output of which java /opt/jdk_1.7.0_25 , you'd add export java_home=/opt/jdk_1.7.0_25 ~/.bashrc or ~/.bash_profile , run source ~/.bashrc (or source ~/.bash

c# - Change the values of members of a list without changing object reference -

i'm working on game, , @ core of game random weapon generation system. basically, works loading bunch of .xml files each own "parttype" tag out of around 20 or (things blade, grip, pommel, etc.). anyways, have class called weaponpart has properties weight, identifier, etc. have public abstract class weapon public list<weaponpart> parts . there then: public class sword : weapon { public weaponpart blade, pommel, grip, guard; public sword() : base() { pommel = new weaponpart(weaponpart.pommel); //there weaponparttype enum grip = new weaponpart(weaponpart.grip); guard = new weaponpart(weaponpart.guard); blade = new weaponpart(weaponpart.blade); parts.add(pommel); parts.add(grip); parts.add(guard); parts.add(blade); } } i run method creates new instance of weapon part every file present in folder of xml files. game generates new weaponparts them. now, problem is: when ru

java - Mac Jar Launcher does not wait for input -

(first question bear me) i'm new java, , i'm trying create executable .jar file. can run .jar through terminal, when double click .jar in finder, doesn't seem want open. when check console errors, looks program runs, skips right on have user input , moves right through code. here's code skips over private string readinputline() { string line = ""; system.out.println("\n>>"); try { bufferedreader reader = new bufferedreader(new inputstreamreader(system.in)); line = reader.readline(); } catch(java.io.ioexception exc) { system.out.println ("read error: " + exc.getmessage()); } return line; } any appreciated! if matters, i'm on snow leopard 10.6.8. if want user interact program providing input, , don't want user have run program through command line this: java -jar /path/to/java/program.jar if ok, great! can stop reading here. if want use window read o

PHP Check of SQL query for value quantities -

i have script checking values in database. there 3 instances need check for. 1) no value present 2) single value exists 3) multiple values exist currently, have following script run first instance: if($value){ echo ‘this showing if value exists’; }else{ echo ‘this showing if no value exists’; } how can add check if array of values exist? we need see code retrieves data, if have array of data use count : if (count($value) > 1) { // multiple values } you may using select count in case can compare value: if ($value["count"] > 1) {

java - Using JComboBox with ItemListener/ActionListener -

Image
i've begun coding in java , wondering how achieve this. want user able input text text box, select font, color , size display in label @ bottom when ok button clicked. appreciated. thanks. package textchanger; import java.awt.event.*; import javax.swing.*; import java.awt.*; public class textchanger implements actionlistener { string[] fontstrings = {"arial", "arial black", "helvetica", "impact", "times new roman"}; string[] sizestrings = {"10", "12", "14", "16", "18"}; string[] colorstrings = {"red", "blue", "green", "yellow", "orange"}; string[] bgstrings = {"red", "blue", "green", "yellow", "orange"}; jpanel panel; jlabel labeltext, labelfont, labelsize, labelcolor, labelbg, labeloutput; jtextfield textfield; jcombobox combofont, combosize, combocolor, combobg; jbutton btn

linux - No SReclaimable in /proc/meminfo -

i using rh5.7 , cant find sreclaimable field. here output of cat /proc/meminfo, , yes there no sreclaimable. memtotal: 8043128 kb memfree: 79524 kb buffers: 221152 kb cached: 3149268 kb swapcached: 446932 kb active: 5399580 kb inactive: 1101800 kb hightotal: 0 kb highfree: 0 kb lowtotal: 8043128 kb lowfree: 79524 kb swaptotal: 12289716 kb swapfree: 10996132 kb dirty: 396 kb writeback: 0 kb anonpages: 3128248 kb mapped: 374620 kb slab: 1097292 kb pagetables: 70952 kb nfs_unstable: 0 kb bounce: 0 kb commitlimit: 16311280 kb committed_as: 10445264 kb vmalloctotal: 34359738367 kb vmallocused: 329484 kb vmallocchunk: 34359407603 kb hugepages_total: 0 hugepages_free: 0 hugepages_rsvd: 0 hugepagesize: 2048 kb i have linux box debian , can find field. had same issue? here debian output : cat /proc/meminfo memto

pug - Jade equivalent for csrf token in Sails -

from examples, using default ejs engine, hidden input required csrf protection is: <input type="hidden" name="_csrf" value="<%= _csrf %>" /> what jade equivalent? it: input(type="hidden", name="_csrf", value='#{_csrf}') thanks. edit: i've tried both value='#{_csrf}' , value=#{_csrf} , i'm pretty sure neither correct don't display right csrf token. try: input(type="hidden", name="_csrf", value=_csrf) that should output token you.

java - How to set JSP page encoding using Servlet 3.0 annotation configuration (or Spring)? -

i converted xml-based configuration pure annotation (using mixture of javax.servlet.annotation , springframework classes). 1 thing haven’t figured out how configure this: <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <page-encoding>utf-8</page-encoding> </jsp-property-group> </jsp-config> any ideas? thanks!

Bootstrap modal box with inline edit PHP -

quick question - possible have modal window inline edit(to stored in db) happy if available in bootstrap. yes or no? see examples having list of records, , clicking record open modal box inline edit. question sounds better? thansk, kimz you need simplemodal.js : http://www.ericmmartin.com/projects/simplemodal/ , plus inline editor, try tinymce, here example: http://www.tinymce.com/tryit/inline.php .

c# - Hot to design the ViewModel for a windows phone 8 pivot app -

i creating windows phone 8 pivot app using mvvm light , wondering how design view model. each pivot of app (in total 3-4) work different collections of data. the options considering are: have 1 mainviewmodel contains different collections different pivots. best practices read on mvvm mandate (this how understood them @ least) 1 view should have 1 viewmodel option comes naturally. have separate viewmodel each pivot , 1 mainviewmodel reference them. option makes more sense me in terms of separation , code structure. make bindings , command wiring little bit more tricky. which option better? have 1 view model , have separate collections each viewmodel. have necessary collection items bind pivot items. view <phone:pivot x:name="tutopivot" selectionchanged="pivotselectionchanged"> <!--pivot item one--> <phone:pivotitem header="{binding collection1.title}"> <!--double line list

browser - How to print to stdout in Clojure without returning nil -

i making website , want know if there way return string of integers vector, each in own line. when rig code use apply str output can in browser goes -> [1 2 3 4] -> 1 2 3 4. want this: 1 2 3 4 . . . when try each element on own line using println, pprint or format, blank under results header in browser. assume because of return nil. there way formatting need, results of output can copied , pasted excel file without user having format hand? if you're explicitly looking output csv-data can read excel, recommend looking @ 1 of csv libraries data.csv . these libraries not handle formatting data strings quite tricky rules in csv around quoting. example obtains string based on csv data: user=> (def data [[1 2] [2 3] [3 4] [4 5]]) #'user/data user=> (with-out-str (write-csv *out* data)) "1,2\n2,3\n3,4\n4,5\n" if want constrain narrowly problem list, 1 way (of many ways) interleave infinite sequence of newlines between each piece of data:

c# - Kinect SDK corrupt memory error -

i have made program in xna using kinect sdk. program running fine in pc, , many of other pc's, in 1 system when open program gives me following error: attempted read or write protected memory. indication other memory corrupt. the program stops , gives me error message in spritebatch.end() . i unable understand why giving me error message. the system using has 4gb ram, , system creating problem has 2gb ram. both systems core2 duo. memory issue or else? yes memory issue. take @ answer in http://social.msdn.microsoft.com/forums/en-us/71f134bd-d665-43b5-8c67-52c4d6ed4ed9/kinect-driver-problem?forum=kinectsdknuiapi . restart system, stop unnecessary processes (to minimize memory usage) try running program again.

In JAVA API why equality check using '==' rather than String.equals() method -

i going through api code found in java api java.io.filepermission.getmask(string actions) { int mask = none; // null action valid? if (actions == null) { return mask; } // check against use of constants (used heavily within jdk) if (actions == securityconstants.file_read_action) { return read; } else if (actions == securityconstants.file_write_action) { return write; } else if (actions == securityconstants.file_execute_action) { return execute; } else if (actions == securityconstants.file_delete_action) { return delete; } else if (actions == securityconstants.file_readlink_action) { return readlink; } .... .... ..... } can 1 tell me why have used '==' operator instead of .equlas() method. :? it because of string interning . happens compiler interns string literals in memory @ compile time (this done save memory). when compare string literals == , work because in same m

javascript - Pagination in Angularjs -

i trying build simple crud application beginners of angularjs. using angularjs + firebase + bootstrap that. here --- plnkr --- that. i wanna add new feature simple pagination that. think $filter('filter')(array, expression, comparator) may don't know how. can please me !!!!? angular provides filters perfect pagination: startfrom , limitto. jsfiddle great base example of how works. key have in scope page index, , page size. can change page viewing increasing/decreasing page index. you can see how works piece of html <li ng-repeat="item in data | startfrom:currentpage*pagesize | limitto:pagesize"> {{item}} </li>

Store javaScript variable value in PHP variable -

how can have javascript variable value in php variable within same page?? i have javascript variable have json string , want store in php variable can store database. possible?? you should write php page accepting json using post , save database. in javascript when ready save json , send json php page using ajax . way save client side data without using forms. as explained in answer send json data javascript php? or if form can refer answer submit serialised data html form how pass javascript variables php?

visual studio 2012 - Disable running pre-deployment and post-deployment scripts -

i have below publish file use publish database project. wanted know if possible disable running pre-deployment , post-deployment scripts during publish. <?xml version="1.0" encoding="utf-8"?> <project toolsversion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <propertygroup> <includecompositeobjects>true</includecompositeobjects> <targetdatabasename>mytestdb</targetdatabasename> <deployscriptfilename>myscript.sql</deployscriptfilename> <targetconnectionstring>data source=127.0.0.1;integrated security=true;pooling=false; </targetconnectionstring> <profileversionnumber>1</profileversionnumber> </propertygroup> </project> i don't want modify script files. want know if can done through configuration specifying in publish.xml file. you can modify pre- , post-deployment script fil

android - GCM push notification does not work correctly when using Wifi network -

hi integrated app receiving push notification using gcm. working correctly, saw strange behavior while receiving push notification on 1 of android set using wifi network, in same time others using edge or 3g network receiving notifications correctly. when try switch off , switch on wifi, receives pending notification. i tried opening ports used gcm i.e 5228,5229 , 5230 in router's firewall no success. please me out resolving issue. n.b:- after seeing this, tried configure app parse api , working same gcm think depends upon network packet receiving or something. i believe, you're facing known issue tcp connection between gcm servers , handset timing out because of inactivity. network devices (like wi-fi router, isp hardware, etc.) between handset , gcm servers kill tcp connection if no packets sent every , then. there workarounds might try. example, there apps on google play modify default android behavior , make update connection more often, increasing cha

java - SQLException error -

i made odbc connection, still wont work. kindly guide along way, please , thank you here code below: package payrollapplication; import java.sql.*; import javax.swing.*; /** * * @author admin */ public class dbconnection { boolean isconn=false; boolean issucc=false; boolean isconfirm=false; private string nextnumber=""; connection conn; preparedstatement ps; resultset rs; statement st; /** creates new instance of dbconnection */ public dbconnection() { connecttodatabase(); } public boolean connecttodatabase() { try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); conn=drivermanager.getconnection("jdbc:odbc:employee"); isconn=true; } catch(exception ex) { joptionpane.showmessagedialog(null,ex,"connection",joptionpane.error_message); } return isconn; }

php - laravel ajax request error -

jquery: $.get("{{url::asset('index.php/items/sessionstore')}}" + '/' + itemids, function (data) { alert(data); } ); routes.php route::get('items/sessionstore', 'itemscontroller@sessionstore'); controller public function sessionstore($id) { if(request::ajax()) { echo $id; echo "ajax"; } else { echo "no ajax"; } } my error is: { "error": { "type": "symfony\\component\\httpkernel\\exception\\notfoundhttpexception", "message": "", "file": "d:\\wamp\\ change route route::get('items/sessionstore/{$id}', 'itemscontroller@sessionstore');

MySQL: Renaming primary key -

while creating table in mysql i've set wrong name primary key column. alter table `table_name` change column `old_id_name` `new_id_name` integer auto_increment primary key after i'm getting error message: multiple primary key defined so question how can rename column. note don't want change primary key rename it. use query this alter table `table_name` change `old_id_name` `new_id_name` int(11) not null auto_increment; it change column name of primary key

android - How to modify zxing for keeping on scanning? -

i have developed application qr code scanner based on zxing,but facing problem how modify code scanner can keep on scan s sequence of qr code data until user stopped it. can give me advice? public class scanlibrarycardactivity extends captureactivity { private progressdialog pdialog; private string uid, bname, authors, publisher, edition, callnumber, location; private int total; jsonparser jparser = new jsonparser(); jsonarray user = null; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // setcontentview(r.layout.main); // cameramanager } @override public void handledecode(final result obj, bitmap barcode) { uid = obj.gettext(); if (uid.matches("\\d+")) new checkcorrectuser().execute(); else { customizeddialog.showresultdialog(scanlibrarycardactivity.this, "invalid user"); intent = new intent(getapplicationcontext(),scanlibrarycardactivi

c# - How should I handle a potentially large number of edits in entity framework? -

i'm using .net 4.5.1 ef 6.0.2 , db-first. the use case this: roughly 50k entities loaded a set of these entities displayed user, others required displaying items correctly the user may perform heavy actions on entities, meaning user chooses perform 1 action cascades affect potentially hundreds of entities. the changes saved database. the question, then, best way handle this? far i've come 2 different solutions, don't either: create dbcontext @ step 1. keep around during whole process, save changes. reason don't this, process might take hours, , far know, dbcontexts should not preserved long. create dbcontext @ step 1. discard right after. @ step 4, create new dbcontext, attach modified entities , save changes. big problem see approach how figure out entities have changed? need build changetracker of own able this? so there better alternative handling this, or should use 1 of solutions above (perhaps changes)? i go option number 1 - use dbc

javascript - Swap values of keys in JSON array -

this question has answer here: swap value of 2 properties on object(s) 2 answers i have following json. need swap sortid like have this, [{"categoryid":1,"name":"worktable","sortid":1} ,{"categoryid":2,"name":"bf ","sortid":2}] after swaping 'sortid' need [{"categoryid":1,"name":"worktable","sortid":2} ,{"categoryid":2,"name":"bf ","sortid":1}] please tell me how through javascript. var tmp = a[0].sortid; a[0].sortid = a[1].sortid; a[1].sortid = tmp; jsfiddle

html - Can't view horizontal menu in Mozilla Firefox and Internet Explorer -

in below code can't view horizontal menu in mozilla firefox , internet explorer. this menu html <div class="menu"> <ul id="menu"> <li><a href="../index.php">home</a></li> <li><a href="../faqs.php">faqs</a></li> <li><a href="../contact.php">contact us</a></li> </ul> </div> this menu css @font-face { font-family: 'segoe print’; src:url('fonts/segoe.eot?#’) format(‘eot’), url(‘fonts/segoe.woff’) format(‘woff’), url(‘fonts/segoe.ttf’) format(‘truetype’); } #menu, #menu ul { margin: 0; padding: 0; list-style: none; font-weight: bold } #menu { width: 400px; /*border: 1px solid #222; background-color: #111; background-image: linear-gradient(#444, #111);*/ border-radius: 6px; background: rgb(107,91,90); /* old browsers */

c++ - cannot load multiple textures in SDL 2.0 -

i trying load multiple texture images in sdl app cannot load or render second image on screen. see grass.bmp being displayed. cannot load bob.bmp. have no idea error have implemented properly my header file #include <sdl.h> #include <sdl_image.h> #ifndef gamewindow_h #define gamewindow_h class gamewindow{ private: bool _running; sdl_window* _screen; sdl_renderer* _renderer; sdl_texture* _grasstexture; sdl_texture* _bobtexture; sdl_rect _grassrect; sdl_rect _bobrect; ...... my .cpp file void gamewindow::loadsprites(){ _grasstexture = img_loadtexture(_renderer,"grass.bmp"); _grassrect.x = 0; _grassrect.y = 0; _grassrect.w = 600; _grassrect.h = 500; _bobtexture = img_loadtexture(_renderer,"bob.bmp"); _bobrect.x = 150; _bobrect.y = 150; _bobrect.w = 80; _bobrect.y = 50; } void gamewindow::initialize(){ if(sdl_init(sdl_init_everything) == -1) _running = fals

html5 - How to JQuery Drap and drop multiple/update msg on drop -

i have project - simple game, far can drag , drop need same draggable image - when dropped - update display in drop div... <script type="text/javascript" src="game/js/jquery1.5.min.js"></script> <script type="text/javascript" src="game/js/jquery-ui1.8.min.js"></script> $( init ); function init() { $('#drag').draggable( { containment: '#content', cursor: 'move', snap: '#content', revert: true }) $('#drop').droppable( { drop: handledropevent } ) } function handledropevent( event, ui ) { var draggable = ui.draggable; //replace image.... var num = 5; num--; $(this).html('<img src="game/images/watermelon_-'+num+'.png">').data( ); //call php game->points(); points... }

javascript - call page in iframe with bootstrap modal? -

i use this bootsrap modal plugin , call page in it. when page needs postback or redirection, not happen in modal, changes page. want show pages in iframe in boostrap modal. this modal func. code; how should modify show contents in iframe? $.fn.modal.defaults.spinner = $.fn.modalmanager.defaults.spinner = '<div class="loading-spinner" style="width: 200px; margin-left: -100px;">' + '<div class="progress progress-striped active">' + '<div class="progress-bar" style="width: 100%;"></div>' + '</div>' + '</div>'; $.fn.modalmanager.defaults.resize = true; var $modal = $('#ajax-modal'); $('.modal-edit').on('click', function () { // create backdrop , wait next modal triggered $('body').modalmanager('loading'); var edit = $(this).attr("data-