Posts

Showing posts from March, 2011

android - How to map Enum in GreenDAO -

i've started using greendao. how add enum property? what i've thought of: using addindex property of entity. private static void main() { // todo auto-generated method stub static schema blah; entity unicorn = blah.addentity("weather"); unicorn.addidproperty(); unicorn.addintproperty("currentairtemp"); unicorn.addindex("shirtsize"); } is right way it? aim: want have reference shirtsize being set: {xs, s, m, l, xl, xxl} as far know, enums not supported greendao due unstable nature. error-prone component add database logic, since values of enum elements can change. one option around add int property database , map enum ordinal values field, so: // add int property entity unicorn.addintproperty("shirtsize"); // create enum static values public enum shirtsize { xs(1), s(2), m(3), l(4), xl(5), xxl(6); private final int value; private shirtsize(int value) { this.value =...

javascript - How plot json data -

i'm getting every 4 secs json data this: { "time": "04:49:07 am", "milliseconds_since_epoch": 1375246147254, "date": "07-31-2013" } i'm processing in order array this: [[1375230673948, 0.6443498175195954]] (the first data js timestamp) i'm trying plot these data, on real time using flot: function draw() { console.log('draw called'); this.array = gettimearray(); $.plot( $("#placeholder"), [ { label: "test data", data: this.array, lines: { show: true, fill: true, fillcolor: "rgba(249, 28, 61,0.3)", linewidth: 2.5 }, } ], { xaxis: { mode: "time", timeformat: "%h:%m" }, yaxis: { min: -2 } }); } function gettimearray(flg) { var array = [], d = new da...

file io - Perl in memory content writing in raw mode -

i using perl 5.10.0 , trying write content in memory buffer in raw mode . not working. in following code snippet tried compare result between 3 scenarios my ($s1, $s2); open rawf, '>:raw', \$s1; #<------- opening in memory reference in raw mode print rawf 'hello world in raw mode', "\n"; open fh, '>:raw', 'testfile.bin'; #<------- opening file in raw mode print fh 'hello world in file', "\n"; open norf, '>', \$s2; #<------- opening in memory reference in normal mode print norf 'hello world in normal mode', "\n"; print $s1; #<------ doesnt print print $s2; #<------ prints expected however, if use perl 5.14.* works. limitation of perl 5.10.1? or should done in other way work? apparently bug fixed in perl 5.12 timeframe. see perlbug #80764 - though initial report/fix doesn't mention problem, problem comes in discussion on bug , rolled ...

Convert (.hex?) file to viewable image -

i given text file , told converted image. text file looks this... 0000000 d8ff e0ff 1000 464a 4649 0100 0001 0100 0000010 0100 0000 e2ff a80c 4349 5f43 5250 464f 0000020 4c49 0045 0101 0000 980c 7061 6c70 1002 ... 000d320 8b4c 1b28 3bd4 0016 91e0 799e 34c1 4457 000d330 7113 ee4d cd73 4945 63db d9ff 000d33c from googling, i'm pretty sure .hex file (though many of hex files have seen online had different formats, not certain). when search 'converting hex image', results formatted mine dry. is on type of file , how can convert view-able image? thanks this looks jpeg file, encoded in .hex file. i'm not used working hex files, 7 first digit counting lines. i'll ignore them, i'm sure can find documentation on there role (if any!). real data bytes encoded in rest of each line. sometime ago, wrote lightweight jpeg encoder . went source see if bytes can see in file rang bell: the file starts d8ff , , code wrote encoding jpeg, star...

Multiple Array Insertion in C# using Foreach statement -

Image
private void updated_modrecfga() { try { drfgamodifiedrecord table = new drfgamodifiedrecord(); foreach (arrayfunc row in arrayfunc.queryresult) { foreach (arrayfunc row2 in arrayfunc.queryresult1) { table.recorddocid = row.fgacol1; table.drno = row.fgacol2; table.ddnum = row.fgacol3; table.linenumber = row.fgacol4; table.itemnmbr = row2.upditemcode; table.itemdesc = row2.upditemdesc; table.pallet = row2.updpallets; table.bagsno = row2.updbagsno; table.totalloaded = row2.updtotalkgs; table.poststat = row2.updpoststat; table.prodcode = row2.updprodcode; table.variantcode = row2.up...

Can't override onBackPressed neither onKeyDown - Android -

i'm implementing app tabhost. in 1 of tabs i'm executing more 1 activities (activitygroup). for example: i'm in activity one, after clicking in listview go activity 2 in same tab. problem when press button, application closes , want go activity one. i've overwritten onbackpressed() method, onkeydown method , won't called, not being fired. i've seen lot of posts same problem of solutions shown wont work. would glad help! creating tabs: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main_tab); tabhost fichas = gettabhost(); fichas.setup(); tabhost.tabspec spec=fichas.newtabspec("tab1"); intent = new intent(getapplicationcontext(), allproductsactivity.class); spec.setcontent(i); spec.setindicator("hoy"); fichas.addtab(spec); tabhost.tabspec spec2=fichas.newtabspec("tab2"); intent i2 = new intent(get...

DeleteWebFolder SkyDrive .Net API Client using C# -

this code , i'm confused write in foreach loop. please me advice helpful skydriveserviceclient svcclient = new skydriveserviceclient(); svcclient.logon( "username", "*********" ); webfolderinfo[] rootwebfi = svcclient.listrootwebfolders(); foreach(webfolderinfo deletewebfi in rootwebfi) { }

php - Merge the array duplicate values -

this question has answer here: how merge 2 arrays without duplicate values in php? 3 answers array ( [0] => tirupur ) array ( [0] => coimbatore ) array ( [0] => coimbatore [1] => chennai ) array ( [0] => coimbatore [1] => chennai [2] => madurai ) array ( [0] => bangalore ) i want final array below output array ( [0] => tirupur [1]=>coimbatore [2]=>chennai [3]=>madurai [4]=>bangalore) you can combine first array in 1 array , try way <?php $array1 = array("orange", "apple", "grape"); $array2 = array("peach", 88, "plumb"); $array3 = array("lemon", 342); $newarray = array_merge($array1, $array2, $array3); array_unique($newarray); hope sure you

javascript - jsf commandbutton setenabled onclick -

how can disable commandbutton (ajaxbutton) when user clicks on it? i tried with: onclick="javascript:this.disabled='true';" and onclick="document.getelementbyid('buttonid').disabled='true'" but nothing works? for specific problem think need remove quotes around 'true'. @ link how can disable h:commandbutton without preventing action , actionlistener being called?

oop - Argument count limit of methods in Smalltalk-80 implementation -

the maximum number of arguments of method limited 2^5-1 (i.e. 31) because there 5 bits encode number of arguments in compiled method illustrated in figure 27.4 of blue book . double extended send bytecode has 8 bits encode number of arguments (see definition of doubleextendedsendbytecode here ), means can send many 2^8-1 (i.e. 127) arguments message (using perform: or statement not compiled). contradiction? think bytecode uses many bits encode number of arguments. yes, contradiction did not yet matter enough. also, number of arguments in methods bounded maximum number of temporary variables in method, too, in smalltalks happen 2^8-1 . there part that: in squeak, number of arguments restricted 15 ( 2^4-1 ), , has nibble (4 bit) of space in method header. comment of squeak's compiledmethod states: (index 18) 6 bits: number of temporary variables (#numtemps) (index 24) 4 bits: number of arguments method (#numargs) with #numtemps including number of argum...

flex4.5 - what happens if i rename namespace in flex? -

i need clarification, regarding flex. happens if rename namesapace in <mx:module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%"> replacing <mx:module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:dx="library://ns.adobe.com/flex/spark" xmlns:ot="library://ns.adobe.com/flex/mx" width="100%" height="100%"> need know why , happens if this... thankxx in advance!! quoting example, how things change: before <s:application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%"> <mx:viewstack id="mainstack" top="0" bottom="0" ...

jquery - HTML Accessing iframe-"objects" from a clickable list -

i'm new site, i'll head right it! so i'm building website band , want have page can access our uploaded music via soundcloud. i'm using jquery other neat stuff on site think i'll stick that. anyway here's link "layout" i'm using. http://gyazo.com/94c87f0b96f58c598b555758e327e1fc here's want: clickable "songtitles" when click on song soundcloud-player changes song. is possible? yes, if understand correctly willing do, you'd need attach event handlers list items sound titles , re-set src of widget iframe. i hope helps.

java - The correct way to update/query from DB -

i abit new working datatbases java, , have been wondering if working in correct way. in code db interface done within 1 class called dataaccess, example of code: please note opened connection ( connblng ) before entering function isvalidoperator() . is correct way work or should open , close connection everytime need access db? if(da.startblngconnection() == null) return "error" dataaccess da = new dataaccess(); da.isvalidoperator("123") //this code dataaccess class public boolean isvalidoperator(string dn) { system.out.println( npgreqid + " - " + log_tag + "inside isvalidoperator : " + dn); preparedstatement prepstmt = null; resultset queryresult = null; try{ prepstmt = connblng.preparestatement("select network_id, network_identifier operators network_identifier = ?"); prepstmt.setstring(1, dn); queryresult = prepstmt.executequery(); if (queryresult.next()) { ...

How to place a textview on Gallery in android? -

in application have gallery view , displaying images database in gallery,i need place text view on gallery item , change text view value based on gallery position.so,how can place text view on gallery.please can 1 me. thanking in advance. use custom adapter gallery view. every item contain imageview , textview, example in relativelayout. example here: android gallery caption

Maven-archetype-webapp Directory Structure? -

is there possibility or workaroud use maven-archetype-webapp archetype generate maven webapp plain directory structure /src /main /java /resources /webapp /test /java /resources i assume issue missing java , test folders in new project when using maven-archetype-webapp. there no options make archetype add those. of course add them manually after project created. you may find archetypes in 1 of these lists: http://myjeeva.com/exclusive-maven-archetype-list.html http://docs.codehaus.org/display/mavenuser/archetypes+list if there nothing matches need suggest creating own archetype: http://maven.apache.org/guides/mini/guide-creating-archetypes.html it quite easy , if plan use 1 several times it's worth effort.

What occurs when assigning a string to char in C -

i appreciate understanding occur in next code? (writing "a" instead of 'a' , etc...). mean stored in memory , why isnt program crashes. char str[10] ; str[0] = "a"; str[1] = "b"; str[2] = "\0"; thanks. 'a' single character (type char ) having ascii value 97. "a" c style string, char array having 2 elements, 'a' , '\0'. if compile code above 3 warnings 3 assignments. on gcc these warnings this: main.c:6:12: warning: assignment makes integer pointer without cast [enabled default] lets take first assignment in code: str[0] = "a"; the right hand side operand, "a", char * . left hand side operand char , integer type. warning hints towards, takes value of pointer, converts integer, , truncates size of char , stores truncated value in str[0] . after assignment str[0] not contain value 'a' (ascii 97) might expect, value obtained described above. so far...

Rails 3.2: rake 10.0.3 required -

when executing rake operation, following: rake aborted! have activated rake 10.1.0, gemfile requires rake 10.0.3. using bundle exec may solve this. /home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/runtime.rb:33:in `block in setup' /home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/runtime.rb:19:in `setup' /home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler.rb:120:in `setup' /home/cristi/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.3/lib/bundler/setup.rb:7:in `<top (required)>' /home/cristi/code/kodion/config/boot.rb:6:in `<top (required)>' /home/cristi/code/kodion/config/application.rb:1:in `<top (required)>' /home/cristi/code/kodion/rakefile:5:in `<top (required)>' (see full trace running task --trace) i not sure can solve this. bundle exec doesn't solve anything. you either need run command in context of bundle (recommended): > bundle exec rake db:ver...

In python nltk I am trying to get parts of speach of a word by using pos_tag. but i am getting inaccurate output? Tell me the better tagger? -

import nltk nltk import word_tokenizer w="cat" word=nltk.word_tokenize(w) print nltk.pos_tag(word) output:[('cat','in')] but cat noun,but returns in(conjunction). pos tagging doesn't work out of sentence context. feed whole sentence pos_tag instead of single word, try again. if doesn't work, use nltk.download() fetch better pos tagging model , run that. if need pos tags single word, try wordnet: in [9]: nltk.corpus.wordnet.synsets('cat') out[9]: [synset('cat.n.01'), synset('guy.n.01'), synset('cat.n.03'), synset('kat.n.01'), synset("cat-o'-nine-tails.n.01"), synset('caterpillar.n.02'), synset('big_cat.n.01'), synset('computerized_tomography.n.01'), synset('cat.v.01'), synset('vomit.v.01')] (as can see, may have filter these.)

spring - java.lang.NoSuchMethodError while init. SessionFactory -

i have facelets / jsf managed beans/ hibernate application , need attach spring framework managing app. application fails start. gives me following stacktrace: 2013-07-31 12:17:35,528 error [contextloader] context initialization failed org.springframework.beans.factory.beancreationexception: error creating bean name 'homebean': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private com.dataart.mediaportal.dao.impl.imagedaoimpl com.dataart.mediaportal.controller.bean.homebean.imagedao; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'imagedaoimpl': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: protected org.hibernate.sessionfactory com.dataart.mediaportal.dao.abstractdao.factory; nested exception org.springframework.beans.factory...

html5 - Placing Large HTML content dynamically on TurnJs Flipbook -

i not sure if has been discussed, tried searching on list of issues not find related it. i have large html content need bind using turn.js. problem have that, turn js, have split html separate div tags pages. there way in turn.js bind content on div , takes care of automatically wrapping different pages based on content being bound? or there way know how data needs bound each page scenario working. here solution splitting content pages, , than, create book using turn.js. the logic of solution check if next content can in current page or need create new page , put content there. this code "read" html specific div , magic ;) alse, can play code in jsbin . var width = 400, height = 400, padding = 20; // create tester div. in `div` put contents , check if need new page var div = $('<div />').css({ // divide 2 because each page half book width: width / 2 }).appendto(document.body); var index = 0; var pages = []; ...

Code First Join options in Entity Framework 5 -

i'm creating webservice layer on legacy sql server based system. it's pretty large , complicated business application has large number of stored procedures perform select statements . of these stored procedures join number of tables , produce single resultset easy consumption client. in building webservice want take advantage of ef, , using code first approach 80% of use cases can achieved mapping direclty tables. have number of use cases need cross tbale views of data provided stored procedures. see have 3 options: create new pocos represent stored procedure returns , link these existing stored procedures (let sql join , re-use exisitng code) create new pocos stored procedure return, populate association othe ef entities (let ef jons) do joins somehow in linq what people think best practice in situations this, guess of coming against everyday? thanks, andy many book out there. julie lerman... more recent http://www.apress.com/9781430257882 ...

Python OpenCV convert image to byte string? -

i'm working pyopencv. how convert cv2 image (numpy) binary string writing mysql db without temporary file , imwrite ? i'm google nothing found... i'm trying imencode , doesn't works capture = cv2.videocapture(url.path) capture.set(cv2.cv.cv_cap_prop_pos_msec, float(url.query)) self.wfile.write(cv2.imencode('png', capture.read())) error: file "server.py", line 16, in do_get self.wfile.write(cv2.imencode('png', capture.read())) typeerror: img not numerical tuple help somebody! if have image img (which numpy array) can convert string using: >>> img_str = cv2.imencode('.jpg', img)[1].tostring() >>> type(img_str) 'str' no can store image inside database, , recover using: >>> nparr = np.fromstring(string_from_database, np.uint8) >>> img = cv2.imdecode(nparr, cv2.cv_load_image_color) where need replace string_from_database variable contains result of query da...

python - Regular expression match string and then next two lines -

i want match following string: window.universal = { yada yada ydada..... }; the following return first line. need next 2 well re.search(r'.*window.universal.*', content).group(0) i tired re.multiline, \s you need dotall. also 2 .* give dotall. try this: re.search(r'window.universal = {.*?};',content,re.dotall).group(0)

php - cakephp using components as controller methods -

i'm trying find best, cleanest way of initialising method within controller. want record 'likes', 'posts' etc 'actions' when happen. actions working fine on submission, not outside it's own controller. in likescontroller, want able go: $this->action->add($fields); but doesn't work, if $this->loadmodel('action'); beforehand. after reading around seems 'components' way go... so wondering how achieve using components. i've got far in likescontroller: public $components = array( 'requesthandler','helper', 'action' => array('controller'=>'actions', 'action'=>'add'), ); but still no joy when try call $this->action->add . what best method of doing this, , how can set component class work though action controller, , able use methods? if can award rep best answer will..! many in advance. a component isn't same mod...

Ignoring escape characters in perl -

my %result = "\\path\tfolder\file.txt"; how can ignore \t escape sequence without prepending '\'. there like: my %result = r"\\path\tfolder\file.txt"; the above doesn't work. single quotes process 2 escape sequences: \\ , \' , have double leading double-backslash not others: my $result = '\\\\server\toppath\files'; to want, use here-document @ cost of syntactic bulk. chomp(my $result = <<'eopath'); \\server\toppath\files eopath note change of sigil % $ because string scalar, , hashes associations.

.net - Visual Studio 2010 - how to force project reference to use exact path NOT GAC or Program Files? -

we're forever having problem, have number of solutions , adjacent /components/ folder. dlls want reference in folder. of them we've built source use specific version number existins in components binary when user on different machine gets-latest of tfs , has exact on disk structure visual studio still changes references ones installed in program files, gac or elsewhere. have tried manually editing proj file include hintpath, e.g. <reference include="foo, version=5.5.5.5, culture=neutral, processorarchitecture=msil"> <specificversion>false</specificversion> <hintpath>..\components\foo.dll</hintpath> </reference> to no avail. how force visual studio respect path? setting "specificversion" true, in addition specifying "hintpath" seemed solution because "prevents visual studio using multiple target rules assembly resolution". however, once foo.dll unavailable (while building or ...

asp.net - Grid Update Event not working -

error on :: rowindex not found gridviewrow row = (gridviewrow)gridview1.rows[e.rowindex]; below grid row update event.... protected void gridview1_rowupdating(object sender, eventargs e) { gridviewrow row = (gridviewrow)gridview1.rows[e.rowindex]; dropdownlist ct = (dropdownlist)row.findcontrol("case_type"); dropdownlist cs = (dropdownlist)row.findcontrol("case_status"); con.open(); sqlcommand cmd = new sqlcommand("update intakesheet set case_number = @case_number, case_name=@case_name, case_type=@case_type, case_status = @case_status, assigned_date = @assigned_date, assigned_to = @assigned_to, date_withdrawn= @date_withdrawn, date_delivered= @date_delivered, qc_by = @qc_by, qc_date=@qc_date, additional_notes = @additional_notes (case_number = @case_number)", con); cmd.executenonquery(); gridview1.editindex = -1; con.close(); bind(); } public void bind() { con.open(); sqldataadapter ...

ruby - Rails - how to save text data with Uploadify? -

i have page, can put text , text need add several images. uploading images want use uploadify. now solving problem, when choose images , send form, data not sent, uploadify start transfer files. text information not transferred. i doing way: %script{:type => "text/javascript"} - session_key = rails.application.config.session_options[:key] $(document).ready(function() { $('#file_upload').click(function(event){ event.preventdefault(); }); $('#file_upload'). ({ 'uploader' : '/uploadify/uploadify.swf', 'cancelimg' : '/assets/uploadify-cancel.png', 'multi' : true, 'auto' : false, 'queueid' : "file_queue", 'script' : '/users/#{params[:user_id]}/listings', 'onclearqueue' : true, onallcomplete : function(queuedata) { $('#upload_next').removeclass('disabled'); }, 'oncomplete'...

c - GTK pass user data to callback using Glade -

i notice glade allows set object passed within user data part of gtk callback. is there way can pass integer value instead? i have set of menu items point @ same callback function, small section of code need identify menu item 1 called callback. note: signals setup automatically glade_xml_signal_autoconnect, , perfer keep way. in opinion respect glade , callbacks 1 have goodbye notion of passing 1 single element callbacks. , stop using glade in order configure user data passed specific callback. i used pass struct named app callbacks contains pointer every ui element loaded ui definitions file , instantiated gtkbuilder . stops tedious task in glade of clicking , forth between widgets set user data of callbacks. in addition ui elements, of time struct contains further elements important @ runtime on application level. a benefit of approach not tempted think how implement individual callback should act upon more 1 element case. people tackle grouping widgets of ...

sublimetext2 - How do I use the > character in a Sublime Text 2 snippet's tabTrigger? -

i'm writing snippets require -> part of tabtrigger. however, seem ignored entirely. list of triggers disappears after hyphen character. i know $ can added escaping backslash, doesn't seem work in case. it seems can use &gt; , instead of >.

php - Google cloud messaging by fetching from database -

i'm working on getting news server android application. i'm thinking of getting push notification using google cloud messaging. i'm trying in application is check regularly in server if there new data added database. if yes make push notification. i'm not seeing tutorial thing. found android code. please me on this. i'm newbie concept. thanks. you have options this: 1.. contact server app periodically , check if there new notifications. if data , show user. -you can scheduling alarm, maybe once day, starts service server checking , notifying user. (this can ok solution if know new notifications appear @ fixed time intervals, used app has show weekly news each friday @ noon) 2.. google cloud messaging android google cloud messaging android (gcm) service allows send data server users' android-powered device, , receive messages devices on same connection. gcm service handles aspects of queueing of messages , delivery target android app...

ios - In-App Purchase Receipt Validation Contradiction -

apple offers 2 documents receipt validation, apparently contradictory statements. in " verifying store receipts ": note: on ios, contents , format of store receipt private , subject change. your application should not attempt parse receipt data directly . yet, in " in-app purchase receipt validation on ios " sample code provided in store receipt parsed , verified, part of "mitigation strategy" security vulnerability: // check validity of receipt. if checks out ensure transaction // haven't seen before , decode , save purchaseinfo receipt later receipt validation. - (bool)istransactionanditsreceiptvalid:(skpaymenttransaction *)transaction { if (!(transaction && transaction.transactionreceipt && [transaction.transactionreceipt length] > 0)) { // transaction not valid. return no; } // pull purchase-info out of transaction receipt, decode it, , save later // can cross checked veri...