Posts

Showing posts from June, 2014

Javascript array search -

Javascript array search - whats best way search javascript array entry?? items strings. is using lastindexof? so: var list= []; list.push("one"); list.push("two"); list.push("three"); if(list.lastindexof(somestring) != -1) { alert("this nowadays in list"); return; } is using lastindexof? yes. however, i'd utilize simpler indexof() if don't need explicitly search backwards (which don't if test "does not contain"). notice these methods standardized in es5 , need shimmed in old browsers not back upwards them natively. javascript

asp.net mvc 3 - MVC, Nhibernate, castle, windsor Integrated testing not writing to database -

asp.net mvc 3 - MVC, Nhibernate, castle, windsor Integrated testing not writing to database - we attempting write integrated tests web app uses mvc, nhibernate, castle, windsor , sharparch. when step thru tests, nail methods correctly, not write info database. using repository model, , nhibernate save. code working when run website. not using di in integrated tests, project in web app solution. there no errors thrown. nhibernate initialized in integration tests in global as nhibernatesession.init(websessionstorage, new string[] { binpath }, null, appconfigpath, configuration, null, null); where binpath path dll containing nhibernate maps , classes , appconfigpath path bin of website. nhibernatesession appears populated. any ideas, suggestions welcomed. thnx verify haven't forgotten transaction handling (and committing them (thus...

How insert mp3 file into oracle database -

How insert mp3 file into oracle database - i'm useing java write programe, need insert file database such ".mp3, .wav" files. by way how insert these file oracle database? have considered storing mp3 metadata , file location. worked on image server years ago , attempted storing images within database. much faster hand off file location server service requesting it, fetch file. possible load mp3 binary file database blob if want to. oracle

c# - How can I parse recursive data structures with JSON.NET? -

c# - How can I parse recursive data structures with JSON.NET? - i have menuitem , screen entries defined in root element menustruct json string. the of import thing here menuitem can contain other menuitem s or screen s. i want parse whole json string json.net should receive tree menuitem s can contain huge chain of nested menuitem s or screen entries. i snipped lot of nested structures next json string: { "menustruct": { "-text": "gui.menu.root", "-image": "gui.menu.home", "-mask": "gui.menu.home.mask", "-color": "#e0e0ff", "-menuid": "menutree", "menuitem": [ { "-text": "gui.menu.text.00000003", "-image": "gui.menu.menu", "-mask": "gui.menu.menu.mask", "-color": "#c0c0ff", "-menuid": "menu.id.00000003", "screen"...

mysql - Facebook app that posts to all its users in a specific time (php) -

mysql - Facebook app that posts to all its users in a specific time (php) - it's first question on stackoverflow. made application , works fine posting photo user's wall 1 time visit app page, but want post many photos in scheduled way (at specific time 12 feb 2013 10:00 pm) wall , users wall i made mysql database contains table users' id, , table posts' info , time. what can next? include ("../facebook/facebook.php") ; $facebook = new facebook(array( 'appid' => app_id , 'secret' => app_secret , 'fileupload' => true, )); $user = $facebook->getuser(); if ($user) { seek { $user_profile = $facebook->api('/me'); } grab (facebookapiexception $e) { error_log($e); $user = null; } } if ($user) { $facebook->setfileuploadsupport(true); $photo ="images/image1.jpg" ; $message= "my message "; $ret_obj = $facebook->ap...

c# - Using regex on a on-screen keyboard -

c# - Using regex on a on-screen keyboard - ok i'm getting stuck here guys :/. i've got (custom!) onscreen keyboard wanna utilize regular expressions. i created regex allow 0-9 , comma regular keyboard. of course of study isn't working on-screen keyboard. i have code snippet works... but have space button, backspace button, , 2 buttons move caret around. when utilize below regex code , click space, backspace or caret buttons error: object reference not set instance of object. what doing wrong? // regex code private command keyb = null; private void editprodpriceex_gotfocus(object sender, routedeventargs e) { string allowedchars = "[^0-9,]"; if (regex.ismatch(editprodpriceex.text, allowedchars)) { keyb = (control)sender; } } space button: private void knopspatie_click(object sender, routedeventargs e) { textbox tb = keyb textbox; int selstar...

android - How to remove all the polylines from a map -

android - How to remove all the polylines from a map - following how draw path between 2 markers i had add together lot of polylines between 2 markers, create path. one of markers draggable, lets source draggable. so, when user starts dragging marker, path drawn must erased , new path between new source , destination must draw. i able draw new path, how can erase previous path? this how path drawn: (int z = 0; z < list.size() - 1; z++) { latlng src = list.get(z); latlng dest = list.get(z + 1); polyline line = map.addpolyline(new polylineoptions() .add(new latlng(src.latitude, src.longitude), new latlng(dest.latitude, dest.longitude)) .width(2).color(color.red).geodesic(true)); } one solution can is map.clear(); to clear polylines, markers etc.. , add together markers again, drawn path. but start dragging, marker cleared, hence not visible on map :( thank you ...

javascript - Trigger infinitescroll manually -

javascript - Trigger infinitescroll manually - i using next code trigger infinitescroll on isotope masonry, how utilize "click load more posts" instead, "the manual trigger". tried implementing solutions on net not work me. thanks. /*--------------------------------------------------------------------------------*/ /* infinitescroll /*--------------------------------------------------------------------------------*/ jquery(document).ready(function($) { var $container = $('.masonry'); $container.imagesloaded( function(){ $container.isotope({ itemselector : '.item' }); }); $container.infinitescroll({ // selector paged navigation navselector : '.post-nav', // selector next link (to page 2) nextselector : '.post-nav .prev-post a', // selector items you'll retrieve itemselector : '.item', loading: { finishedms...

java - Getting a specific word from files in a larger directory(workspace) -

java - Getting a specific word from files in a larger directory(workspace) - i need document in word table names used application , in classses used. it big application. did file seaarch in workspace using extend class name (testtransformation) , got 142 java files referencing table names. i need fetch table names , respective classes this. so, thought of writing java code first list of java files extending testtransformation , trying tables names in , respective class name in list, not manully re-create paste it. is possible that? eg: of 1 class search: need fetch class name addcustomer , table name h005table public class addcustomer extends testtranformation { ...//codes..... .... setin.setparms( "h005table", // tablename m.getnumber()) } using bufferedreader read lines till "public class" line , when pointer @ "public class...

c# - Slot Allocation Algorithm -

c# - Slot Allocation Algorithm - is there generic algorithm can employ solve next problem: given: background: month, has 0 1000 events (any number really). each event has start , end dates. events take place in rooms, 1 @ time (no overlaps, consequent events allowed share end , start dates each other). number of rooms unlimited. the challenge: allocate rooms events such number of rooms required host monthly events kept minimum. while finish solution highly appreciated i'm looking directions, smart ideas. class event: - int id; - datetime startdate; - datetime enddate class allocation: - int eventid - int roomid so i'm looking for: // roomids enumerable.range(1, int.maxvalue) ienumerable<allocation> getallocations(ienumerable<event> events, ienumerable<int> roomids, int year, int month) { ... } split every event 2 timepoints labeled 'start' , 'end' (keeping pointer original event), sort points on time - bre...

windows phone 7 - Assign geo coordinates to a pushpin -

windows phone 7 - Assign geo coordinates to a pushpin - guys need help, have map xmlns:maps="clr-namespace:microsoft.phone.maps.controls;assembly=microsoft.phone.maps" xmlns:maptk="clr-namespace:microsoft.phone.maps.toolkitassembly=microsoft.phone.controls.toolkit" <maps:map grid.row="0" tap="onm_mapcontroltap" name="m_mapcontrol <maptk:mapextensions.children> <maptk:pushpin x:name="m_pushpin" tap="onpushpintap"> <maptk:pushpin.content> <stackpanel> <textblock text=""/> <image source=""/> </stackpanel> </maptk:pushpin.content> </maptk:pushpin> </maptk:mapextensions.children> </maps:map> when have coordin...

java - Register component callbacks appropriate for current SDK version -

java - Register component callbacks appropriate for current SDK version - i want receive notifications ontrimmemory when available (ics+) , onlowmemory otherwise (> ics). questions following: will scheme allow me define class implements interface not in current sdk long don't instantiate it? example, defining callbacksics implements componentcallbacks2 while targeting minsdk 8, example, checking current sdk_int before choosing instantiate , register. will onterminate called when application ready cleaned system? vaguely remember hearing in days of application life cycle methods aren't guaranteed called. from application class: @suppresslint("newapi") @override public void oncreate() { super.oncreate(); if (build.version.sdk_int >= build.version_codes.ice_cream_sandwich) { callbacksics = new callbacksics(); registercomponentcallbacks(callbacksics); } else { callbackslegacy = new callbackslegacy(); ...

javascript change function parameter variable name and return its value -

javascript change function parameter variable name and return its value - hi have function , want homecoming function parameter added value parameter. instead of writing this: function(response) { homecoming response.links_1; } function(response) { homecoming response.links_2; } function(response) { homecoming response.links_3; } i want create loop iterates through , adds number, this: function(response) { var counter = 3; for(var = 0; < counter; i++) { homecoming response.links_ +i; } } the of import part response.link_ must not string! looses function parameter value. i tried doing this: function(response) { var = 1, resp = 'response.links_', endresp = resp + i; homecoming endresp ; } } and console.log(endresp); returns right string, thats it, string.. want value of variable response.links_1 not string value response.links_1. i have tried next without luck: (the parse: backbone m...

c# - How to manage animations? -

c# - How to manage animations? - i'm using c# , i'm building 3rd person view game. have 3d character model animations in frames have cutting animations frame the problem have 5 animations (idle, run, walk, punch, jump) , code void update () { if (input.getaxis("horizontal") != 0 || input.getaxis("vertical") != 0){ //play run animation } else { if (motion.x != 0 || motion.z != 0){ motion.x = 0; motion.z = 0; } //play idle anim } if (input.getkeydown(keycode.space) && controller.isgrounded){ //play jump anim } if (input.getkeydown(keycode.p)){ //play punch anim } if (!controller.isgrounded){ //play jump anim } vertvelo -= gravity * time.deltatime; motion.y = vertvelo; this.controller.move(motion * time.deltatime); } the problem occurs when press p create character punch. seems idle animation in updat...

sql - MySQL selecting MAX unique values -

sql - MySQL selecting MAX unique values - i have mysql table shows sellers table looks following: advertiseid[pk] | customerid[fk] | productsid[fk] | quantites_advertised | price_advertised ------------------------------------------------------------------------------------------ 1 2 2 4.00 2.00 2 4 3 5.00 2.50 3 3 2 1.00 1.00 the first record means ..this means client id 2 selling choclates(product id 1), 4kg's@ £2.00 i wanted select each product id query displays minimum of different products: hence, table be: advertiseid[pk] | customerid[fk] | productsid[fk] | quantites_advertised | price_advertised ------------------------------------------------------------------------------------------ 2 4 3 5.00 ...

ios - Core Data unrecognized selector error -

ios - Core Data unrecognized selector error - i using core info save strings. have next class called results results.h #import <coredata/coredata.h> @interface results : nsmanagedobject @property(nonatomic, retain) nsstring *lessondate; @property(nonatomic, retain) nsstring *lesson; @property(nonatomic, retain) nsstring *location; @property(nonatomic, retain) nsstring *start; @property(nonatomic, retain) nsstring *end; @end results.m #import "results.h" @implementation results @dynamic lessondate; @dynamic lesson; @dynamic location; @dynamic start; @dynamic end; @end the next code perform save: -(void)savelesson{ results *result = (results *)[nsentitydescription insertnewobjectforentityforname:@"diary" inmanagedobjectcontext:managedobjectcontext]; result.lessondate = calendardatestring; result.lesson = [nsstring stringwithformat:@"%@", lessontext.text]; result.location = [nsstring stringwithformat:@"%@", lo...

c# - Validating School Year -

c# - Validating School Year - im asking schoolyear . just example 2013-2014 (startyear-endyear) how validate if user come in school year (ex. 2013-2014 ) this have tried far. private void textbox_validating(object sender, canceleventargs e) { if (!string.isnullorwhitespace(studentlastschoolattendedschoolyeartextbox.text)) { int fromyear = 0; int toyear = 0; string[] years = regex.split(studentlastschoolattendedschoolyeartextbox.text, @"-"); fromyear = int.parse(years.firstordefault().tostring()); if (fromyear.tostring().length == 4) { if (years.count() > 1) { if (!string.isnullorwhitespace(years.lastordefault())) { toyear = int.parse(years.lastordefault().tostring()); if (fromyear ...

objective c - How can I decide if switch view value was changed by user interaction or by code in IOS? -

objective c - How can I decide if switch view value was changed by user interaction or by code in IOS? - i have switch view on ui , i'd handle event when value changed. perform i've made ibaction method handle value changed event. far good. my problem can't decide if alter performed - code (it may happen in app) - user interaction how can decide if changed user interaction or code? is there specific method changes switch value when it's done code only? if so, maybe utilize method set boolean/flag check against when need decide/handle event. ios objective-c switch-statement ibaction

google app engine - GAE Memcached API -

google app engine - GAE Memcached API - i followed https://developers.google.com/appengine/docs/python/memcache/usingmemcache, , got memcached work. but have problem when seek update cache before expires. example, after: "memcache.add('key', data, 60000000000)" if want update info stores in "key" i hoping there api of "memcache.update('key', newdata, 60000000000)" (no) i tried add together again: "memcache.add('key', newdata, 60000000000)" but doesn't work. didn't replace previous one. anyone can give me ideas how it? i know there "memcahed.flush_all()" but flush whole cache. use memcache.set('key', data, 60000000000) set value, regardless of previous contents in cache. see: https://developers.google.com/appengine/docs/python/memcache/functions google-app-engine memcached

html - inline-block object not resizing properly with dynamically sized image -

html - inline-block object not resizing properly with dynamically sized image - i trying center set of floated blocks contain images scale dynamically. having issue inline-block using come in floated blocks not shrinking new size of image. instead wrap original size of image, leaving big empty space. http://jsbin.com/ewonas/1/ body { text-align: center; } .inlineblock { background: red; display: inline-block; } .constrainer { width: 20%; float: left; } .constrainer img { width: 100%; } <body> <div class="inlineblock"> <div class="constrainer"> <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/smiley.svg/500px-smiley.svg.png"> <h1>product title</h1> </div> <div class="constrainer"> <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/smiley.svg/500px-smiley.svg...

middleman 3.0.11 do not know template=html5-haml -

middleman 3.0.11 do not know template=html5-haml - i'm next getting started on main website. , copy-paste: middleman init my_new_mobile_project --template=html5-haml unknown project template 'html5-haml' middleman init my_new_mobile_project --template=html5 works... middleman 3.0.11. i've gone through too, seems instructions html5-haml template legacy, previous middleman version. current middleman doesn't come it, , under development middleman-html5bp-haml template cloned ~/.middleman/html5bphaml/ , used through middleman init my_new_project --template=html5bphaml has caused me problems, installs entire gemset , dependent of older gems ones working provided templates. the author says it's bundled middleman soon, expect behavior of template similar of other ones when happen. middleman

html - Twitter bootstrap grid adding up to > 100%? -

html - Twitter bootstrap grid adding up to > 100%? - i using twitter bootstrap grid. i trying use: <div id="footer-groups" class="row-fluid collapse in"> <div class="span3"> users </div> <div class="span3"> clients </div> <div class="span3"> projects </div> <div class="span3"> tasks </div> </div> but reason width + margin-left adding 101.309328969% i using less version of bootstrap 2.2.2 (as 2.3 not compile through lessphp!). the unusual thing is, happens if have 1 file (custom.less) that contains: @import "bootstrap.less" @import "responsive.less" if include these 2 separately works fine. i using font awesome. i have bootswatch theme in use, not modify grid far aware, uses these 2 files variables.less (diff) diff variables.less variables.default.less...

php - Laravel : Login user without password -

php - Laravel : Login user without password - i new laravel , looks nice php framework. going through guide , various tutorials, know how login user using auth class. auth class requires username , password login user. now, if using facebook connect, after successful authentication facebook, might able retrieve user's details corresponding facebook id have saved in db. however, facebook user, no passwords saved in db. how log in user auth class? in codeigniter, have set session info follows: $userdata = array( 'logged_in' => true, 'user_id' => $user_id ); $this->session->set_userdata($userdata); here's guide of how , bundle allow connect users more oauth apis php facebook laravel laravel-3

java - Why is this "if" a "dead code"? -

java - Why is this "if" a "dead code"? - i have next code : /** width of each brick in pixels */ private static final int brick_width = 11; /** width of each brick in pixels */ private static final int brick_height = 12; /** number of bricks in base of operations of pyramid */ private static final int bricks_in_base = 14; public void run () { int lowerleftside; if (brick_width / 2 == 0) { lowerleftside = ((getwidth()/2) - (brick_width*(bricks_in_base/2))); }else lowerleftside = ((getwidth()/2) - (brick_width*(bricks_in_base/2-1))); eclipse marks whole if dead code. initialize value @ origin of run method. thanks. looks brick_width constant, brick_width/2 known @ compile time , eclipse knows path taken, other 1 dead code. java

html - A SVG file in a SVG game? -

html - A SVG file in a SVG game? - i'm trying create svg game. can't svg file (made inkscape) take place in game. i'm aware of embed , utilize of objects , iframes: <embed src="spaceship.svg" type="image/svg+xml" /> <object data="spaceship.svg" type="image/svg+xml"></object> <iframe src="spaceship.svg"></iframe> but doesn't work jumps outside of svg game. is possible place svg file in svg tag? or should stick canvas games? do want dynamically load svg file existing svg file or want multiple svg objects in svg file - so: <?xml version="1.0" standalone="no"?> <!doctype svg public "-//w3e//dtd svg 1.1//en" "http://www.w3.org/graphics/svg/1.1/dtd/svg11.dtd"> <svg preserveaspectratio="none" viewbox="0 0 10000 10000" version="1.1" xmlns="http://www.w3.org/2000/svg" onload=...

ios - Can I serialize an ACAccount object holding an authorized twitter account? -

ios - Can I serialize an ACAccount object holding an authorized twitter account? - i have implemented built in twitter api, , working great, trying decide how best persist twitter business relationship between sessions when user has multiple twitter accounts set up. if receive single acaccount using -[acaccountstore accountswithaccounttype:] , it's easy... utilize one. if, however, there multiple acaccounts don't want asking them every time come in app 1 use. the way see far, options are: serialize acaccount object using nskeyedarchiver (this ideal, if possible) bug user every time (don't want this) store username of selected acaccount , in next session compare username in each business relationship within acaccountstore , , select business relationship (although reason seems inelegant workaround). many in advance! acaccount has property named identifier uniquely identify single account. type of property nsstring can persist value either ...

c++ - avr linker++ setting header and .cpp files -

c++ - avr linker++ setting header and .cpp files - i want set linker correctly eclipse project can work properly.i have added the folder header , cpp files exist c/c++ compiler directories. have set linker also. n ot know how cause linker in tool settings wants add together library (an .a file not exist cause none makes it), since not have .a file error @ functions cause can give folder path linker within there there no .a file. can do. c++ c eclipse optimization arduino

jquery - Error while configuring datatable with json -

jquery - Error while configuring datatable with json - i have table follow <table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> <thead> <tr> <th>month</th> <th>id</th> <th>comments</th> <th>details</th> </tr> </thead> <tbody> </tbody> </table> my json is [{ "month": "jan-2013", "id": "asdfa0", "comments": "", "details": "bla bla blba blablabalbal" }] and script $(document).ready(function () { var otable = $('#example').datatable({ "bprocessing": true, "sajaxsource": "script/ahd.json", "aocolumns": [ { "mdata": "month" }, { "mdata": "id" }, { "mdata": "co...

ios - How to Move the sprite with conditions and constrains -

ios - How to Move the sprite with conditions and constrains - i having 32 sprite in scene had arranged sprite this o o o o o o o o o o o o o o o o . o o o o o o o o o o o o o o o o o ---> movingball . ---> empty hole when move move 1 sprite empty hole, middle sprite removed , sprite , hole should interchanged, this. o o . -----> . . o possible ways: | | | | | | | o | | . | | o | . | . | . o | o o . | o | . o o | o | o | o | o . | | o | | . | o | o | o | | | | | | | totally 8 possibility move sprite. can ...

c# - How could I find an element with similar ID in JS? -

c# - How could I find an element with similar ID in JS? - in page have labels this: contentplaceholder1_gvgroups_lblname_0 with corrosponding: contentplaceholder1_gvgroups_lblhidden_0 i can assert *lblname has corrosponding *lblhidden. now, have js: //use create label 'edit' class editable function makelabelseditable() { $(".edit").focusout(function () { setlabel(this); }); $(".edit").click(function () { editlabel(this); }); } //used edit labels function editlabel(source) { source.innerhtml = '<input type="text" maxlength="40" value="' + source.innerhtml + '"/>'; $(source).unbind('click'); source.children[0].focus() } //used edit labels function setlabel(source) { if (source.children[0].value != '') { $(source).click(function () { editlabel(this); }); source.innerhtml = source.chil...

my php code is not working on Internet explorer 9? -

my php code is not working on Internet explorer 9? - i writing code in php using session ,its working on mozilla on chrome on net explore not working ? please help me resolve problem ` <?php session_start(); if(isset($_post['submit'])) { $_session['ignite']="ignite -"; $_session['ignite_price']=39.95; $_session['ignite_qty']+=1; $_session['total_ignite']+=39.95; } if(isset($_post['submit1'])) { $_session['rebuild']="rebuild -"; $_session['rebuild_qty']+=1; $_session['rebuild_price']=39.95; $_session['total_rebuild']+=39.95; } if(isset($_post['submit2'])) { $txt_rebuild=$_post['txt_rebuild']; $txt_ignite=$_post['txt_ignite']; $_session['ignite_price']; $_session['rebuild_qty']=$txt_rebuild; $_session['ignite_qty']=$txt_ignite; $_session['total_rebuild']=$_session['rebuild_price'] * $_session['rebuild_qty'...

ios - How to put CGContextScaleCTM and CGContextTranslateCTM outside of drawRect? -

ios - How to put CGContextScaleCTM and CGContextTranslateCTM outside of drawRect? - i rather beginner @ kind of path drawing, when displaying map, realised cgcontextscalectm , cgcontexttranslatectm take lot of time within drawrect. bring outside. since draw same map, think should possible. how? could scale this: cgaffinetransform currenttransform = myview.transform; cgaffinetransform newtransform = cgaffinetransformscale(currenttransform, 0.5, 0.5); [myview settransform:newtransform]; and utilize cgaffinetransformtranslate in similar manner x/y. ios drawrect cgcontext scaletransform

python - Return whichever expression returns first -

python - Return whichever expression returns first - i have 2 different functions f , , g compute same result different algorithms. 1 or other takes long time while other terminates quickly. want create new function runs each simultaneously , returns result first finishes. i want create function higher order function h = firstresult(f, g) what best way accomplish in python? i suspect solution involves threading. i'd avoid give-and-take of gil. now - unlike suggestion on other answer, piece of code requesting: from multiprocessing import process, queue import random import time def firstresult(func1, func2): queue = queue() proc1 = process(target=func1,args=(queue,)) proc2 = process(target=func2, args=(queue,)) proc1.start();proc2.start() result = queue.get() proc1.terminate(); proc2.terminate() homecoming result def algo1(queue): time.sleep(random.uniform(0,1)) queue.put("algo 1") def algo2(queue): ...

NoMethodError undefined method '-@' NoMethodError in Controller Ruby on Rails -

NoMethodError undefined method '-@' NoMethodError in Controller Ruby on Rails - context: pulled recent code repository , tried create sure changes force going work version of code. ruby on rails application. worth noting fact when running main application pulled on web, error not show up. if run branch or main branch cloned onto environment, error shows every url try. on end. problem: go localhost:3000, next error: nomethoderror in homecontroller#index undefined method `-@' #<actiondispatch::response:0x64fd460> what i've tried: have asked question on #rubyonrails irc channel , nobody able determine going on through total trace (i haven't posted here because wasn't sure best way on here; didn't in code block or block quote). have looked @ homecontroller's index method, defined such: def index @groups = @current_user.groups @things = thing.where(:group_id => @groups.map{|e|e.id}) end i have googled a...

php - If/then statement on field value in drupal 7 -

php - If/then statement on field value in drupal 7 - i'm trying write statment looks @ value in boolean field (field_solo) , returns 1 of 2 template files have created in drupal 7. my field "field_solo" correctly outputting value of 0 or 1 , have cleared cache. can tell me if doing correctly? right not getting display when statement true. function motg_preprocess_node(&$vars) { $node = $vars['node']; if($node->field_solo[0]['value'] == 1) { $vars['theme_hook_suggestion'] = 'node__solo'; } else { $vars['theme_hook_suggestion'] = 'node__video'; } } instead of if($node->field_solo[0]['value'] == 1) make it if($node->field_solo['und'][0]['value'] == 1) // or if($node->field_solo[language_none][0]['value'] == 1) php drupal if-statement drupal-7 drupal-theming

Sed: append after last occurrence -

Sed: append after last occurrence - let's have next kind of file: <?xml version="1.0" encoding="utf-8"?> <preferences> <section id="widgets"> <value id="version" xml:space="preserve">1</value> </section> <section id="wuid-b2a8e6b8-6619-714e-9cfe-466c27c90902"> <value id="path widget data" xml:space="preserve">{preferences}widgets/opera-adblock-1.3.4-1.oex</value> </section> <section id="wuid-0c5cfdb2-8e51-f149-a1e7-51d66240ed7a"> <value id="path widget data" xml:space="preserve">{preferences}widgets/flag-button-1.5.4-1.oex</value> </section> </preferences> my mission add together text right after lastly occurrence of </section> . looking @ these 2 seems if utilizing tac simpler don't understand how either: using sed append string 4th ...

linux - How to find matching patterns between two text files and output to another file? -

linux - How to find matching patterns between two text files and output to another file? - i have 2 text files different text organization. both files contain few identical patterns (numbers) in text. i'd find patterns (numbers) nowadays in both files , write them output file. file1.txt: blablabla_25947.bkwjcnwelkcnwelckme blablabla_111.bkwjcnwelkcnwelckme blablabla_65155.bkwjcnwelkcnwelckme blablabla_56412.bkwjcnwelkcnwelckme file2.txt: blablabla_647728.bkwjcnwelkcnwelck kjwdhcwkejcwmekcjwhemckwejhcmwekch blablabla_6387.bkwjcnwelkcnwelckme wexkwhenqlciwuehnqweiugfnwekfiugew wedhwnejchwenckhwqecmwequhcnkwjehc owichjwmelcwqhemclekcelmkjcelkwejc blablabla_59148.bkwjcnwelkcnwelckme ecmwequhcnkwjehcowichjwmelcwqhemcle kcelmkjcelkwejcwecawecwacewwawwaxeg blablabla_111.bkwjcnwelkcnwelckm wesetrbrvsscqesfdveradassefwaefawecc output_file.txt: 111 how about: $ egrep -o '_[0-9]+\.' file1 | grep -of - file2 | tr -d '_.' 111 # redirect n...

android - Draw with canvas.draw() a custom class -

android - Draw with canvas.draw() a custom class - im using canvas draw phone call "label" in app. "label" has round shape, icon , text. i'm calling method canvas.draw() , set params draw this. since app needs handle lot of labels, need create class handle icon , text of label instead of calling method canvas.draw(text, bitmap, paint...). there way can that? post of code: public void ondraw(canvas canvas){ canvas.draw(bitmap mybitmap); canvas.draw(string mytext); and on. need utilize class param draw canvas. canvas.draw(mycustomclass labelbathroom); assuming mycustomclass has properties , methods required. you wrap in either view or drawable . android class canvas ondraw

c - Change more than one space in between words into one -

c - Change more than one space in between words into one - i need read text , find if there more 1 space between words. if there alter one. for illustration if have text: my name lukas program should alter to: my name lukas any ideas? j = 0; for(i=0; mystr[i] != '\0'; i++) { if(mystr[i] == ' ' && mystr[i+1] == ' ') continue; newstr[j] = mystr[i]; j++; } and don't forget add together '\0' (which indicates end of string) end of newstr c

php - HTML email generation that supports all mail services -

php - HTML email generation that supports all mail services - is there php script can generate email templates back upwards email clients such yahoo,gmail,outlook,hotmail etc.,? example, seems inline styles accepted in mail service services. there way generate inline styles elements provided within <style>...</style> tag or that? can't utilize online services, since have 1000 of email templates , increasing day day. suggestion or ideas appreciated... pommo want! main projet: http://pommo.org/main_page screen: http://www.flickr.com/photos/26392873@n00/sets/72157594430337337/show/ download: https://sourceforge.net/projects/pommo/files/ i utilize several years, works fine php html-email

memory - Predict number of rows in merge/join -

memory - Predict number of rows in merge/join - in code utilize merge/join in numerous places. bumped on bring together making cartesian product (probably out of 5000 files process). since code works on 64 bit system/python, bring together keeps running fill memory, blocking every process/user on hardware node. since no actual error occurs, hard debug well. is there easy way test validity of join/merge, utilize in assert statement? thanks, luc memory join merge pandas

bash - how to parse html by sed - extract two strings delimited by two strings - on different lines, sequentially -

bash - how to parse html by sed - extract two strings delimited by two strings - on different lines, sequentially - i have bash script: v1='value="' v2='" type' do_parse_html_file() { sed -n "s/.*${v1}//;s/${v2}.*//p" "${_script_path}/iblocklistlists.html"|egrep '^http' >${_tmp_file} } ... extracting html file urls. have on output: somename url somename url --- illustration of input html file following: </tr> <tr class="alt01"> <td><b><a href="http://www.iblocklist.com/list.php?list=bcoepfyewziejvcqyhqo">iana-reserved</a></b></td> <td>bluetack</td> <td><img style="border:0;" src="i-blocklist%20%7c%20lists_files/star_4.png" alt="" height="15" width="75"></td> <td><input style="width:200px; outline:none; border-style:solid; border-width:1px; border-c...

java - Hibernate update query -

java - Hibernate update query - i have table 1 primary key (auto increment) , 3 columns except primary key column s.no empid empname month salary 1 1700 xxxx jan 17000 2 1701 yyyy jan 70000 3 1700 xxxx feb 16750 4 1702 yyyy jan 70000 5 1700 xxxx mar 17000 6 1700 xxxx apr 16000 this table contains details employee names , his/her monthly salary details, need update salary of employee xxx in jan month. how can in hibernate using session.saveorupdate method? assuming working persistent "employee" objects, think should work out. transaction t = session.begintransaction(); employee.setempid(id); employee.setempname(name); employee.setsalary(newsalary); ... session.saveorupdate(employee); system.out.println("successfully updated"); t.commit(); java sql hibernate sql-update dao

Three.js Picking is working with custom geometry having multiple materials -

Three.js Picking is working with custom geometry having multiple materials - here jsfiddle: here here previous version jsfiddle without implementing picking, if want seek start: here my custom geometry in scene having multiple materials couldn't pick them. please help me resolve issue. <script type="text/javascript"> var subset; var meshmaterial, camera, projector = new three.projector(), scene, renderer, container; var width = window.innerwidth, height = window.innerheight; var mouse = { x: 0, y: 0 }, intersected; function change() { subset = new array(); init(); animate(); } meshmaterial = [ new three.meshlambertmaterial({ color: 0xffffff, opacity: 0.6, depthwrite: false, depthtest: false, vertexcolors: three.vertexcolors }), new three.meshlambertmaterial({ color: 0xffffff, opacity: 1, depthwrite: false, depthtest: false, vertexcolors: three.vertexcolors })]; // photographic camera ...

ios - Releasing static resources in Objective-C -

ios - Releasing static resources in Objective-C - this question has reply here: objective-c/iphone memory management static variables 3 answers if utilize static resource in objective-c class, create memory leak not ever releasing it? following: @interface myclass : nsobject + (myclass *)sharedinstance; @end @implementation myclass + (myclass *)sharedinstance { static myclass * inst; if (!inst) inst = [myclass new]; homecoming inst; } @end a) there scenario application using class closes , static declaration creates memory leak? b) there class method, such + (void)unloadclassdefinition , called when class definitions beingness purged memory? (does happen?) a leak chunk of memory have lost pointers. have pointer object, because variable exists duration of process. long don't reassign new object pointer without destroying old...

selenium - llegalStateException: Unable to locate element by xpath for com.gargoylesoftware.htmlunit.TextPage -

selenium - llegalStateException: Unable to locate element by xpath for com.gargoylesoftware.htmlunit.TextPage - all of sudden tests stopped working. error message is java.lang.illegalstateexception: unable locate element xpath com.gargoylesoftware.htmlunit.textpage@11d1aa6 @ org.openqa.selenium.htmlunit.htmlunitdriver.findelementbyxpath(htmlunitdriver.java:796) @ org.openqa.selenium.by$byxpath.findelement(by.java:344) @ org.openqa.selenium.htmlunit.htmlunitdriver$5.call(htmlunitdriver.java:1251) @ org.openqa.selenium.htmlunit.htmlunitdriver$5.call(htmlunitdriver.java:1248) @ org.openqa.selenium.htmlunit.htmlunitdriver.implicitlywaitfor(htmlunitdriver.java:991) @ org.openqa.selenium.htmlunit.htmlunitdriver.findelement(htmlunitdriver.java:1248) @ org.openqa.selenium.htmlunit.htmlunitdriver.findelement(htmlunitdriver.java:397) pointing on line webelement menu = driver.findelement(by.xpath("//a[starts-with(@href,'/index.html')]")); my driver initializ...

algorithm - Does the order of data in a text file affects its compression ratio? -

algorithm - Does the order of data in a text file affects its compression ratio? - i have 2 big text files (csv, precise). both have exact same content except rows in 1 file in 1 order , rows in other file in different order. when compress these 2 files (programmatically, using dotnetzip) notice 1 of files considerably bigger -for example, 1 file ~7 mb bigger compared other.- my questions are: how order of info in text file impact compression , measures can 1 take in order guarantee best compression ratio? - presume having similar rows grouped (at to the lowest degree in case of zip files, using) help compression not familiar internals of different compression algorithms , i'd appreciate quick explanation on subject. which algorithm handles sort of scenario improve in sense accomplish best average compression regardless of order of data? "how" has been answered. reply "which" question: the larger window matching, less sensitive alg...

c# - Replacing recursive with loop -

c# - Replacing recursive with loop - i working on asp.net page, , there tree view in it. in tree view nodes have nested nodes branches. have info in list of custom objects in next format: id, description, parentid right now, using function recursively add together nodes tree view. next code snippet: private bool findparentaddnode(string id, string description, string parentid, ref list<customtreenode> treelist) { bool isfound = false; foreach (customtreenode node in treelist) { if (node.id == parentid)//if current node parent node, add together in kid { node.addchild(id, description, parentid); isfound = true; break; } else if (node.listofchildnodes != null)//have kid nodes { isfound = findparentaddnode(id, description, parentid, ref node.listofchildnodes); if (isfound) break; } } homecoming isfound; } the ab...

c# - Why does cancellation block for so long when cancelling a lot of HTTP requests? -

c# - Why does cancellation block for so long when cancelling a lot of HTTP requests? - background i have code performs batch html page processing using content 1 specific host. tries create big number (~400) of simultaneous http requests using httpclient . believe maximum number of simultaneous connections restricted servicepointmanager.defaultconnectionlimit , i'm not applying own concurrency restrictions. after sending of requests asynchronously httpclient using task.whenall , entire batch operation can cancelled using cancellationtokensource , cancellationtoken . progress of operation viewable via user interface, , button can clicked perform cancellation. problem the phone call cancellationtokensource.cancel() blocks 5 - 30 seconds. causes user interface freeze. suspect occurs because method calling code registered cancellation notification. what i've considered limiting number of simultaneous http request tasks. consider work-around because httpclient ...