Posts

Showing posts from February, 2015

c++ - Creating variables from different line types imported from text file -

i'm trying import data text file , assign variables can analyse functions. data in following format: run 141544 event 5 njets 0 m1: pt,eta,phi,m= 231.277 0.496237 -2.22082 0.1 dptinv: 0.000370146 m2: pt,eta,phi,m= 222.408 -0.198471 0.942319 0.1 dptinv: 0.00038302 run 141544 event 7 njets 1 m1: pt,eta,phi,m= 281.327 -0.489914 1.12498 0.1 dptinv: 0.000406393 m2: pt,eta,phi,m= 238.38 0.128715 -2.07527 0.1 dptinv: 0.000399279 ... there around 15000 entries, each 4 lines. on each line, values delimited spaces, , between each entry, there blank line. because each line of entry in different format, wrote loop separate cases. problem i'm having appears wrong code assigns variables. when use loop output lines of type, runs perfectly. once try break each line variables , assign , print variables, program prints same line multiple times , crashes. here's code: #include <iostream> #include <fstream> #include <sstream> #include <cmath> #include &

php - GET variable Value lost ,want to store (causing me trouble in pagination of data ,because GET value lost on page load) -

i m working on php codeigniter found issue while paging datatable, take value view through query string , recevie asa value , use fetch data data base in clause,problem have facing have done paging of retrieved data ,on view 1st set of data comes fine ,but on number 2nd click shows error value empty ,paging works value database offset , limit when value lost after 1st page load ,shows error ,plzz me body can store $_get['value'] long time unless select value view.!! get variable value lost ,want store changes on requesting (causing me problem in pagination of data ,because value lost on page load) model function get_data($limit,$offset ) { //$type = $this->input->post('data'); $this->db->select('s_name,p_name,p_price'); //$this->db->from(); $this->db->join('item_info', 'p_id = i_productid '); $this->db->join('order_info', 'i_orderid = o_id'); $this

git - BitBucket: My Cloned repo does not include other branches -

i working on project @ work , have uploaded project private bitbucket repo, have cloned repo on home machine, master branch , not other branch develop . how can make sure local repo matches origin/remote version able work on branch edit: no sooner post find answer typical a answer here

c# - WPF DataGrid with different UserControl in each Cell -

Image
i hava data model looks this: public class model { public string displayas {get;set;} // textbox, checkbox, combobox public string value {get;set;} public string displayname {get;set;} // row1, row2, ... } now want display these models in datagrid shall this: how achieve this? please provide example code. tried whole day different kind of datatemplateselectors can't working your selector selects template cells in second column based on displayas value. have add templates datagrid.resources . in second column, assign celltemplateselector public class dynamicdatatemplateselector: datatemplateselector { public override datatemplate selecttemplate(object item, dependencyobject container) { frameworkelement element = container frameworkelement; if (element != null && item != null && item task) { model model = item model; return element.findresource(model.displayas + "

wcf data services - Suppress emitting of default values in WCF ODATA -

i have data entity poco set in self-hosted wcf odata service running wcf data services 5.5. the data entity has several string properties null. i'd suppress output of these properties when null reduce size of data crosses wire. [dataserviceentity] [dataservicekey("id")] public class mydata { public string id { get; set; } [system.runtime.serialization.datamember(emitdefaultvalue=false)] public string description { get; set; } } datamember(emitdefaultvalue = false) seems have no effect on data entity serialization: { "id":"test4", "description":null } how can persuade wcf data services suppress null property? do know asp.net web api odata provider? http://www.nuget.org/packages/microsoft.aspnet.webapi.odata you can write own serializer. (inherit odatafeedserializer) odataentry class has key/value property called "properties". can try clear out empty properties there.

c++ - Is there a way to get Common/templated functionality with different function names? -

first of all, wasn't sure name question, hope it's enough. essentially, have whole bunch of functions have common functionality differ types. sounds templates yeah? here catch: each function specific enough name each function differently. for example, @ following code: bool getfriendslist(friendslistrequestdata::callbacktype callback) { check(callback != nullptr); friendslistrequest* request = new friendslistrequest(this, getnewrequestid()); friendslistrequestdata* data = new friendslistrequestdata(request, callback); return storeandperformrequest(data); } bool getaccountinfo(accountinforequestdata::callbacktype callback) { check(callback != nullptr); accountinforequest* request = new accountinforequest(this, getnewrequestid()); accountinforequestdata* data = new accountinforequestdata(request, callback); return storeandperformrequest(data); } // many more routines... the 2 functions identical. differ types , function names. te

what type of password hash? possible mysql hash? -

i hosting localhost site , can't find decrypted password anywhere. the encrypted password => *85a7adb64bfb8faf77d233387448779c66d02a86 i think mysql5 password can't decrypt it. whats decrypted-pass? you can't decrypt password. mysql passwords encrypted using one-way encryption function. per manual : encryption performed password() one-way (not reversible). not same type of encryption used unix passwords; that, use encrypt().

jquery - Using .fadeIn() sequentially -

i've got bunch of divs, default set display:none , fadein 1 one after delay of 500ms. approach below works great, way should be? happens if there no more div value of display:none ? function myfadein() { $(".myitems:hidden:first").fadein(500, function(){ myfadein(); }); } ("#mybutton").click(function(){ myfadein(); }); i made few little changes, in part make function more generic, otherwise code should work. function recursivefadein(selector) { $(selector+":hidden").eq(0).fadein(400, function(){ recursivefadein(selector); }); } $("#mybutton").on("click",function(e){ recursivefadein("ul > li"); }); here jsfiddle: http://jsfiddle.net/qnabc/1/ i replaced ":first" selector eq(0) performance (see jquery :first vs. .first() ), , there many other little rtweaks can if you're crazy performance (see performance of jquery visible ).

c - How does one access the raw ECDH public key, private key and params inside OpenSSL's EVP_PKEY structure? -

i'm using openssl's c library generate elliptic curve diffie-hellman (ecdh) key pair, following first code sample here . glosses on actual exchange of public keys line: peerkey = get_peerkey(pkey); the pkey variable , return value both of type evp * . pkey contains public key, private key, , params generated earlier, , return value contains peer's public key. raises 3 questions: how get_peerkey() extract public key pkey sending peer? how code extract private key , params pkey store them later use after key exchange? how get_peerkey() generate new evp_pkey structure peer's raw public key? i've seen openssl functions evp_pkey_print_public() , evp_pkey_print_private() , , evp_pkey_print_params() these generating human-readable output. , haven't found equivalent converting human-readable public key evp_pkey structure. to answer own question, there's different path private key , public key. to serialize public key: pass evp_

call a variable created in an event function in wx python -

i created variable (snowdir) via getpath inside wx.dirdialog box , use snowdir outside function. there sample of code: for file in os.listdir(snowdir): if fnmatch.fnmatch(file, '*.hdf'): if file[9:16] == a: inputhdf = (snowdir + '\\' + file) print 'input hdf is: ', inputhdf tmod = 1 def ondownload(self, e): modispathfile = 'modis_data_directory_path.txt' dlg = wx.dirdialog(self, "choose directory:", style=wx.dd_default_style #| wx.dd_dir_must_exist #| wx.dd_change_dir ) if dlg.showmodal() == wx.id_ok: print "you chose %s" % dlg.getpath() snowdir = dlg.getpath() print 'snowdir : ', snowdir dlg.destroy() more code .... return snowdir any appreciated since i've search net without lock , i&#

java - Regular expression with characters -

i validating city field , accept spaces between words, example "san francisco". right can validate cities of single word. how improve code? public static boolean verifycity (context context, string _string) { pattern pattern_ = pattern.compile("[a-za-z]+[\\s]+"); matcher matcher = pattern_.matcher(_string); boolean matchfound = matcher.matches(); if (matchfound) return true; else return false; } why not allow spaces in range pattern pattern_ = pattern.compile("[a-z][a-za-z\\s]*[a-za-z]"); the other ranges avoid spaces @ beginning or end.

javascript - How to run function when route is loaded? -

i want have myfunk() run when overview route loaded onto page, , when go somewhere else , come back, myfunk() run again, have no model overview view, tried use didinsertelement dont know if makes sense. app.js: app.router.map( function() { this.resource('overview'); }); app.overviewview = ember.view.extend({ didinsertelement: function() { myfunk(); } }); index.html: <script type="text/x-handlebars" data-template-name="application"> <div id="wrapper" class="clearfix"> <div id="content" class="clearfix"> {{outlet}} </div> </div> </script> and route template: <script type="text/x-handlebars" data-template-name="overview"> <div class="leftbox"> <img id="kpibox" src="../img/kpis.png" /> </div> </script> you hook a

php - cakePHP , cant connect to database , XAMPP on windows -

im recieving error... "cake not able connect database. database connection "mysql" missing, or not created." ive tried ive read on google, extension=php_pdo_mysql.dll there in php.ini , not commented out... changed host whats seen below instead of localhost ive added port, doesnt make difference. have double checked username , password , db name. am missing obvious? class database_config { public $default = array( 'datasource' => 'database/mysql', 'persistent' => false, 'host' => '127.0.0.1', 'login' => 'cakeshop', 'password' => 'connect', 'database' => 'cakeshop', 'prefix' => '', 'port' => '/tmp/mysql.sock' //'encoding' => 'utf8' ); public $test = array( 'datasource' => 'database/mysql', 'persistent' => false,

embedded - What is the best way to compile a specific C program that may have dependencies? -

i compile following c file on embedded platform: https://github.com/openwsn-berkeley/openwsn-fw/blob/develop/firmware/openos/bsp/chips/at86rf231/radio.c however, can see, on lines 20-26 of radio.c references "radiotimer_capture_cbt": typedef struct { radiotimer_capture_cbt startframe_cb; radiotimer_capture_cbt endframe_cb; radio_state_t state; } radio_vars_t; radio_vars_t radio_vars; so need hunt down defined , make sure include right header. i have cloned entire git repository here: https://github.com/openwsn-berkeley/openwsn-fw , , i'm looking way compile easily. is there better way compiled other going through brutal dependency nightmare? my ultimate goal radio.c compiled , needs. not see makefiles in project i'm expecting want use ide. the project seems use scons build system. simplest way dive scons files. there's small scons file in directory containing linked file , 2 main script in top directory. but if want play,

Responsive list items -

i have list items , them auto expand parent width. html looks this: <div class="wrapper"> <div class="playlistholder"> <div class="playlist_inner"> <ul> <li>coffee</li> <li>tea</li> <li>milk</li> </ul> </div> </div> </div> wrapper needs 100% browser width. playlistholder , list items inside need 100% width , responsive follow width of wrapper. how can achieve css? take @ fiddle: http://jsfiddle.net/umzb8/1/ .wrapper { width: 100%; background: red; padding: 5px; } .playlistholder { width: 100%; } .playlist_inner ul { list-style:none; padding: 0; } .playlist_inner ul > li { width: 100%; padding: 0; background: blue; }

python 3.x - Python3 Virtual Environment and PIP -

i'd play around in virtual environment that's being interpreted purely via python3.3. on system (ubuntu 13.04), there 2 ways create virtual environment. virtualenv env or: pyvenv-3.3 env if use old faithful, virtualenv , i'm able use expected, however, pip installs python2.7 libs rather python3.3 libs. so, calling scripts using python3 script.py doesn't seem work, yet: python script.py works charm. but, must using python2.7 now, if instead, use "built-in" venv python3+ ( pyvenv-3.3 ), seems get's little whacky. correctly places python3.3 lib folder in venv, however, installing modules using pip no longer possible seems somehow reference global rather virtual environment. so, on question: how recommend getting working virtual environment python3.3(+) , pip installing python3.3 libs? you might consider trying similar following: create virtual environment $ python3 -m venv myvenv $ source myvenv/bin/activate (myvenv

java - Scanner's nextLine(), Only fetching partial -

so, using like: for (int = 0; < files.length; i++) { if (!files[i].isdirectory() && files[i].canread()) { try { scanner scan = new scanner(files[i]); system.out.println("generating categories " + files[i].topath()); while (scan.hasnextline()) { count++; string line = scan.nextline(); system.out.println(" ->" + line); line = line.split("\t", 2)[1]; system.out.println("!- " + line); jsonparser parser = new jsonparser(); jsonobject object = parser.parse(line).getasjsonobject(); set<entry<string, jsonelement>> entryset = object.entryset(); exploreset(entryset); } scan.close(); // system.out.println(keyset);

html - Making a Footer stay at the bottom and not overlap on zoom with dynamically generated height main content - Sticky footer doesn't work -

i working on large website client , have run issue previous designers structure. footer not stay @ bottom of content when dynamically generated. have hidden divs opened links. these divs contain user comments. when both opened footer overlaps of content. when zoom in footer overlaps of main content. i've tried: ryan fait's css , html5 sticky footers how keep footer @ bottom dynamic height website css reset sticky footer prevent footer overlapping all no success. doing full restructure option? i've tried using javascript make footer stay @ bottom of content. once document loaded , height changes, footer doesn't move content. ideas? code have long - 4000 lines of css, 2000 lines of html. should post part?

javascript - other way how to toggle 2 function in jQuery -

i want toggle tweenmax when click tweenmax.to(con, 1, {height: '200px', ease:bounce.easeout}); here want: function one() { tweenmax.to(con, 1, {height: '200px', ease:bounce.easeout}); } function two() { tweenmax.from(con, 1, {height: '200px', ease:bounce.easeout}); } $('.click').toggle(one, two); con div animation height when click posible ? please help you setup variable keep track when clicked: this using functions: function one() { tweenmax.to(con, 1, {height: '200px', ease:bounce.easeout}); } function two() { tweenmax.from(con, 1, {height: '200px', ease:bounce.easeout}); } var clicked = false; $(document).on('.click',function(){ var $this = $(this); if(clicked === false){ one(); clicked = true; } else if(clicked === true){ two(); clicked = false; } return false; }); or use tweens right in click handler: var

Print values inside the array with an on click event in C++ -

please note below code only idea , , not actual code . how print characters inside teststring[] array 1 @ time when button clicked? const string teststring[] = { "a", "b", "c", "d", }; if ( button ).onclick() == true { int = 0; printf("output: %s\r\n", teststring[i]); i++; } it similar code in http://jsfiddle.net/dfprp/ , in javascript , instead of numbers, want characters stored in teststring array. if understood question correctly, looking for std::string teststring = "abcd" private void mymethod() { int len = teststring.length(); for(int cnt=0; cnt< len; cnt++) printf("output: %c\n", teststring[i]); }

algorithm - replacing spaces with %20 in c program -

i have written following program replace spaces %20.it works fine. prints garbage values pointer variable ptr though might have been limited 8 characters malloc assigns 8 bytes of memory. can tell me did go wrong here ? or there in place algorithm ? void replacespaces(char *inputstr ) { char *ptr; int i,length, spacecount=0; int newlength,j; (length=0; *(inputstr+length)!='\0';length++ ) { if (*(inputstr+length)==' ') { spacecount++; } } newlength = length + 2*spacecount; ptr = (char *)malloc(newlength*sizeof(char)); ( = length-1; >=0; i--) { if (*(inputstr+i)==' ') { *(ptr+newlength-1)='0'; *(ptr+ newlength-2)='2'; *(ptr+newlength-3)='%'; newlength = newlength -3; } else { *(ptr+newlength-1) = *(inputstr+i); newlength = newlength -1;

How to use variables in different less files? -

let's separate less files many less files easy organize. here repository: /reset.less /variables.less /mixins.less /main.less /styles.less the styles.less importing other files: @import "reset.less"; @import "mixins.less"; @import "variables.less"; @import "main.less"; however, when add codes main.less , use @line-color defined in variables.less. shows name error: variable @line-color undefined , cannot compile it- use phpstorm less plugin. could pleas suggest me? you have import variables.less files use variables. edit: you have compile style.less. cannot compile main.less because doesn't know variables.less don't want main.css anyway, you? should correct style.css (i guess) css file you'll need.

nasm - Windows Text to Speech uses which library and function -

i making nasm code invoke text speech . need know windows library , function windows "text speech" utility use( default 1 ) . tried searching on msdn pointing me towards microsoft robotics developer studio , microsoft silverlight etc . microsoft speech api or sapi - http://msdn.microsoft.com/en-us/library/ms723627(v=vs.85).aspx i not familiar nasm cannot advice on how nasm.

excel vba - Vlookup error message when comparing 2 opened workbooks -

i have problem code below: code: sub cpt_click() dim cptbook, prbook workbook dim cptsheet, prsheet worksheet dim cptrange range dim myresult, lookvalue string set prbook = thisworkbook set prsheet = prbook.worksheets("implementation") set cptbook = workbooks.open("cpt.xlsx", readonly:=true) set cptsheet = cptbook.worksheets(2) set cptrange = cptsheet.range("g4:dy300") lookvalue = prsheet.range("u18").value 'returns correct value myresult = application.worksheetfunction.vlookup(lookvalue, cptrange, 2, false) msgbox myresult end sub when click on button, famous: "unable vlookup property of worksheetfunction class" error message. i have tried , when typing vlookup function inside sheet, correct value - value i'm looking (lookvalue) in cptsheet within cptrange. any thoughts? thanks in advance. you need set cptrange's external attribute of address

error:undefined label, how to use label statement in this code in java? -

i read in textbooks java statement can labeled , can used break. while trying code error undefined label. (guys @ stackoverflow wait before marking question duplicate, have checked questions none of explain problem). public class labeltest { public static void main(string[] args) { first: system.out.println("first statement"); (int = 0; < 2; i++) { system.out.println("second statement"); break first; } } } as per jls 14.7 the scope of label of labeled statement contained statement. so in case, scope of lable first sysout statement following lable. clearer, can define scope using curly braces , , within these braces valid jump label . below valid first: { system.out.println("first statement"); (int = 0; < 2; i++) { system.out.println("second statement"); break first; } } or first: { system.out.pri

C++ passing dynamic array element to a function -

the code looks this: void func(float b){ //does nothing } float* finit(void){ float result[3]; result[0] = 1.0; result[1] = 1.0; result[2] = 1.0; return result; } int main(){ float* = new float[3]; = finit(); func(a[0]); printf("%f, %f, %f", a[0], a[1], a[2]); return 0; } values of array elements -107374176.000000. works if func(a[0]) [which nothing] commented out. what's problem? edit: code edited bit better understanding you cannot return raw array that. finit() return address of local memory invalidated once function returns. your a then, in sense, points memory inside finit() , not valid anymore. attempt read element a[n] results in undefined behaviour. you should use 1 of standard containers, e.g. std::vector if size of array determined @ runtime, or std::array if know size @ compile time. if need chained lists, use std::list , , on. all of standard containers copyable (and returnable). see http://en.cpprefe

java - Ant build.xml file unable to use a property in the fileset element -

i using ant build.xml build simple war file. <?xml version="1.0" ?> <project name="cellar" default="war"> <target name="init"> <property file="${user.home}/build.properties"/> <property name="app.name" value="${ant.project.name}"/> <property name="src.dir" location="src"/> <property name="lib.dir" location="lib"/> <property name="build.dir" location="build"/> <property name="dist.dir" location="dist"/> <property name="classes.dir" location="${build.dir}/classes"/> <mkdir dir="${build.dir}"/> <mkdir dir="${dist.dir}" /> </target> <path id="classpath"> <fileset dir="lib"> <include name="*.jar"/> </fileset>

php - Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No such host is known -

i have downloaded wamp server. want establish connection mysql database php , i'm using root user, localhost , name of database. code seems correct when run on wamp, following error: warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: no such host known. in c:\wamp\www\cone.php on line 8 , warning: mysqli_connect(): (hy000/2002): php_network_getaddresses: getaddrinfo failed: no such host known. also, error message haven't been connected database(from if statement) displayed. does mean have configuration on server? here code: <?php $dbcon = mysqli_connect('root','', 'localhost', 'people'); `if(!$dbcon)` `{` `die('error connecting database');` `}` `echo "success";` ?> thank in advance mysqli_connect('root','', 'localhost', 'people'); you passing root in hostname. try this mysqli_connect('localhost','root', ''

mysql - Inserting Persons with IDs in one query? -

i need add data mysql database that: person: pid, nameid, titleid, age name: nameid, name title: titleid, title i don't want have names or title more once in db didn't see solution last_insert_id() my approach looks that: insert ignore name(name) values ("peter"); insert ignore title(title) values ("astronaut"); insert person(nameid, titleid, age) values ((select nameid name name = "peter"), (select nameid name name = "astronaut"), 33); but guess that's quite dirty approach!? if possible want add multiple persons 1 query , without having more 1 times in db. possible in nice way? thanks! you put title , name 2 columns of table , then: set 1 unique index on each column if don"t want have 2 titles or 2 names identical in db or set unique index on (title,name) if don't want have 2 entries having both same name and same title. if really want have separate tables, suggested in post, wrappin

r - operations on a variable from a data.frame with time points -

i stuck in problem , send call (i went through similar questions not find need, although seems simple) : have original dataframe 50 patients 3 time points (reproducible code below) , variable of interest called "ht". goal study variations of ht between these 3 time points, example according variable (ex here numerical variable "a"). id <- rep(c(seq(1,50,1)),3) time <- factor(rep(c("day1", "day2", "day3"), c(50,50,50)), levels=c("day1", "day2", "day3"), labels=c("day1", "day2", "day3"), ordered=true) ht <- rnorm(150, mean=30, sd=3) <- rnorm(150, mean=7, sd=10) dfrm <- cbind (id,time,ht,a) > head(dfrm) id time ht [1,] 1 1 28.64048 11.1595852 [2,] 2 1 28.30068 4.2925773 [3,] 3 1 32.51943 21.2013316 [4,] 4 1 30.66561 0.6980816 [5,] 5 1 28.92749 22.2756818 [6,] 6 1 33.82217

ehcache - Spring with hibernate cache native query -

i'm using spring 3.2 hibernate 4. in dao implementation want cache results of native sql query. method results of query looks this: public list<object[]> getbestsellers(string category) { session session = sessionfactory.getcurrentsession(); query query = session.createsqlquery( "select i_id, i_title, a_fname, a_lname , sum(ol_qty) val " + "from " + "orders, order_line, item, author " + "where " + "order_line.ol_o_id = orders.o_id , item.i_id = order_line.ol_i_id " + "and item.i_subject = :category , item.i_a_id = author.a_id group i_id " + "order orders.o_date, val desc" ); query.setparameter( "category", category ); query.setmaxresults( 50 ); query.setcacheable( true ); list<object[]> res = query.list(); return res; } it seems doesn't work , don't know why. i have confi

Validation of array form fields in laravel 4 error -

how can validate form fields arrays? take @ following code userphone model: public static $rules= array( 'phonenumber'=>'required|numeric', 'isprimary'=>'in:0,1' ) ........... usercontroller: $validation = userphone::validate(input::only('phonenumber'))); if($validation->passes()) { $allinputs = input::only('phonenumber','tid'); $loopsize = sizeof($allinputs); for($i=0;$i<$loopsize;$i++) { $phone = userphone::find($allinputs['tid'][$i]); $phone->phonenumber = $allinputs['phonenumber'][$i]; $phone->save(); } return redirect::to('myprofile')->with('message','update ok'); } else { return redirect::to('editphone')->witherrors($validation); } } the $validation comes basemodel extends eloquent. in view: <?php $counter=1; ?>

objective c - UIKit additions: bridging the gap between eg CGRectValue and NSStringFromCGRect? -

i'm trying implement specialized typed logger takes dictionary input , creates string of values out of it. one sample such dictionary might be: cgsize size = {300, 200} ; cgaffinetransform t = ::cgaffinetransformidentity ; [self logit: @{ @"columns": @{ @"value": @3 , @"type": @"nsnumber" } , @"size": @{ @"value": [nsvalue valuewithcgsize(size)] , @"type": @"cgsize" } , @"transform": @{ @"value": [nsvalue valuewithcgaffinetransform(t)] , @"type": @"cgaffinetransform" } }] ; the issue is: how retrieve values in generic way? i write (nsstring * key in dict) { nsdictionary * params = dict[key] ; if ([params[@"type"] isequaltostring: @"cgrect"]) { cgrect r = [params[@"value"] cgrectvalue] ; nsstring * s = ::nsstrin

javascript - Is ASCII 19 used? -

i used answer in page saving text on ctrl+s , don't copy-pasting without understanding first, decided first. it's simple jquery script, converted (still working) this: /* key pressed */ $(window).keypress(function(event) { /* ctrl + s or ?? */ if ((event.which == 115 && event.ctrlkey) || (event.which == 19)) { savedata(); event.preventdefault(); } }); the bit i'm asking event.which == 19 . quick search on ascii codes tells me it's "device control 3 (oft. xoff)". however, the link of xoff , google didn't bring light subject. so, is ascii character 19 (device control 3) still used in computers/keyboards/other devices or can securely delete bit? note: want delete can change switch , don't have hanging, not understood code. afair which key scancode, not ascii code. anyway, code 19 should stand key arrow or somewhat, doesn't have printable representation letter or digit. e.g. [esc] has code 27. http:/

c# - One ViewModel for multiple views in wpf mvvm -

i'm working on wpf project mvvm pattern, have such scenario: window seperated 2 parts, first part simple, textbox users input keywords , button searching keyword. second part user control, default, it's advanced search user control, users can select different selections, such categories, authors, each of selection support multiple selection. after user setting filter in advanced search user control, click search button in first part search. after searching results return, replace advanced search user control result list user control. should create viewmodel contains result collection, advanced search options , used main window , 2 user controls? or there more appropriate solution? thanks in advance!

symfony - symfony2 semantic bundle configuration - conditional required parameter -

i working on bundle have couple of required parameters. want able disable bundle setting enabled: false in parameters.yml. if bundle disabled configuration parameters cant required more. is there anyway can in bundle configuration class required parameters required if enabled parameter true? thank you. edit: my configuration.php $rootnode ->children() ->arraynode('settings') ->canbeenabled() ->children() ->scalarnode('api_key') ->isrequired() ->cannotbeempty() ->end() ->scalarnode('api_secret') ->isrequired() ->cannotbeempty() ->end() ->booleannode('debug') ->defaultfalse()

css - Logo Responsive Design - On zoom comes out of the box -

i using gantry on template joomla 2.5 template set host small image logo @ first point wanted changed bigger 1 in ters of width. so, doesn't work on ipad goes out of box , menu appears on top of it. here logo css lines : .logo-block { padding-top: 25px; padding-bottom: 15px; padding-left : 0px; padding-right: 15px; margin-top : 7px; margin-bottom : 10px; margin-left: 0px; margin-right : 50px;} rt-logo { margin: -9px 0 0 0; max-width: 370px; max-height: 84px; display: block;} i want logo resize page view becomes bigger. can please me out ? thanks in advance, nick

mysql - How to update target table in FROM clause? -

i prepared following sql statement in order update field master_id of staging table id of corresponding row of master table. master contains objects unique location . therefore 1 id @ maximum should returned if @ all. update staging set master_id = ( select m.id master m, staging s m.lat = s.lat , m.lon = s.lon ); the query fails you can't specify target table 'staging' update in clause . how can fix this? also think query can optimized using join . if can greatful! here try on joining both tables: update staging s inner join master m on s.lat = m.lat , s.lon = m.lon set s.master_id = m.id; query ok, 0 rows affected (0.38 sec) rows matched: 14976 changed: 0 warnings: 0 next try: update staging s inner join ( select id, lat, lon master ) m on s.lat = m.lat , s.lon = m.lon set s.master_id = m.id; query ok, 0 rows affected (0.35 sec) rows matched: 14976 changed: 0 warnings: 0 please mind, using mysql if affects syntax of solution.

php - jQuery stopping after parseJSON -

$.get('api/dosomething.php',data,function(responsetext){ alert(responsetext); var response = jquery.parsejson(responsetext); alert(response); the first alert says: object (object) however, next alert never executed. uncaught syntaxerror: unexpected token ) file.php:1 4 uncaught syntaxerror: unexpected token o php: $result = array('id' => $db->lastinsertid()); header('content-type: application/json'); echo json_encode($result); your php script tells browser serving json ( content-type: application/json ). $.get automatically detects , converts fetched json data valid javascript object. $.get('api/dosomething.php',data,function(data) { alert(data.id); }); http://api.jquery.com/jquery.ajax/#data-types : the type of data you're expecting server. if none specified, jquery try infer based on mime type of response

performance - is it worth it to convert graphics from jpg to png? -

all game textures start in jpg. i've been converting them png android game, since i've read seems default format recommended, haven't seen justification on over jpg when original file jpg. know difference between jpg , png (lossy vs lossless), , png converted jpg can't of higher quality original jpg, file size increases in conversion anyway. have been doing in case png files process faster in game or display better on phone screen. either of these case or should leaving in original jpg save memory , time. it late, you've lost fidelity. png cannot make lost pixels re-appear, works in law & order crime lab. quite liable png that's larger necessary due quantization noise, added when jpeg data converted bitmap. you'll need original artwork , skip jpeg encoding step go straight png. never smaller file, better.

jquery - How to get the "index" of a draggable element? -

for sortable element, use ui.item.index() . there equivalent draggable elements? $('.elem').draggable({ start: function(event, ui){ //how "index" of ui.item? } }); just use jquery.index() anywhere else: $('.elem').draggable({ start: function () { var myindex = $(this).index(); $(this).text('i #' + myindex); } }); here's fiddle .

sql - What is LINQ operator to perform division operation on Tables? -

to select elements belonging particular group in table, if elements , group type contained in 1 table , group types listed in table perform division on tables. trying linq query perform same operation. please tell me how can perform it? apparently definition of blog post you'd want intersect , except. table1.except(table1.intersect(table2)); or rather in case i'd guess table1.where(d => !table2.any(t => t.type == d.type)); not hard. i don't think performance can made better, actually. maybe groupby. table1.groupby(t => t.type).where(g => !table2.any(t => t.type == g.key)).selectmany(g => g); this should better performance. searches second table every kind of type once, not every row in table1.

tortoisesvn - Upgrading SVN after new Windows installation -

i've been running tortoise svn awhile , have been using v1.6.8 . bought new hd decided time upgraded svn , downloaded v1.8.1 my old svn installed at: c:\program files\tortoisesvn my new 1 installed at: g:\program files\tortoisesvn accidentally installed windows g drive , c: occupied old drive removed soon. all repositories remain in same place versioned files/folders. so question is, there need worry when doing upgrade? such path information considering installed @ new location? process need follow? i want keep old settings etc wanting keep data inside application data\tortoisesvn folder not sure if compatible new version? i'm thinking this.. install old version g:\program files\tortoisesvn copy on old data in application data\tortoisesvn new dir install new version would it? or above there path issues or other things consider? is there need worry when doing upgrade? yes such path information considering installed @ new location

redis - this command is not available unless the connection is created with admin-commands enabled -

when trying run following in redis using booksleeve. using (var conn = new redisconnection(server, port, -1, password)) { var result = conn.server.flushdb(0); result.wait(); } i error saying: this command not available unless connection created admin-commands enabled" i not sure how execute commands admin? need create a/c in db admin access , login that? basically, dangerous commands don't need in routine operations, can cause lots of problems if used inappropriately (i.e. equivalent of drop database in tsql, since example flushdb ) protected "yes, meant that..." flag: using (var conn = new redisconnection(server, port, -1, password, allowadmin: true)) <==== here i improve error message make clear , explicit.

vbscript - Vb script for Speech to text (speech recognition)? -

this text speech script, easy, put in notepad , save anyname.vbs createobject("sapi.spvoice").speak"hello" open file, computer hello tutorial http://www.bustatech.com/get-the-gender-of-your-pc/ but how opposite (speech text script or speech recognition), please how script? i think asking speech recognition, im not sure if works in vbscript, know works in google chrome --- or in html connected google crhome. visit site- http://www.labnol.org/software/add-speech-recognition-to-website/19989/ try microsoft speech recognition.

eclipse - Getting Theano to use the GPU -

i having quite bit of trouble setting theano work graphics card - hope guys can give me hand. i have used cuda before , installed necessary run nvidia nsight. however, want use pydev , having several problems following 'using gpu' part of tutorial @ http://deeplearning.net/software/theano/install.html#gpu-linux the first quite basic, , how set environment variables. says should ' define $cuda_root environment variable '. several sources have said create new '.pam_environment' file in home directory. have done , written following: cuda_root = /usr/local/cuda-5.5/bin ld_library_path = /usr/local/cuda-5.5/lib64/lib i not sure if way has written - apologies if basic question. if confirmation indeed correct place have written it, too, helpful. the second problem in following part of tutorial. says ' change device option name gpu device in computer '. apparently has theano_flags , .theanorc, able find out these are: files? if find them? tutorial

php - Update MySQL table with button without refreshing page using ajax -

i trying update value in database without refreshing page using ajax . new ajax have have managed create function after searching answers on stackoverflow unable make work. one main page... <script type="text/javascript" src="/js/jquery.js"></script> <script> function updaterecord(id) { jquery.ajax({ type: "post", url: "del_reason.php", data: 'id='+id, cache: false, success: function(response) { alert("record updated"); } }); } </script> the button (which in form) <input type="button" name="delete_pos" value="delete" class="delrow_pos" onclick="updaterecord(<? echo $row['reasonid']; ?>);"/> the contents of del_reason.php $var = @$_post['id'] ; $sql = "update gradereason set current = 0 reasonid = $var"; $result = mysqli_q

Is CQ5 used as a backend service? -

i have experience other enterprise cms's teamsite & tridion, no hands on experience cq5. i'm wondering, how cq5 integrated large site has content & functionality? functionality defined pages generated data non-cms repository or webservice. my question is, cq5 content read in back-end service? know api http based. api typically called server or client? example, lets have page driven web service linked non-cms enterprise system, want footer & right rail "content" users can change easily. @ point the different page sources typically combined? i'm wondering because work asp.net. know cq5 java, expect cusomters java shops, think http easy consume asp.net site, if backend webservice. your question not clear me honest. i'm going answer rather broad. to answer question different page sources: client initiates http or json request server (although server server calls not uncommon in case of extended infrastructure) , server execute

ruby on rails - Testing an API resource with RSpec -

i've done bit of googling on topic, , i'm still confused. i'm building custom page zendesk api ruby client, , i'm @ stage when need test creation of zendeskapi::ticket resource. following code in spec/features directory. fills out form valid values , submits form #create action. standard, simple stuff. require 'spec_helper' feature 'ticket creation' scenario 'user creates new ticket' visit root_path fill_in 'name', with: 'billybob joe' fill_in 'email', with: 'joe@test.com' fill_in 'subject', with: 'aw, goshdarnit!' fill_in 'issue', with: 'my computer spontaneously blew up!' click_button 'create ticket' expect(page).to have_content('ticket details') end end and here relevant part of tickets controller. ticket_valid? method supplies minimal validations options hash , client instance of zendeskapi::client . def create

android - Make screenOrientation configurable? -

my activity forces portrait mode using android:screenorientation="portrait" in manifest. however, of users (on tablets default in landscape mode) have asked me make configurable option. possible set orientation in code (without triggering orientation-change animation, before activity displayed)? yes, call: activity.setrequestedorientation (int requestedorientation) taken from http://developer.android.com/reference/android/app/activity.html#setrequestedorientation%28int%29 if want lock screen orientation after setting it, take @ post: screen orientation lock

arrays - How do I get the hash name and key in TCL? -

i'm trying figure out how hash name , key in following situation. have following hash value: set client(car) "koenigsegg" if pass $client(car) proc, value passed "koenigsegg". there way capture fact hash , key storing value 'client' , 'car', respectively? for example: proc foobar {item} { set the_item $item } foobar $client(car) in example, proc receives value of $client(car), "koenigsegg". $item "koenigsegg", don't know kind of item is. i'd hash name "client" , key "car" know "koenigsegg" "client car". you can pass name of array proc, use upvar access it: proc process_array {arrayname} { upvar 1 $arrayname myarray puts "car $myarray(car)" } set client(car) "koenigsegg" process_array client ;# pass name of array, note: no dollar sign output: car koenigsegg i hope looking for. update so, want pass 2 things proc

java - Extracting 3rd digit of a hexadecimal number -

i want extract 3rd digit of hex number. example, extract 4 0x4598 . to extract 0th digit: (0x4598 & 0x0f) // returns 8 to extract 1st digit: (0x4598 & 0xf0) >> 4 // returns 9 to extract 2nd digit: (0x4598 & 0xf00) >> 8 // returns 5 for 3rd digit, followed pattern , tried (0x4598 & 0xf000) >> 16 , returns 0 . wrong? the pattern here add four, not double. try instead: (0x4598 & 0xf000) >> 12;

php - Enable drag and drop upload in div container -

i'm sure there couple of questions similar 1 out there had no idea search for. what i'm looking way enable drag , drop div on website. when drop file page (i'm using chrome) displays file (a file:// url) not want. if there's way without using plugins i'd more happy. should support multiple files. this div-css looks like: #dnd { position: absolute; top: 0; right: 0; left: 0; bottom: 0; } and here're jquery binds drag: function processfileupload(droppedfiles) { var uploadformdata = new formdata($("#dnd")[0]); if(droppedfiles.length > 0) { for(f = 0; f < droppedfiles.length; f++) { uploadformdata.append("upload[]",droppedfiles[f]); } } $.ajax({ url : "index.php", type : "post", data : uploadformdata, cache : false, contenttype : false, processdata : false }); } $("#dnd&q