Posts

Showing posts from May, 2011

MySQL Union distinct based on equality predicate -

i have 2 tables have columns "name" "lname" "val" , want union "name" , "lname" unique first table overriding rows of second. union distinct looks want cant make check first 2 rows. (select a.name, a.lname, a.val a) union (select b.name, b.lname, b.val b left join using(name, lname) a.name null)

Jquery wildcard selectors for calling plugin? -

to keep brief, i'm trying select #small-cycle1, #small-cycle2, etc. jquery cycle plugin. using wild cards select not seem working, writes out pager nav of cycles each cycle. below how i'm getting around problem now. $('#small-cycle1').cycle({ speed: 0, timeout: 0, pager: '#nav1', pagerevent: 'mouseover', pauseonpagerhover: true }); $('#small-cycle2').cycle({ speed: 0, timeout: 0, pager: '#nav2', pagerevent: 'mouseover', pauseonpagerhover: true }); $('#small-cycle3').cycle({ speed: 0, timeout: 0, pager: '#nav3', pagerevent: 'mouseover', pauseonpagerhover: true }); $('#small-cycle4').cycle({ spe...

jsp - Error checking in java while converting a string to a double -

i tryin convert string array double array, depending on weather station chosen database - weather stations have no data, whole string array filled nulls(12 of them in fact) obviosly if 1 of them stations chosen exception. realy have no time write lot of code work around it, since have submit work soon... there solution catch , display error message user insted of lines , lines explaining error? thanks! here loop convert string array double array for(int = 0; i<12; i++) { avmaxtempoptimised[i] = double.parsedouble(avmaxtempsplit[i]); avmintempoptimised[i] = double.parsedouble(avmintempsplit[i]); meantempoptimised[i] = double.parsedouble(meantempsplit[i]); highesttempoptimised[i] = double.parsedouble(highesttempsplit[i]); lowesttempoptimised[i] = double.parsedouble(lowesttempsplit[i]); maxwindoptimised[i] = double.parsedouble(maxwindsplit[i]); totalrainfalloptimised[i] = double.parsedouble(totalrainfallsplit[i]); maxdayrainfalloptimised[i] = double.parsedouble(maxdayrainfal...

wpf - Binding a ComboBoxEdit ItemsSource -

i hope can enough job explaining problem. i have devexpress gridcontrol 3 columns. gridcontrol's itemssource set collection of objects have 3 strings on them. my problem 3rd column must comboboxedit itemssource collection of of selected values of 3rd column's combo boxes. here (link an) image describe mean: http://imgur.com/77vri4w.jpg (can't post images yet, unfortunately) so want the drop down of group column display group1, group2, etc... choices, collection exists on viewmodel , not on object each row represents. that being said, group string is on row, , that's inputting new value edit box should change. want able bind display/valuemembers of combobox value on row object, bind itemssource on drop down collection on viewmodel. here xaml third column pick apart: <dxg:gridcolumn width="auto" header="group" fieldname="pacgroup"> <dxg:gridcolumn.celltemplate> <data...

javascript - Accessing elements with IDs via their global variables -

it not-so-widely-known fact most* web browsers create global variable every element on page id attribute: html: <header id="page-header"></header> js: window['page-header'].style.fontfamily = "comic sans ms"; questions: is reliable way select elements? any reason use document.getelementbyid instead? guess accessing id'd elements global variables faster document.getelementbyid . here demo. *i've tested in latest versions of chrome, firefox, , ie. i tested on jsperf , chromium v25 getelementbyid faster

string split method (each in line) javascript -

i'm trying write code program allow user enter word or sentnce in text-box press button. when user press button result should appear actually faced problem in last part split sentence , put each in separate line. what know can put them in separate line write code such that: var mystring = "zero 1 2 3 four"; var mysplitresult = mystring.split(" "); for(i = 0; < mysplitresult.length; i++){ document.write("<br /> element " + + " = " + mysplitresult[i]); } but when did it, didn't work code function t { var r=input.split("."); (var = 0; < r.length; i++){ r.innerhtml ="<br/> " + r[i];} } for (var = 0; < n.length; i++) { result.innerhtml = "lenrth of input string: "+ input.length + "<p>number of spaces: "+num +"</p>" + "<p> replacing word 'red' 'blue...

jquery - Flexslider stop at first slide after loop -

i trying flexslider make full loop , stop or pause once gets first slide. here code far: $(window).load(function(){ $('.flexslider').flexslider({ animation: "slide", animationloop: true, slideshowspeed: 5000, pauseonhover: true, start: function(slider){ $('body').removeclass('loading'); } }); }); try this: $(window).load(function(){ $('.flexslider').flexslider({ animation: "slide", animationloop: true, slideshowspeed: 5000, pauseonhover: true, start: function(slider){ $('body').removeclass('loading'); }, after: function (slider) { if ((slider.currentslide + 1) == slider.count) { slider.pause(); } } }); });

c# - Winforms and Background Worker -

i have console app @ moment, monitors folder files, , based on rules , file name, copies new file location on network. i have requirement make application more pretty, decided go simple winforms single form application displays status , 'last updated file' type information. the console app written in such way console display information went through single method, called 'notify', taking 2 parameters. string display information want user see, , errorlevel enum, which, if 'normal' displayed in green text, if warning, yellow, , if error, red. point is, code did use 'notify' method output text. i want change console app normal class, run background worker winforms project, , have notify method in thread send updates winforms app, safely. think can done events, not sure best way handle this. propose method working? there's 'invoke' way of doing things. good? like: this.begininvoke (new methodinvoker(() => updatelabel(s)); it se...

C# solution design to display web content from a complex calculation? -

i need process complex calculation generate report , display webpage. has run periodically recalculate formula based on new input. i have few ideas: 1. create web service process , cache content , create web application request content via http periodically. 2. create service output file periodically , create web application read file. 3. create web application has task in there running periodically generate output , create webpage display it. i have read of old threads want know better approach, pros , cons or if there newer way of implementing this? jite! i did program similar yours. task generate report when user asks application do. daily report, calculation costs several minutes, there many records, , fomular complex, too. we created periodly thread check wether time calucate.thus thread calute , store condition , result sqlserver. when users click button view daily report, yet report in db , application needs read out db, , show on screen. let disscuss so...

c# - Is there a way to create a delegate to get and set values for a FieldInfo? -

for properties there getgetmethod , getsetmethod can do: getter = (func<s, t>)delegate.createdelegate(typeof(func<s, t>), propertyinfo.getgetmethod()); and setter = (action<s, t>)delegate.createdelegate(typeof(action<s, t>), propertyinfo.getsetmethod()); but how go fieldinfo s? i not looking delegates getvalue , setvalue (which means invoking reflection each time) getter = s => (t)fieldinfo.getvalue(s); setter = (s, t) => (t)fieldinfo.setvalue(s, t); but if there createdelegate approach here? i mean since assignments return value , can treat assignments method? if there methodinfo handle it? in other words how pass right methodinfo of setting , getting value member field createdelegate method delegate can read , write fields directly? getter = (func<s, t>)delegate.createdelegate(typeof(func<s, t>), fieldinfo.??); setter = (...

c++ - Premake OpenGL SDK Cannot Build Project From Tutorial -

i'm trying build tutorials http://www.arcsynthesis.org/gltut/index.html , can't seem past linking part. when go tut 01 folder , type in "premake4 gmake" , "make" right after. ==== building framework (debug) ==== ==== building tut 01 main (debug) ==== linking tut 01 main /usr/bin/ld: cannot find -lglloadd /usr/bin/ld: cannot find -lglimgd /usr/bin/ld: cannot find -lglutild /usr/bin/ld: cannot find -lglmeshd /usr/bin/ld: cannot find -lfreeglutd collect2: error: ld returned 1 exit status make[1]: *** [tut 01 maind] error 1 make: *** [tut 01 main] error 2 as can see, has problems linking project together. downloaded tutorial 0.3.8.7z here: https://bitbucket.org/alfonse/gltut/downloads all right, found answer in case wants know how fix, have open file in framework/framework.lua , scroll down until see configuration "linux" links {"gl", "glu"} and change to configuration "linux" lin...

ruby on rails - track history of active record changes and its association -

i want track history active record , association. have many many association: class booklist has_many :book_list_items has_many :books, through: :book_list_items end class booklistitem belongs_to :book belongs_to :book_list attr_accessable :position end class book has_many :book_list_items has_many :book_lists, through: :book_list_items end how track history of booklist this: add book book list remove book book list update position of book in book list how implement structure http://railscasts.com/episodes/255-undo-with-paper-trail this great rails cast work great based on information provided

jsf - Domain based I18N with JSF2.0 -

i have implement i18n based on domain using jsf2. for example if domain is www.bookstore.com --> should go english site www.bookstore.com.cn --> should go chinese site www.bookstore.co.jp --> should go japanese site we have properties files proper translation. when change browser language/locale, able see translated content. don't need behavior actually. setting locale based on domain in filter, seems not working. here code, wrong in code, problem ? authenticationfilter.java public class authenticationfilter implements filter { private static log log = logfactory.getlog(authenticationfilter.class); @override public void init(filterconfig config) throws servletexception { } @override public void dofilter(servletrequest request, servletresponse response,filterchain chain) throws ioexception, servletexception { request.setcharacterencoding("utf-8"); response.setcharacterencoding("utf-8")...

c++ - Bit shifting and assignment -

this question has answer here: why doesn't left bit-shift, “<<”, 32-bit integers work expected when used more 32 times? 9 answers this sort of driving me crazy. int = 0xffffffff; int b = 32; cout << (a << b) << "\n"; cout << (0xffffffff << 32) << "\n"; my output is -1 0 why not getting 0 0 undefined behavior occurs when shift value number of bits not less size (e.g, 32 or more bits 32-bit integer). you've encountered example of undefined behavior.

Create array from dynamic variables PHP -

i working following code. every time line ready form file, need add associative array $fp = fopen("printers.txt", "r"); // open ptinters.txt read fgets() // while not end of file, read line , store in $printer while (!feof($fp)) { $printer = fgets($fp, 256); // split line of text 3 sections , store them // variables named $pname $printertype , $numpages. $temparray = explode(":", $printer); $pname = $temparray[0]; $printertype = $temparray[1]; $numpages = $temparray[2]; //create 2 arrays. first stores $pname , $printertype // second stores $pname , $numpages }; // close while !feof $fp loop. fclose($fp); // close $fp file pointer stream. the following code creates array1 = [name] => printertype , array2 = [name] => numpages . $array1 = array(); $array2 = array(); $fp = fopen("printers....

netbeans - Inserting an object in ascending order with an ArrayList in Java -

so i've went , forth quite few times trying multiple different methods can't seem wrap head around appropriate algorithm method. creating polynomial class uses arraylist term(int coeff, int expo) coeff coefficient of polynomial , expo exponent. in test class have insert multiple different term objects need inserted in ascending order exponents (for example, 4x^1 + 2x^3 + x^4 + 5x^7) this code have end of insert() method takes 2 parameters, coeff , expo: public class polynomial { private arraylist<term> polynomials ; /** * creates new polynomial object no terms */ public polynomial() { polynomials = new arraylist<>() ; } /** * inserts new term proper place in polynomial * @param coeff coefficient of new term * @param expo exponent of new term */ public void insert(int coeff, int expo) { term newterm = new term (coeff, expo) ; if (polynomials.isempty()) { polynomials.add(ne...

android - How to properly inflate a layout with a nested ViewFlipper? -

i used have simple main.xml layout had 2 views flipped via viewflipper wrapper. worked (still works) great, using following code: setcontentview(r.layout.main); mtv1 = (textview) findviewbyid(r.id.textview01); mtv2 = (textview) findviewbyid(r.id.textview02); mviewflipper = (viewflipper)findviewbyid(r.id.flipper01); i want add 2 buttons on top of original views, in fashion similar this : <linearlayout android:id="@+id/linearlayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> <linearlayout android:id="@+id/linearlayout02" android:layout_width="fill_parent" android:layout_height="wrap_content"> <button android:id="@+id/button01" android:layout_height="wrap_content" android:text="button 1" android:layout_width="0dip...

how to test/use zend in wamp 2.2? -

i using win 7 system, have installed wamp 2.2, open http://localhost/?phpinfo=1 , can see zend info, eg: zend extension 220090626... mean zend installed in wamp 2.2? did test: <?php $date=new zend_date(); echo $date; ?> but shows: fatal error: class 'zend_date' not found in d:\wamp\www\test.php on line 2 so how know if zend installed already? , how test/use it? thanks. try this 1.you config zend library file 2.download zend library file , paste location c:\wamp\bin 3.some changes need in wamp server following steps given you following steps 1.copy zendframework file => c:\wamp\bin 2.add bin path environmental variables path => "c:\wamp\bin\zendframework\bin" 3.change php.ini file in wamp server below: ; windows: "\path1;\path2" include_path = ".;c:\wamp\bin\zendframework\library" 4.change httpd.conf in apache below: loadmodule rewrite_module modules/mod_rewrite.so which means remove #. ...

vb.net 2010 - NullReferenceException is not managed. "Tables" returns nothing. why? -

here code. it's first time @ vb.net. private sub accountnum_keypress(byval sender object, byval e system.windows.forms.keypresseventargs) handles accountnum.keypress dim index long = 0 if asc(e.keychar) = 13 while index <= 111000 if accountnum.text = ds.tables("dbo.accountmaster").rows(index).item("accountnumber").tostring nameconsumer.text = ds.tables("dbo.accountmaster").rows(index).item("consumername") address.text = ds.tables("dbo.accountmaster").rows(index).item("consumeraddress") end if loop end if end sub the null reference error means you're attempting take action on object value has not been set. it's not uncommon people lose sight of source of these errors when using language handy dot notation. take @ example line 5 in snippet: ds.tables("dbo.accountmaster").rows(index).item("accountnu...

php - Combining HybridAuth with Javascript SDKs? -

(repost https://groups.google.com/forum/?hl=en&fromgroups=#!topic/hybridauth/cwo2r9suyts ) starting facebook, i'm trying use provider javascript sdks login , have hybridauth "know" it. appreciated. i started including configuration ids in data pass view can use them when calling javascript login functions. in middle of getproviders function of hybrid_auth class, added: if(array_key_exists('keys', $params) && array_key_exists('id', $params['keys'])) $idps[$idpid]['id'] = $params['keys']['id']; my javascript includes this: fb.init({ appid:'<?php echo $providers['facebook']['id']; ?>', cookie:true, status : true, xfbml:true }); so far good. but after logging in (i.e., fb.login()) of course hybridauth doesn't know , doesn't have user information. then "force" it, tried calling ".../hauth/login/facebook" method via ajax: $.ajax({ type: ...

html - Certain fonts not working with @font-face? -

here's what's frustrating here. got font pack sansation, , tried use @font-face. regular version works , "bold" version doesn't. checked filename , it's correct. understanding font should work. missing something? @font-face { font-family: sansation_regular; src: url('/fonts/sansation_regular-webfont.ttf'), url('/fonts/sansation_regular-webfont.eot'); } i then, without changing font-family in css corresponding text element, change to: @font-face { font-family: sansation_regular; src: url('/fonts/sansation_bold-webfont.ttf'), url('/fonts/sansation_bold-webfont.eot'); } thanks assistance. you should run font through fontsquirel full set http://www.fontsquirrel.com/tools/webfont-generator the css it'll generate like: /* fonts */ @font-face { font-family: 'sansation_regular-webfont'; src: url('../fonts/sansation_regul...

c# - What is POCO in Entity Framework? -

i started learning poco cannot understand use , advantage. following link of stackoverflow did not me. what entity framework poco can explain usage of poco simple example? pocos(plain old clr objects) entities of domain. when use entity framework entities generated automatically you. great unfortunately these entities interspersed database access functionality against soc (separation of concern). pocos simple entities without data access functionality still gives capabilities entityobject functionalities like lazy loading change tracking here start this poco entity framework you can generate pocos existing entity framework project using code generators. ef 5.x dbcontext code generator

How to print an array in defined order in AWK 3.1.3 -

i googled , find out after awk 4.0 can print array in defined order putting procinfo["sorted_in"] command right before loop. example procinfo["sorted_in"] = "@ind_num_asc" for( in array) print i, array[i] in awk 4.0.2, works. however, tried in awk 3.1.3 environment, did not work. version of awk not support function? how achieve goal in awk 3.1.3? just keep second array order numerical indices , keys first array values. can iterate through order in sequence , values of array : for (i = 1; < length(order); i++) { print order[i], array[order[i]] } when building order , may want check whether key present in array , prevent keys of array being shown multiple times.

java - Please explain me why 24,16, 8 were used in converting int to bytes? -

the following code convert int bytes array. know int i right shifted 24, 16, 8 times , anded 0xff can't understand why these numbers used? private static byte[] inttobytes(int i) // split integer 4 byte array { // map parts of integer byte array byte[] integerbs = new byte[4]; integerbs[0] = (byte) ((i >>> 24) & 0xff); integerbs[1] = (byte) ((i >>> 16) & 0xff); integerbs[2] = (byte) ((i >>> 8) & 0xff); integerbs[3] = (byte) (i & 0xff); // (int j=0; j < integerbs.length; j++) // system.out.println(" integerbs[ " + j + "]: " + integerbs[j]); return integerbs; } // end of inttobytes() ok lets pretend have 32 bit binary number: 00001111 00000111 00000011 00000001 one byte equivalent 8 bits , therefore number above comprised of 4 bytes. to separate these bytes out need perform series of shift , and mask operations. for instance first byte (00001111) f...

How to assign ClientCredentials to WCF Client while binding with Ninject Kernel in Test_at_server configuration? -

i using ninject inject wcf client in local environment , working fine. how have implemented it: private static ikernel createkernel() { var kernel = new standardkernel(); kernel.bind<func<ikernel>>().tomethod(ctx => () => new bootstrapper().kernel); kernel.bind<ihttpmodule>().to<httpapplicationinitializationhttpmodule>(); registerservices(kernel); return kernel; } and in registerservices(kernel) method have follwing implementation: private static void registerservices(ikernel kernel) { #if debug kernel.bind<mywcfclient.imywcf>().to<mywcfclient.mywcfclient>(); #elif test_at_server kernel.bind<mywcfclient.imywcf>().to<mywcfclient.mywcfclient>() /*.withconstructorargument("username", credentials.username.username = "user") .withconstructorargument("password", credentials.userna...

Retrieve GPS location using android -

i'm trying gps location of current location using simple android program. used onlocationchanged() method this. returning coordinates 0.0. users permission part correct. code of main one. public class mainactivity extends activity { gpstracker gps; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button btn = (button) findviewbyid(r.id.button1); final textview tv = (textview) findviewbyid(r.id.textview1); btn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub gps = new gpstracker(mainactivity.this); double lat = gps.latitude; string mlat = string.valueof(lat); tv.settext(mlat); } }); } } this gps location class im using... public class gpstracker extends service implements locationlistener{ ...

Confused on jquery .ajax .done() function -

i'm bit confused on how use ajax .done() function. i'm working on validating form check if user exists in database , though ajax best approach (still learning it). have php file return true if user exists , false if user doesn't exist. how pass boolean parameter done function? $(".check").blur(function(){ var username = $(".check").val(); $.ajax({ url: "validateuser.php", type: "post", data: "username= " + username }).done(function(result){ if (result == true){ // user exists }else{ // user doesn't exist } }); }); i hope made sense. did best explain it. i think should result == 'true' result data string i checked, correct, quotes make work php: <?php if($_post['username']=='sambob'){echo 'true';}else{echo 'false';} ?> javascript username='sambob'; $(".check").blur(function(){ $.post(...

inheritance - How to override a method Inside another method using c# -

i'm new c# , need figure out how override class method inside new class method without implementing inheritance, in java can this: class classa{ void method1(){ statements .... .... classb obj = new classbb(){ @override void somemethod(){ //from classb statements .... .... } }; } } i want achieve same in c# . you cannot in c#. if part of implementation call-site specific, use delegate , though. void method2() signature maps action (no parameters / return-value), so: class classb { private readonly action method2; public classb(action method2) { if(method2==null) throw new argumentnullexception("method2"); this.method2 = method2; } public void somemethod() { ... uses method2() method2(); } } then: classb obj = new classb(() => { // statements... }); with alternative identical syntax: class...

objective c - Current location code is not working in iOS 5 but works fine in iOS 6 -

i have downloaded current location sample project working fine in both ios 5 , ios 6 . when copied same files project, stopped working in ios 5 workin fine in ios 6 . getting error didfailwitherror: error domain=kclerrordomain code=1 "the operation couldn’t completed. (kclerrordomain error 1.) my code is: .h #import <uikit/uikit.h> #import <corelocation/corelocation.h> @interface viewcontroller : uiviewcontroller<cllocationmanagerdelegate> { cllocationmanager *locationmanager; clgeocoder *geocoder; clplacemark *placemark; } @property (weak, nonatomic) iboutlet uilabel *lbllat; @property (weak, nonatomic) iboutlet uilabel *lbllong; @property (weak, nonatomic) iboutlet uilabel *lbladdress; @end .m - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. locationmanager = [[cllocationmanager alloc] init]; geocoder = [[clgeocoder alloc] init]; locationmanager.delegate = self;...

iphone - locationManager:didUpdateLocations: always be called several times -

i start updating current location when view did appear, , stop updating location whenever locationmanager:didupdatelocations: called. why locationmanager:didupdatelocations: called several times? have missed? #import "viewcontroller.h" @interface viewcontroller (){ cllocationmanager *locationmanager; // location manager current location } @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; } - (void)viewdidappear:(bool)animated { [super viewdidappear:animated]; [self startupdatingcurrentlocation]; } - (void)startupdatingcurrentlocation { if (!locationmanager) { locationmanager = [[cllocationmanager alloc] init]; [locationmanager setdelegate:self]; locationmanager.distancefilter = 10.0f; // don't need more accurate 10m } [locationmanager startupdatinglocation]; } -(void)locationmanager:(cllocationmanager *)manager didupdatelocations:(nsarray *)locations{ [locationmanager sto...

java - How to perform a Differential Sync between a collection of objects and a DB Table -

i have hashmap of type (string, pojoobj). used java program running , triggered using quartz schedular @ regular intervals. for safety during abrupt killing of java process.. hashmap destroyed.. making loss of data.. so, planning dump/sync hashmap data ( pojo objects ) when class started executing schedular. effective if sync differential.. ( changed values updated in db ). i dont have idea it... please me.. using hibernate 3.5 in program. you can use shutdown handler purpose : public final class myshutdownhandler extends thread { private list<iobserver> observerlist; private static myshutdownhandler shutdownhandler; private myshutdownhandler() { observerlist = new arraylist<iobserver>(); runtime.getruntime().addshutdownhook(this); } public static myshutdownhandler getshutdownhandler() { if (shutdownhandler == null) { synchronized (myshutdownhandler.class) { if (shutdownhandler =...

configuration - Restricting access to Site Public pages for select Users -

is possible restrict access of site public pages few users through configuration? now default in liferay can access public pages [that reason named public pages :-) ] of site whether open , restricted or private . in our system force login access public pages, once logged-in user can see public-page of site if has url it. to make requirement more clear: i have 3 users in system, user01 , user02 , user03 . have 3 sites - site01 (open), site02 (restricted), site03 (private) these sites have 1 user respectively. all these 3 users can see public-pages of 3 sites. want user02 should exception, user02 should not able access public-pages of site01 , site03 . is possible through configuration? or require changes in liferay code (possibly through hook)? even if can limit access public-pages users not member of site work? any ideas or appreciated. thanks. for last question even if can limit access public-pages users not member of site work? this can ...

javascript - How to Reset Values of a Form AFTER they are submitted. -

i have form1 , submit button goes like: <input type="submit" name="submit2" id="submit2" value="insert" onclick="document.form1.reset();"/> i want reset values of form after values submitted. above code resets them , submits (empty) values. i have tried: onclick="document.form1.submit();document.form1.reset();" didnt work. append following form's tag: onsubmit="this.submit(); this.reset(); return false;"

php - Unsetting elements from array within foreach -

i'm working on generic form creation class , had issue yesterday. made snippet reproduce problem. essentially want delete elements grouped original elements array after whole group has been drawn , i'm doing while looping on elements array. the code snippet should cover problem, missing here? knowledge deleting element while foreach safe , legal since foreach internally uses copy may modified during loop. $ids = array('a' => array(), 'b' => array(), 'c' => array()); $groups['g1'] = array('a', 'c'); foreach($ids $id => $element) { //var_dump($ids); $g_id = ''; // search id in groups foreach($groups $group_id => $group) { if(in_array($id, $group)) { $g_id = $group_id; break; } } // element part of group if($g_id !== '') { //echo $g_id; // element , c gets unset within loop , should not in $ids anymore ...

c# - Convert caption tag to figure tag -

i want convert this: (from wordpress) [caption id="attachment_5433" align="aligncenter" width="413"] <a href="http://baicadicungnamthang.net/uploads/2012/02/nsut-tuyet-thanh.jpg"><img class=" wp-image-5433" title="nsut-tuyet-thanh" src="http://baicadicungnamthang.net/uploads/2012/02/nsut-tuyet-thanh.jpg" alt="nsƯt tuyết thanh" width="413" height="551"></a>nsƯt tuyết thanh [/caption] to this: (html5) <figure> <a href="http://baicadicungnamthang.net/uploads/2012/02/nsut-tuyet-thanh.jpg"><img class=" wp-image-5433" title="nsut-tuyet-thanh" src="http://baicadicungnamthang.net/uploads/2012/02/nsut-tuyet-thanh.jpg" alt="nsƯt tuyết thanh" width="413" height="551"></a> <figcaption>nsut tuyết thanh</figcaption> </figure> how php or c#? ...

c++ - Where to put main and what to write there? -

i have following code in file tested.cpp : #include <iostream> using namespace std; class tested { private: int x; public: tested(int x_inp) { x = x_inp; } int getvalue() { return x; } }; i have file (called testing.cpp ): #include <cppunit/extensions/helpermacros.h> #include "tested.cpp" class testtested : public cppunit::testfixture { cppunit_test_suite(testtested); cppunit_test(check_value); cppunit_test_suite_end(); public: void check_value(); }; cppunit_test_suite_registration(testtested); void testtested::check_value() { tested t(3); int expected_val = t.getvalue(); cppunit_assert_equal(7, expected_val); } when try compile testing.cpp file get: undefined reference to main'`. well, because not have main (the entry point program). so, compiler not know how start execution of code. but not clear me how execute code in testing.cpp ...

Is is possible to check if certain fd belongs to a epoll set? -

suppose have constructed epoll set, possible find out if fd belongs epoll set? , possible find out epoll set events fd interested in? thanks. use epoll_ctl fd want check op argument epoll_ctl_add. if fd registered registration fail errno assigned eexist. if registration succeeds, part of epoll set delete set right away using epoll_ctl op argument epoll_ctl_del set remains unchanged. if can add more context problem maybe can come better method.

c# - Generating Keystroke With the Kinect -

i'm working on project final year of degree , having trouble coding aspect, being new c# , unity. i'm using kinect, unity , zigfu package , want use persons position in relation kinect generate keystroke. eg if player closer kinect trigger forward button pressed, if farther away trigger back button neutral area in middle. //has user moved if (rootposition.z < -2) { //print(rootposition.z); v = -1; } //has user moved forward if (rootposition.z > -1) { //print(rootposition.z); v = 1; } i've managed find section registers in relation kinect don't know how trigger keystroke. matter appreciated deadline fast approaching , i'm struggling technical side of things. i've used in past simulated keystrokes: windows input simulator (c# sendinput wrapper - simulate keyboard , mouse)

c - Can not disable sse in gcc -

i trying disable sse , sse2 instructions. cross compiling x86 in x64 system. using -static statically link libc. although use -mno-sse , -mno-sse2, when disassemble binary still see call strcpy_sse2, solution? it highly possible library still contains sse instructions. have build library cross system , without sse instructions.

java - Hibernate: how to map collection of Double? -

how can map list of double values class person { @id private string key; @onetomany @column(name="values") private list<double> values; i error use of @onetomany or @manytomany targeting unmapped class: person.values[java.lang.double] try use annotation @collectionofelements like: @collectionofelements @column(name="values") private list<double> values; this work if using 3.4. and if you're using hibernate annotations 3.5+, prefer jpa 2.0 annotations use @elementcollection annotation : @elementcollection @column(name="values") private list<double> values;

c++ - Adding functions to an existing Objective-C class raises error -

i'm writing c++ wrapper nsimage class , i'm having trouble additional functions wrote. here's brief summary: nsimageextras.h @interface nsimage (myextensions) -(nsstring*) myextrafunction; @end nsimageextras.mm #import "nsimageextras.h" @implementation nsimage (myextensions) -(nsstring*) myextrafunction { return @"hello world"; } @end nsimagewrapper.h class nsimagewrapper { public: // nsimage of type (nsimage*) nsimagewrapper(void* nsimage) {myimage = nsimage;} ~nsimagewrapper() {} cfstringref myextrafunction(); // cast (nsimage*) void* getnsimage() {return myimage;} private: void* myimage; }; nsimagewrapper.mm #include "nsimagewrapper.h" #import "nsimageextras.h" cfstringref nsimagewrapper::myextrafunction() { return (cfstringref) [(nsimage*) myimage myextrafunction]; } this compiles. when try call myextrafunction error raised because function isn't found. if change...

objective c - Use of undeclared identifier in main.m -

i'm starting objective-c , have problem. the compiler giving me error message: semantic issue: use of undeclared identifier and main.m code: #import <uikit/uikit.h> #import "hmjappdelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return uiapplicationmain(argc, argv, nil, nsstringfromclass([hmjappdelegate class])); } } this error in main.m file. how can fix problem?

Vertex in Java using JUNG library -

i trying use jung library visualise basic graph vertices , edges. using example code on website, have following: import edu.uci.ics.jung.graph.directedsparsegraph; import edu.uci.ics.jung.graph.graph; import edu.uci.ics.jung.graph.undirectedsparsegraph; import java.util.*; public class graphtest { public graphtest(){ graph g = new directedsparsegraph(); vertex v1 = (vertex) g.addvertex(new directedsparsevertex()); vertex v2 = (vertex) g.addvertex(new directedsparsevertex()); } however, "vertex" underlined in red , netbeans telling me cannot find symbol. tried importing netbeans suggested no avail, , believe vertex native java. i've no idea i'm going wrong think it's elementary error escaping me. jung uses generic types, doesn't define vertex type. what plan put graph? assuming want strings vertex , integers edges, code should like graph<string,integer> g = new directedsparsegraph<string,intg...

Upstart monitoring problems in ubuntu and creating a pid -

i looking how create pid file monitoring of upstart processes in ubuntu. looked @ accepted answer in ubuntu, upstart, , creating pid monitoring , ended following code: env program_name=myscript env base_path=/bar/ respawn limit 5 30 script ${base_path}/bin/python ${base_path}/scripts/${program_name}.py -e ${base_path}/foo.ini end script post-start script echo pid=`status myscript | egrep -oi '([0-9]+)$' | head -n1` echo $pid > /var/run/${program_name}.pid end script post-stop script rm -f /var/run/${program_name}.pid end script there 3 problems encounter: somehow code creates 2 processes. parent process (checked through ps -ef | grep python) shell such as: /bin/sh -e -c ${base_path}/bin/python ${base_path}/scripts/${program_name}.py -e ${base_path}/foo.ini /bin/sh while child process has correct substitutes: /bar/bin/python /bar/scripts/myscript.py -e /bar/foo.ini the pid file contains pid of parent of actual process. not child 1 actual proce...

ruby - Need to implement Watirgrid, -

i want implement watirgrid, i'm not able that, every time i'm getting errors related controller , provider starting process, example on internet, none of them working. could 1 please me implement this, full running example steps great help. i'm trying code: require 'rubygems' require 'watirgrid' require 'watir' require 'watir-webdriver' # setup controller on port 12351 new grid controller = controller.new(:ring_server_port => 12351, :loglevel => logger::error) controller.start # add provider grid # :browser_type => 'webdriver' if using webdriver or # :browser_type => 'ie' if using watir... provider = provider.new(:controller_uri => 'druby://127.0.0.1:11235', :ring_server_port => 12351, :loglevel => logger::error, :browser_type => 'webdriver') provider.start # connect grid , take providers (this time one...

asp.net mvc 4 - Autocomplete or create new object for model -

i'm trying implement similar so/gmail tag system: "try find matching tag or create new". i have 2 simple classes: public class item { [key] public int itemid { get; set; } [required] public string name { get; set; } public int categoryid { get; set; } public virtual category tag { get; set; } } public class category { [key] public int categoryid { get; set; } public string name { get; set; } } the categorycontroller implements autocompletecategory -method returns json list of available categories: public jsonresult autocompletecategory(string term) { var result = categoryrepository.all.where(category=> category.name.tolower().contains(term.tolower())).distinct(); return json(result, jsonrequestbehavior.allowget); } i have jquery-script sends request method , displays matches. now problem: what need use in _createoredit -view map edit-field model? represent category, bind categoryid, simple key, don't ...

php - Can't Initialize Class Gives Error 324 (net::ERR_EMPTY_RESPONSE) -

i want initialize class error 324 (net::err_empty_response) this class want initialize: <?php class cms_content_item_page extends cms_content_item_abstract { public $id; public $name; public $headline; public $image; public $description; public $content; } and class extends from: <?php abstract class cms_content_item_abstract { const no_setter = 'setter methode bestaat niet'; public $id; public $name; public $parent_id = 0; protected $_namespace = 'page'; protected $_pagemodel; public function __construct($pageid = null) { $this->_pagemodel = new cms_content_item_page(); if(null != $pageid) { $this->loadpageobject(intval($pageid)); } } protected function _getinnerrow($id = null) { if($id == null) { $id = $this->id; } return $this->_pagemodel->find($id)->current(); } protected function _getproperties() { $propertyarray = array(); $class = new zend_reflection_class($this); $...

Blocking list of IP addresses in ASP.NET web application/website -

i have group of ip addresses. after deploying application, want able access application particular ip address. how can achieve using global.asax (not through iis)? this starting point you (especially it's separated nicely httpmodule subsequent re-use)

php - having trouble installing Laravel4 dependency with composer -

i tried install laravel4 according instruction in https://github.com/brunogaspar/laravel4-starter-kit . after downloading section tried section 2 contain: cd your-folder curl -s http://getcomposer.org/installer | php php composer.phar install when run last command: php composer.phar install i got output: loading composer repositories package information installing dependencies - installing doctrine/lexer (dev-master bc0e1f0) cloning bc0e1f0cc285127a38c6c8ea88bc5dba2fd53e94 - installing doctrine/annotations (v1.1) downloading:connection... [composer\downloader\transportexception] "https://api.github.com/repos/doctrine/annotations/zipball/v1.1" file not downloaded (http/1.0 500 internal server error) install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-s...