Posts

Showing posts from January, 2010

Javascript function to save new fields from existing fields (migration) in mongodb collection -

Javascript function to save new fields from existing fields (migration) in mongodb collection - we have design alter in application accommodate few new requirements. design alter forced migrate 1 of mongodb collection, instead of having individual fields, have create derived json string field existing fields. the migration process invoked end-user doing action in ui (like saving change). 1 action might update few thousands of documents. write javascript code executed on server side, can avoid loading many records application. but issue running is, cannot phone call java script function using eval collection sharded. , other alternative cannot consider create collection un-sharded migration has happen on live system. please help if know of alternate approach. example migration : exampledoc (collection) has fields a1, a2, b1 , b2. migration create new fields called fieldjson : { : "", b : ""}. here , b derived existing fields a1, a2, b1 , b2. ...

Fields in java, "not a primitive field" error -

Fields in java, "not a primitive field" error - i have been working fields parsing class sharedpreferences. worked while settings class not singleton. changed work singleton , not working anymore. g2asettings settings = g2asettings.getinstance(); field[] fields = g2asettings.class.getdeclaredfields(); (field f : fields) { f.setaccessible(true); seek { if (preferences.contains(f.getname()) && !f.getname().equals("instance")) { f.set(settings, preferences.getboolean(f.getname(), f.getboolean(settings))); //si no lo encuentra, pone el valor por defecto determinado en la clase } else { if (blablabla) { editor.putboolean(f.getname(), true); allpreferencesdisabled = true; } else (*)-----> editor.putboolean(f.getname(), f.getboolean(settings)); } (*)-----> if (!allpreferencesdisabled) allpr...

java - key pressed how show message file read only in jpanel when text area is non editable? -

java - key pressed how show message file read only in jpanel when text area is non editable? - when open file in jtextarea. set textarea non editable using textarea.seteditable(false) in when press key how show message in jpanel file read only. thank you. you can add together keylistener text area, , in keypressed() method want, e.g. show dialog. jtextarea ta = new jtextarea(); ta.addkeylistener(new keyadapter() { @override public void keypressed(keyevent e) { system.out.println("key pressed, warn user read only!"); } }); java swing jpanel jtextarea

javascript - Replace Vote Count with a Percentage System for Jquery upVote -

javascript - Replace Vote Count with a Percentage System for Jquery upVote - i want replace vote counts of 0 default, 1 upvote, , -1 downwards vote not rated default, 100% upvote, , 0% downwards vote. note: need accomplish without going server side, frontside solution involving jquery, javascript, html, , css only. here's fiddle: http://jsfiddle.net/3ec67gne/3/ html: <div class="examples" id="examples"></div> <div id="templates" class="hidden"> <div class="upvote"> <a class="upvote" title="this stuff. vote up! (click 1 time again undo)"></a> <span class="count" title="total number of votes"></span> <a class="downvote" title="this not useful. vote down. (click 1 time again undo)"></a> <div class="examples" id="examples"...

audio - in php error in uploading file to the server -

audio - in php error in uploading file to the server - i using script upload file server. <?php $name = $_files["file"]['name']; echo $tmp_name = $_files['file']['tmp_name']; if (isset($name)) { if (!empty($name)) { $location = 'uploads/'; if (move_uploaded_file($tmp_name, $location.$name)) { echo 'uploadded'; } else { echo "there error"; } } else { echo 'please take file.'; } } ?> <form action="#" method="post" enctype="multipart/form-data"> <input type="file" name="file"><br><br> <input type="submit" value="submit"> </form> this script working @ local host (my own pc). when upload code online code giving next error. 500-internal server error. there problem resource looking for, , can not displayed. secondly w...

spring mvc - Getting ModelAttribute value in POST request handler -

spring mvc - Getting ModelAttribute value in POST request handler - i have form bean follows public class questionpagebean { private string statement; private string options; // getters , setters } below request handler creates object 'question' , sets field 'statement'. populates list of values shown check-box 'options' field. page displays 'statement' , list of check-boxes. @requestmapping(value = "/question", method = requestmethod.get) public modelandview initform() { logger.debug("received request show question page"); list<string> optionlist = new arraylist<string>(); modelandview model=new modelandview("question"); questionpagebean question=new questionpagebean(); question.setstatement("this question"); optionlist.add("option1"); optionlist.add("option2"); optionlist.add(...

objective c - AVAudioEngine (iOS 8 Obj-C): How to construct the graph for Recording & Playback? -

objective c - AVAudioEngine (iOS 8 Obj-C): How to construct the graph for Recording & Playback? - i need create render graph basic recording file , playback file, using avaudiofile & avaudioinputnode. below main setup methods started, graph connected player. how build graph [input], [player] [mixers] connected accomplish rec/play? #pragma mark - setup -(void)setupaudioengine{ //create _audioengine = [[avaudioengine alloc]init]; _player = [[avaudioplayernode alloc] init]; _inputmixer = [[avaudiomixernode alloc]init]; _playermixer = [[avaudiomixernode alloc]init]; //attach player engine [_audioengine attachnode:_player]; [_audioengine attachnode:_inputmixer]; [_audioengine attachnode:_playermixer]; _input = [_audioengine inputnode]; _mainmixer = [_audioengine mainmixernode]; //setup sound file nserror *error = nil; //connect render grapth [_audioengine connect:_input to:_mainmixer format:[_input inputformatforbus:0]]; [_audioengine connect:_player to:_mainmix...

ios - UIButton color in UIScrollView is set to wrong color when scrolling -

ios - UIButton color in UIScrollView is set to wrong color when scrolling - i have uitableview 20 rows , in every row have 1 uiimageview, 4 uitextview , 3 uibutton. my tablview loads perfectly, when scroll, of uibutton shows wrong color. illustration 1 of rows should have yellowish uicolor, when scroll unbutton in row became yellow! here code : func tableview(tableview: uitableview!, cellforrowatindexpath indexpath: nsindexpath!) -> uitableviewcell! { var cell:timelinetableviewcell? = tableview.dequeuereusablecellwithidentifier("timelinetableviewcell") as? timelinetableviewcell if (cell == nil){ cell = nsbundle.mainbundle().loadnibnamed("timelinetableviewcell", owner: self, options: nil)[0] as? timelinetableviewcell } cell!.namelabel.text = self.usernamea[indexpath.row] cell!.screennamelabel.text = "@" + self.screennamea[indexpath.row] cell!.tweetlabel.text = self.tweeta[indexpath.row] cell?.avatar...

uploading files to Dropbox, bypassing authorization page? -

uploading files to Dropbox, bypassing authorization page? - i have form upload file fields, , want store files in dropbox folder. however, api asks register before uploading files. does knows how without having go through authorization page ?? i click upload, , straight upload file repository. dropbox

java - confused with the design of servlet -

java - confused with the design of servlet - i want create servlet receive info in json format , store info in database. when send info servlet through http request, found connection table, create table, , store data. code create connection , table has done first time. not able come design of code create connection , table first time , store info rows rest of time my code follows :- public class master extends protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { handle(request, response); } private void handle(httpservletrequest req, httpservletresponse resp) { jsonobject jsonobject = null; if ( req.getmethod().equalsignorecase("post")) { seek { string jsonstring = extractjsonbody() /* code connection database create table store info */ } grab (exception e) { system.out.println("json in bad for...

recursion - How to utilize recursive functions to help rank matrix rows - R -

recursion - How to utilize recursive functions to help rank matrix rows - R - i advice how best solve puzzle. have got of way solving using manually written long-hand code. sense if need utilize recursive functions, still not @ using them. hope question not long, i'm trying succinct possible whilst giving plenty information. sorry if it's long - though finds of interest. i have matrix mat1 # b c d e f g # 0 2 1 1 0 1 1 # b 0 0 0 1 2 2 1 # c 1 2 0 0 0 2 1 # d 1 1 2 0 1 2 1 # e 2 0 2 1 0 2 1 # f 1 0 0 0 0 0 1 # g 1 1 1 1 1 1 0 this represents results of contests between individuals in rows , columns. numbers refer how individual in row 'won' against individual in column. i wish rank individuals a-g 1-7 using next criteria: number of wins against others (most wins should ranked 1, to the lowest degree wins 7, 2nd wins 2, etc.) if number of wins tied, ranks should based on number of wins obtained when considering contests between individuals...

xcode - OSX Cocoa NSButton type checkbox " Select all " issue, and how to solve it? -

xcode - OSX Cocoa NSButton type checkbox " Select all " issue, and how to solve it? - i have multiple checkboxes in table view. , out of table, have 1 checkbox action select looks this: - (ibaction)selectall:(nsbutton *)sender { (int = 0; < [maintable numberofrows]; i++) { nstablecellview *cellview = [maintable makeviewwithidentifier:@"maincell" owner:self]; for(nsbutton *button in cellview.subviews){ //i have multiple buttons, need 1 tooltip if([[button tooltip] isequaltostring:@"select"]){ [button setstate:sender.state]; } } } } that code works great view not updated. tried [maintable reloaddata] guess not that. simple question how update view? i tried: 1) creating new nsbutton , replacing old 1 no luck there. view not updated. 2) trying create nsbuttons dynamically instead of using designer , applying code, no luck there. unusual...

ruby on rails 4 - has_many :through association and form_for -

ruby on rails 4 - has_many :through association and form_for - i trying first time build form including has_many through association these 3 models: class book < activerecord::base has_many :talks has_many :authors, through: :talks accepts_nested_attributes_for :talks accepts_nested_attributes_for :authors validates :title, presence: true end class author < activerecord::base has_many :talks has_many :books, through: :talks validates :l_name ,presence: true end class talk < activerecord::base belongs_to :book belongs_to :author accepts_nested_attributes_for :author end my book/new.html.erb <h1>add new book</h1> <%= form_for (@book) |f| %> <div> <%= f.label :title %><br> <%= f.text_field :title %> </div> <div> <%= f.fields_for :talks, talk.new |t| %> <div> <%t.fields_for :author, author.new |a| %> <%= a.label :f_name %> <%=...

css - Sass referencing parent selectors using the ampersand character within nested selectors -

css - Sass referencing parent selectors using the ampersand character within nested selectors - just when thought sass coolest thing since sliced bread, had go , allow me down. i'm trying utilize ampersand select parent of nested item. it's complex selection , returning unexpected results... my sass: .page--about-us { { text-decoration:none; } .fa-stack { .fa { color:pink; } & { &:hover { .fa-circle-thin { color:red; } .fa-twitter { color:blue; } } } } } outputted css: .page--about-us { text-decoration: none; } .page--about-us .fa-stack .fa { color: pink; } .page--about-us .fa-stack:hover .fa-circle-thin { color: red; } .page--about-us .fa-stack:hover .fa-twitter { color: blue; } expected output (note placement of tag): .page--about-us { text-decoration: none; } .page--about-us .fa-stack .fa { color: pink; } .page--about-us .fa-stack:ho...

order a dataframe according to a given list in R -

order a dataframe according to a given list in R - this question has reply here: order info frame rows according target vector specifies desired order 2 answers i have function calculate count of column in r want arrange dataframe entries according given list passed function input appeared in form: complete( c(2, 55, 8, 111, 12)) complete(30:25) i have info frame in ascending order id, want arranged according list given id nobs 2 463 8 586 12 338 55 711 111 932 should sorted / rearranged as: id nobs 2 463 55 711 8 586 111 932 12 338 here's possible approach using merge : # data.frame sort df <- read.csv(text= 'id,nobs 2,463 8,586 12,338 55,711 111,932') # keys utilize sorting keys <- c(2, 55, 8, 111, 12) keydf <- data.frame(key=keys,weight=1:length(keys)) merged <- merge(df,keydf,by....

image - Batch process .png to .webp -

image - Batch process .png to .webp - i have around 100 .png images, , of them have converted .webp (google's image format). using google's cli tool. thought how batch process them. you can help of simple bash script. navigate directory images reside , execute this: $ file in * > > cwebp -q 80 "$file" -o "$file.webp" > done you can alter output file name, want. should end .webp extension. image bash png webp

arrays - Difference between subarray, subset & subsequence -

arrays - Difference between subarray, subset & subsequence - i'm bit confused between subarray , subsequence & subset if have {1,2,3,4} then subsequence can 1,2,4 or {2,4} etc. can omit elements maintain order. subarray be( subarray of size 3) {1,2,3} {2,3,4} subset? i'm bit confused between these 3. in opinion, if given pattern array, called subarray means contiguous subarray . for example, if given {1, 2, 3, 4}, subarray can be {1, 2, 3} {2, 3, 4} etc. while given pattern sequence, subsequence contain elements subscripts increasing in original sequence. for example, {1, 2, 3, 4}, subsequence can be {1, 3} {1,4} etc. while given pattern set, subset contain possible combinations of original set. for example, {1, 2, 3, 4}, subset can be {1} {2} {3} {4} {1, 2} {1, 3} {1, 4} {2, 3} etc. subset arrays subsequence

matlab - Find the count of elements in one matrix equal to another -

matlab - Find the count of elements in one matrix equal to another - i need compare elements of 2 matrices , homecoming count of how many rows same. ismember function returns 1 column each column nowadays in matrix. want 1 column indicating whether row same or not. ideas appreciated. if want compare corresponding rows of 2 matrices, use result = all(a==b, 2); example: >> = [1 2; 3 4; 5 6] = 1 2 3 4 5 6 >> b = [1 2; 3 0; 5 6] b = 1 2 3 0 5 6 >> result = all(a==b, 2) result = 1 0 1 if want compare all pairs of rows: result = pdist2(a,b)==0; example: >> = [1 2; 3 4; 1 2] = 1 2 3 4 1 2 >> b = [1 2; 3 0] b = 1 2 3 0 >> result = pdist2(a,b)==0 result = 1 0 0 0 1 0 matlab matrix

pdf - How to make PdfLayer.SetPrint work with PdfStamper? -

pdf - How to make PdfLayer.SetPrint work with PdfStamper? - i'm adding watermarks on existing pdf using itext pdfstamper class. , want these watermarks switched on or off, i'm using class pdflayer . want these watermarks visible when file printed : i'm using function pdflayer.setprint() then. this lastly step unfortunately doesn't work expected. here's code : pdfreader reader = new pdfreader("c:/temp/input.pdf"); pdfstamper stamp = new pdfstamper(reader, new fileoutputstream("c:/temp/output.pdf")); pdfwriter author = stamp.getwriter(); pdflayer layer = new pdflayer("watermarks", writer); layer.seton(true); layer.setprint("watermarks", true); basefont bf = basefont.createfont(); pdfcontentbyte cb = stamp.getovercontent(1); cb.begintext(); cb.setfontandsize(bf, 18); cb.beginlayer(layer); cb.showtextaligned(element.align_left, "watermark line 1", 50, 55, 0); cb.showtextaligned(element.align_left, "wat...

java - Lucene changing from RAMDirectory to FSDIrectory - Content-Field missing -

java - Lucene changing from RAMDirectory to FSDIrectory - Content-Field missing - i'm lucene starter , and got stuck on problem during alter ramdirectory fsdirectory: first code: private static indexwriterconfig iwc = new indexwriterconfig(version.lucene_43, new standardanalyzer(version.lucene_43)); directory dir = fsdirectory.open(new file(indexloc)); //indexloc = "path/to/dir/" // ramdirectory dir = new ramdirectory(); // index made content indexwriter author = new indexwriter(dir, iwc); // store both position , offset info fieldtype type = new fieldtype(); type.setstored(true); type.setstoretermvectors(true); type.setstoretermvectoroffsets(true); type.setstoretermvectorpositions(true); type.setindexed(true); type.settokenized(true); idocumentparser p = documentparserfactory.getparser(f); arraylist<parserdocument> docs = p.getparseddocuments(); (int = 0;...

java - How to set json values came from jsp to html using javascript -

java - How to set json values came from jsp to html using javascript - here code : <% response.setcontenttype("application/json"); jsonobject json = new jsonobject(); employee employee = new employee("ram","ram@gmail.com"); json.put("employee",employee); out.println(json); %> i need set json values came jsp html file. parsing js. there thought i'm stucked on here... if provide code response helpful me.. java javascript json jsp

java - jsonschema2pojo Regenerating JavaType Issue -

java - jsonschema2pojo Regenerating JavaType Issue - i working jsonschema2pojo , dealing more complex java types within. have come across issue when comes regenerating generated class. example, definitions has followed defined: class="lang-java prettyprint-override"> "definitions" : { "test" : { "javatype" : "com.generated.model.test", "properties" : { "name" : { "type" : "string" } }, "type" : "object" } } and referenced in schema follows: class="lang-java prettyprint-override"> "anothername" : { "$ref" : "#/definitions/test", "type" : "object" } this works great, first time around, , generates object schema , complex type. part of set-up, have custom launcher/generator deletes java packages before generates usi...

Lisp (null (QUOTE NIL)) returns NIL -

Lisp (null (QUOTE NIL)) returns NIL - i new lisp , i'm trying simple check see if list empty. test purposes created test function: (defun test (list) (if (null (caddr list)) (make-node 1) (caddr list))) if uses make-node function defined as: (defun make-node (atm) (cons atm `(`() `()))) when running (make-node 6) get: (6 (quote nil) (quote nil)) which want. i phone call (test (make-node 6)) get: (quote nil) which (caddr list) test. if run (null (quote nil)) t want when run given test function receive nil . so question why when check if null why nil instead of t ? when evaluate (null (quote nil)) , (quote nil) evaluated, resulting in nil beingness used argument function null . however when evaluate (null (function-returning-quote-nil)) , function-returning-quote-nil evaluated, resulting in list (quote nil) used argument function null without farther evaluation. compare difference between (null (quote nil))...

php - Wordpress custom post not showing featured -

php - Wordpress custom post not showing featured - i have come across unusual problem when creating new wordpress theme. maybe because have been @ day need see if can spot error or see problem. i trying display 'featured' posts per name of category , show 1 if has been checked in wp-admin section. yet defining within code shows latest post instead regardless of beingness featured or not. <?php $args = array( 'post_type' => 'post', 'category_mame' => 'featured', 'posts_per_page' => 1 ); $the_query = new wp_query( $args ); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="push_2 grid_10 omega clearfix"> <article> <?php get_template_part( 'content', 'p...

c# - The given path's format is not supported in Isolated storage -

c# - The given path's format is not supported in Isolated storage - i want calculate file size before uploading in server, before maintain file in isolated storage creating folder. want path calculating file size, giving error "the given path's format not supported" my code is: class="lang-c# prettyprint-override"> string filepath = path.combine(foldername, filename); string fp = @"ms-appdata:///local//" + imagefolder + "//" + fname; // here tried "/" , seek append "filepath " straight still throwing same error fileinfo info = new fileinfo(fp); ////here throwing error "the given path's format not supported" var filelength = new system.io.fileinfo(fp).length; int image_file_size = convert.toint32(filelength); what right format path? think kind of path when you're sourcing code in xaml. if want system.io then need build path this string dbpath = path.combine(windows.s...

sharding counters in google app engine -

sharding counters in google app engine - hi guys new google app engine, can u guys explain below code, why counter param used , declare parameters. have no source , helpless. eager larn concept, help me guys... import pmf; import java.util.list; import java.util.random; import javax.jdo.persistencemanager; import javax.jdo.query; public class shardedcounter { private string countername; public shardedcounter(string countername) { this.countername = countername; } public string getcountername() { homecoming countername; } public int getcount() { int sum = 0; persistencemanager pm = pmf.get().getpersistencemanager(); seek { query shardsquery = pm.newquery(generalcountershard.class, "countername == nameparam"); shardsquery.declareparameters("string nameparam"); list<generalcountershard> shards = (list<generalcountershard>) shardsquery.execute(countername); if (shar...

namespaces - PHP class_exists - getting Fatal error: Cannot redeclare clas instead? -

namespaces - PHP class_exists - getting Fatal error: Cannot redeclare clas instead? - i want homecoming an error message when two classes provided user/ developer don't exist. core/model/conan.php, namespace core\model; class conan { var $bodybuild = 'extremely muscular'; var $birthdate = 'before history'; var $skill = 'fighting'; public function methodconan() { homecoming 'the methodconan namespace core\model'; } } local/model/conan.php, namespace local\model; class conan { var $bodybuild = 'very skinny'; var $birthdate = '1963'; var $skill = 'comedy'; public function methodconan() { homecoming 'the methodconan namespace local\model'; } } index.php, define ('website_docroot', str_replace('\\', '/', dirname(__file__)).'/'); include 'core/helper/baseclassautoloader.php'; // autoload c...

c - GDB conditional break on function parameter -

c - GDB conditional break on function parameter - i'm wanting set breakpoint on function parameter if greater value. dummy code below: int main(void) { uint64_t num = 123456; uint64_t x = 847534; uint64_t other = (num*x) - (x/num); .... other stuff here (multithreaded stuff) calc(other); } void calc(uint64_t size) { ...do stuff size } i've tried set breakpoint by: (gdb) b calc if size == 852479 but not know size since parameter i'm guessing. how break if parameter equals number. not alternative break on calls function because gets called billion times in multithreaded environment. assuming x86-64 calling conventions on gnu/linux platform examine %rdi (64-bit) register straight check function's first parameter: b calc if $rdi == 852479 this allows break on function calc if don't have debugging symbols loaded (thus no code listing, i.e. list calc ). note method fail if function inlined optimizing compil...

php - Perform advanced where clause Eloquent -

php - Perform advanced where clause Eloquent - i know how perform 'advanced where'. didn't find in documentation explain want.. there. (cf: http://laravel.com/docs/4.2/queries#advanced-wheres). post::wherehas('international_post_en', function($q) { $q->where('is_published', 1); })->wherehas('categories', function($q) { $q->where('name', 'test-one'); })->orwherehas('subcategories', function($q) { $q->where('name', 'test-two'); })->with('categories', 'subtags') ->get(); my query this: select * `posts` `posts`.`deleted_at` null , (select count(*) `international_posts_en` `international_posts_en`.`posts_id` = `posts`.`id` , `is_published` = ?) >= 1 , (select count(*) `categories` inner bring together `posts_has_categories` on `categories`.`id` = `posts_has_categories`.`categories_id` `posts_has_categories`.`posts_id` = `posts`.`id...

ios - What is pancake.apple.com? -

ios - What is pancake.apple.com? - i noticed app running in simulator printed line in console: rtcreporting: resolve http://pancake.apple.com/bags/hls?version=4.12 now, there question attempts reply why exception occuring, frankly rather pancake.apple.com , why returning plist? plist used for, , moreover, pancake.apple.com, there other instances endpoint gets called? and here contents in base of operations 64 decoded glory: this "bag" <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple computer//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>apple_internal</key> <dict> <key>dashboard</key> <dict> <key>display_url</key> <string>https://hls.apple.com/dashboard/</string> <key>ip</key...