Posts

Showing posts from July, 2012

ruby - Unsupported field datatype: metadata -

i have error message: unsupported field datatype: metadata. extracted source (around line #23): 21 end 22 23 configure :block, :metadata 24 25 configure :sticky, :metadata 26 view_helper :check_box i'm doing presentation gem rails_admin. , in slide 29 put in post , has error. files: /lib/rails_admin/metadata.rb require 'rails_admin/config/fields/base' module railsadmin class metadata < railsadmin::config::fields::base railsadmin::config::fields::types::register(self) def value raise 'no metadata!' unless bindings[:object].respond_to?(:metadata) bindings[:object].metadata[method_name] end def allowed_methods 'metadata' end def parse_input(params) params['metadata'] ||= bindings[:object].metadata params['metadata'] [method_name] = params.delete(method_name) end end end /models/blog/...

java - NullPointerException on Button.findViewById() -

i followed tutorial create dialog in android studio. code shows no error in java file, says "unfortunately app has stopped working". don't know why. my java file: import android.app.alertdialog; import android.content.dialoginterface; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.button; public class mainactivity extends appcompatactivity { private static button b1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); onbutoonlistener(); } public void onbutoonlistener(){ b1=(button) b1.findviewbyid(r.id.button); b1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { alertdialog.builder ad = new ...

javascript - JS Pan Gestures on Android Webview doesn't work -

pan gesture / scrolling on web view not working on webview hosting jquery datatables table until click on table header done. meaning, user cannot scroll table , down , sideways, until presses table header (which sorts table). happens on non-jquery-tables js code – webview not scrollable. interesting thing note, when attach chrome debugger webview, scrolling starts work. i’ve tested same code on android chrome browser local , remote js code – , scrolling works. leads me think there’s kind of issue webview itself. thought might swipe gesture collision - there no swipe gesture defined (meaning web view standalone in activity , there no windows swipe to). any ideas? you should post code, android webview has many options, i'll start testing: webview.getsettings().setbuiltinzoomcontrols(true); also check javascript enable. hope helps

c# - Displaying coloured text in a RichTextbox -

so have string of characters typically formatted this: " t e xt" bold character red. i want display these types of strings in richtextbox bold character being red. i have text in string variable , have location of red character (in string) in int variable. my solution is: get characters before red character get red character get characters after red character display characters before red character display red character (with foreground = brushes.red) display characters after red characters this i've got far: https://github.com/icebbyice/rapide/blob/master/rapide/spreadwindow.xaml.cs find: "//stackoverflow" (also, seperateoutputs not completed) i stopped there because thought there had more efficient way because changing content of rich text box (up 1000 content changes / 60 seconds). so, there better way this?

python - Pjsip Failed to discconect audio -

im using python pjsip library have issue disconnecting wav playing before answer call code if self.call.info().state == pj.callstate.early: call_slot = self.call.info().conf_slot self.wav_player_id = pj.lib.instance().create_player('ring.wav', loop=true) self.wav_slot = pj.lib.instance().player_get_slot(self.wav_player_id) pj.lib.instance().conf_connect(self.wav_slot, 0) if self.call.info().state == pj.callstate.confirmed: print "connecting" pj.lib.instance().conf_disconnect(self.wav_slot, 0) pj.lib.instance().player_destroy(self.wav_player_id) any ideas whats going on? when disconnect slot, shouldn't wait disconnected callback before destroying player ?

angularjs - onsen ui - Include Files -

i have onsen-ui project several pages. have same navigator control on each of these pages. there anyway can extract navigator control out of pages , keep 1 file, import/include file in pages? in c# can create usercontrol , include usercontrol in pages. i'm looking similar in onsen-ui. consider following: <ons-page ng-controller="mycontroller myctrl"> <div class="navigation-bar"> <div class="navigation-bar__left"> <ons-toolbar-button ng-click="myctrl.back()"><ons-icon icon="fa-chevron-left"></ons-icon></ons-toolbar-button> </div> <div class="navigation-bar__center"> page </div> <div class="navigation-bar__right"> <ons-toolbar-button ng-click="myctrl.dosometask()"><ons-icon icon="fa-cog"></ons-icon></ons-toolbar-button...

Java Constructor & Arrays -

i learning java. class take online. assignment finished. trying figure out cause following. the 2 main issues have are: 1)it seems storing 1 flower , ignoring other inputs. how can correct this? 2) display flower (e.g roses - 2): after displays flowers , count give me following error message. flower pack: daffodils - 1 roses - 1 exception in thread "main" java.lang.nullpointerexception @ assignment2.displayflowers(assignment2.java:203) @ assignment2.<init>(assignment2.java:44) @ assignment2.main(assignment2.java:9) i believe it's origination statement flowername = searchingpack[i].getname(); here code: public class flower { private string name; private string color; private string thorns; private string smell; public flower(){ } public flower(string flowername, string flowercolor, string flowerthorns, string flowersmell){ name = flowername; color = flowercolor; thorns = flow...

c# - Entity Framework query return my primary key plus $id -

this model class public partial class tlog { [key] public int idlog { get; set; } public string description { get; set; } public system.datetime insertdate { get; set; } } and query method: public static list<tlog> getalllogs() { var query = log in datacontext.log select log; return query.tolist(); } the json returned is [ { "$id": "1", "idlog": 1, "description": "log1", "insertdate": "2015-06-13t17:32:02.053" }, { "$id": "2", "idlog": 2, "description": "log2", "insertdate": "2015-06-13t17:52:39.637" } ] how can avoid $id in returned json have idlog? use configure json serializer var json = config.formatters.jsonformatter; json.serializersettings.preservereferenceshandling = newtonsoft.json.preserveref...

maven - Jenkins build parameterized with a choice of versions of a Nexus artifact (all GAVs) -

is there jenkins plugin can group-artifact-version (gav) search of nexus repo , list results? results available on parameterized build choice (a dropdown). i added groovy script dynamic choice parameter (see jenkins plugins ) some hurdles were: our nexus server issues basic authentication challenge couldn't use groovy " http://blah ".tourl().text i didn't want load in missing groovy jars httpbuilder used java urlconnection class , encoded user:pass header. used rest api nexus versions, had distinguish between release , snapshots. added group based authentication developers had access snapshots. gav sort not straight forward. there better way gav sort (using org.apache.maven.artifact.versioning.comparableversion ) have not implemented yet now, i'm sorting smaller strings line first. import hudson.model.* import jenkins.model.* def versions=[ ] def snapshots=[ ] // artifactname passed in parameter (eg. extended choice parameter) linke...

c# - Make a <li> invisible in asp.net -

is there way make li id litest , lilogout invisible? i tried this: litest.visible = false but error: error 3, name 'litest' not exist in current context <asp:loginview runat="server" viewstatemode="disabled"> <anonymoustemplate> <ul class="nav navbar-nav navbar-right"> <li><a runat="server" href="~/account/register">register</a></li> <li><a runat="server" href="~/account/login">log in</a></li> <li><a id="litest" runat="server" >test</a></li> <li><a id="lilogout" runat="server" >logout</a></li> </ul> </anonymoustemplate> reference: how to: access server controls id when control not inside naming container, can reference using cont...

node.js - send email via google http rest api -

i trying send email nodejs running on linux server google gmail resr http api. not using libraries, sending https . have figured out oauth part, have access token , responses google. cannot past various error messages. have posted code below. not obvious emailsend() called after access token google, yeah being called. var emailstr = new buffer( "content-type: text/plain; charset=\"utf-8\"\n" + "mime-version: 1.0\n" + "content-transfer-encoding: 7bit\n" + "to: someone@gmail.com\n" + "from: someoneelse@mydomain.com\n" + "subject: subject text\n\n" + "the actual message text goes here" ).tostring("base64").replace(/\+/g, '-').replace(/\//g, '_'); //var emailbase64urlsafe = rtrim( emailstr, '=' ); //var emailbase64urlsafe = jsstrtourlsafe ( emailstr ); var emailbase64urlsafe = emailstr; var http = require('https'); fu...

json - JavaScript objects returning undefined -

i'm sending http request api endpoint returns following: { "status": 200, "headers": "{\"server\":\"nginx\",\"date\":\"sat, 13 jun 2015 22:29:35 gmt\",\"content-type\":\"application/json; charset=utf-8\",\"content-length\":\"223\",\"connection\":\"keep-alive\",\"status\":\"200 ok\",\"cache-control\":\"no-cache, no-store, must-revalidate\",\"pragma\":\"no-cache\",\"x-frame-options\":\"sameorigin\",\"vary\":\"accept-encoding\",\"x-ua-compatible\":\"ie=edge,chrome=1\",\"set-cookie\":[\"_twitch_session_id=4654465464564645645646546; domain=.twitch.tv; path=/; expires=sun, 14-jun-2015 10:29:35 gmt; httponly\"],\"x-request-id\":\"lostsofstringsstuffhere\",\"x-runtime\":\"0.4036...

regex - Can't figure out the format this file is expecting to read -

i've got block of perl supposed read static file irc hostmask, privilege level , comment. between perl (which i'm certified novice in) , regex i'm having trouble creating file. sub read_users { @users = (); open config, "<", "users"; while (my $line = <config>) { next if $line =~ /^\s*#/; ($mask, $level, $comment) = split /\s+/, $line, 3; push @users, [$mask, $level]; } close config; } the file reads: <config> irc.hostmask.goes.here 500 comment that isn't working. see mentions word users , regex omits whitespace. i've grumbled on enough , tried various formulations no luck. ideas? each line of file must either: a comment (which ignored), consisting of optional whitespace, # , , arbitrary text a "mask", "level", , "comment", separated whitespace, no leading whitespace before mask. mask , level cannot contain whitespace, though c...

ruby on rails - Allowing users to select options from a dropdown -

my app allows users create profiles , enter information (description, name, etc..). i'd them able select language dropdown , have choice saved record in user table. i understand have have separate languages table, language_id field on profile table , using options_from_collection_for_select create actual dropdown. my question need model/controller files make work? you need define model named language , table responsible storing languages. think: have 1 field named language of type string. rails g model language language:string # though don't need ':string' part in app/models/language.rb: class language < activerecord::base has_many :users end now, need add language_id users table, , run following migration: rails g migration add_language_id_to_users language:references and update user model accordingly: class user < activerecord::base belongs_to :language # other code end and then, form , need send language_id when pa...

optaplanner - How do you create a Collection of GenuineVariableDescriptors? -

i'm trying implement own movelistfactory , don't know how access / create variable descriptors move want instantiate. createmovelist method (from movelistfactory interface) takes single argument of instance of solution class. can access planning variables need create chainswapmove . i'm unsure how create first argument chainswapmove constructor requires (e.g. collection<genuinevariabledescriptor> ). example in documentation doesn't shed light on process since custom move used in nqueens example doesn't require collection of genuinevariabledescriptors . i've not come across examples of how can access these information contained in solution object. anything ending *descriptor very internal api , not kind of classes want users using. docs presume build own move (which difficult indeed build valid move on chained variables leaves chain in valid state). that being said, here's clue: innerscoredirector.getsolutiondescriptor().getentityd...

python - multiprocessing in iPython: too many files open when I'm not opening any files? -

i have ipython notebook running multi-threaded , have changed on try , run on multiple processors. there substantial amount of code won't quote here unless thinks helpful @ specific portion of it. gist of i'm trying wrap load balancer around pyopencl need feed multiple independent queues-- partly solve specific problem (particle simulation) , partly learning exercise. at no point intentionally opening files, yet it's crashing error: traceback (most recent call last): file "//anaconda/lib/python3.4/site-packages/ipython/core/interactiveshell.py", line 3035, in run_code file "<ipython-input-23-d29c87aba720>", line 1, in <module> co.convergestep(mags[3]) file "<ipython-input-17-0eac43f0bbbf>", line 62, in convergestep evt=self.nlb.qtask(evtlist,(b,k),b.forces,k,out=b.forceaccum,out2=k.forceaccum,sum=true) file "<ipython-input-13-0f26b8ae660e>", line 36, in qtask t=stagingthread(wait...

php - Laravel Artisan CLI doesn't execute commands -

the problem i'm facing laravel's (v4.2) artisan cli when try execute command (for instance php artisan list ) command doesn't work , instead contents of illuminate\foundation\application object in command window. screenshot you're question vauge. if you're asking how add custom commands laravel's artisan, missing last step. if have created command via: php artisan command:make customcommand --command=custom:command then last step need register command : artisan::add(new customcommand);

c# - Check if input matches in list -

i have used 2 list, , not sure method use print input. want show months first, let user choose 1 month , show days. class program { static void main(string[] args) { console.writeline("choose month: "); console.readline(); list<int> list = new list<int> { 31, 28, 31, 30, 31, 30, 31, 31, 30, 30, 30, 31 }; list<string> manad = new list<string> { "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december" }; string inmat; inmat = console.readline(); if (inmat == 31) ; { console.writeline(manad[0] + " " + list[0]); console.readline(); } } } } with 2 lists better use dictionary...

node.js - How to build Restful API without using frontend javascript -

i have been searching on tutorial make restful api without using frontend javascript no avail. new javascript/ web-development , have been doing many tutorials , mini projects myself acquainted it. this test job @ startup looking entry level developer. requirements different want me use in house build apis. what looking on how started building restful api using node.js, express, mongo , without using frontend javascript. thanks. recommendations tutorials don't make questions stack overflow, might want take @ following books. helped me out quite bit when getting started node: express web application development advanced express web application development restful web api design node.js as others have commented, re presentational s tate t ransfer api implemented server-side. consume such api client-side using javascript, not build 1 on client-side. express popular web framework node, , can use build apis, might take @ restify . hope helps out.

Editing Ini Files In Visual C# -

i trying use edit ini, cannot seem code add section of ini file richtextbox. if (myini.getsection(string.format("[{0}]", combobox1.selecteditem.tostring().toupper())) != null); { mysection = new inifile.inisection(myini, string.format("{0}", combobox1.selecteditem.tostring().toupper())); foreach (inifile.inisection.inikey key in mysection.keys) { richtextbox1.appendtext(string.format("{0}={1}{2}", key.name, key.value, environment.newline)); } } i don't know wrong code. you can use old existing ini calls windows: [system.runtime.interopservices.dllimport("kernel32")] static extern int getprivateprofilestring(string section, string key, string def, stringbuilder retval, int size, string filepath); [system.runtime.interopservices.dllimport("kernel32")] static extern long writeprivateprofilestring(string section, ...

Choosing the perfect data structure for the below data in java -

i have choose 1 data structure need below explaining conditions there following values abc,def,rty,ytr,dft map row r1b1 (actully key combination of r1+b1) abeerc,dfffef,rggty map row r1b2 (actully key combination of r1+b2) key value abc,def,rty,ytr,dft ---> r1b1 abeerc,dfffef,rggty ---> r1b2 now, example, let's say, if ytr able retrieve r1b1 or, let's say, value rggty able retrieve r1b2 now case matters of search, complexity , time taken things have go in sequence for example, first pick first line search ytr , first match abc not match have match def not again match match rty not match match ytr , find key r1b1 finally similarly if second string need searched lets rggty scan first row in not find value search continue second row , in second row in third element rggty element retrieve r1b2 value let's say, if put thing in map sequence search go on key , able find corresponding value folks please advis...

components - VHDL OR logic with 32 bit vector -

zero <= result_i(31) or result_i(30) or result_i(29) or result_i(28) or result_i(27) or result_i(26) or result_i(25) or result_i(24) or result_i(23) or result_i(22) or result_i(21) or result_i(20) or result_i(19) or result_i(18) or result_i(17) or result_i(16) or result_i(15) or result_i(14) or result_i(13) or result_i(12) or result_i(11) or result_i(10) or result_i(9) or result_i(8) or result_i(7) or result_i(6) or result_i(5) or result_i(4) or result_i(3) or result_i(2) or result_i(1) or result_i(0); how can make shorter? i assuming using std_logic / std_logic_vector types. can use or_reduce ieee.std_logic_misc . library ieee; use ieee.std_logic_misc.or_reduce; ... 0 <= or_reduce(result_i); or write own function: function or_reduce(vector : std_logic_vector) return std_logic variable result : std_logic := '0'; begin in vector'range loop result := result or vector(i); e...

elisp - In Emacs theme definition, why are there structures like (t (:background "black")) -

Image
why theme definitions contain structures (t (:background "black")) ? role of t ? the sexp ((t (:foreground ... ))) face specification described here: http://www.gnu.org/software/emacs/manual/html_node/elisp/defining-faces.html in short, alist of form (display . plist) , hence in code t corresponds display , (:background... ) plist . plist property list of face attributes, , i'm not going talk since it's not relevant question. however, display can take other values t . aforementioned documentation describes display as: the display part of element of spec determines terminals element matches. and value t means: this element of spec matches terminals. however, more selective , define face attributes apply terminals, instance support color.

sql - Is it possible to reject excessively large queries on specific views? -

i'm working ms-sql server, , have several views have potential return enormous amounts of processed data, enough spike our servers 100% resource usage 30 minutes straight single query (if queried irresponsibly). there absolutely no business case in such huge amounts of data need returned these views, we'd lock down make sure nobody can dos our sql servers (intentionally or otherwise) querying these particular views without proper where clauses etc. is possible, via triggers or method, check where clause etc. , confirm whether given query "safe" execute (based on thresholds determine), , reject query if doesn't meet our guidelines? or can configure server reject given execution plans based on estimated time-to-completion etc.? one potential way reduce overall cost of queries coming group of people use resource governor. can throttle how cpu and/or memory used particular user/group. effective if have "wild west" kind of environment u...

Entity Framework Migration: .resx Snapshot vs __MigrationHistory table -

following question entity framework migration: why ignore snapshot , take __migrationhistory account? , i'm confused why ef migrations stores previous model both in db inside __migrationhistory table , in resource files? , more confused why ignore resources , consider table data calculate model changes?

c# - Waiting without Sleeping? -

what i'm trying start function, change bool false, wait second , turn true again. i'd without function having wait, how do this? i can use visual c# 2010 express. this problematic code. trying receive user input (right arrow example) , move accordingly, not allow further input while character moving. x = test.location.x; y = test.location.y; if (direction == "right") { (int = 0; < 32; i++) { x++; test.location = new point(x, y); thread.sleep(31); } } } private void form1_keydown(object sender, keyeventargs e) { int xmax = screen.primaryscreen.bounds.width - 32; int ymax = screen.primaryscreen.bounds.height - 32; if (e.keycode == keys.right && x < xmax) direction = "right"; else if (e.keycode == keys.left && x > 0) direction = "left"; else ...

Is there a way with Grunt to automatically link css files to HTML -

i wondering if there way automatically link css files html. example give files (dependencies) path , automatically stylesheet link specific html file. thank you if css in bower package, can use grunt-wiredep : include <!-- bower:css --> <!-- endbower --> in html, , wiredep replace links css bower packages. if css own, far know there nothing of sort.

Transform a multidimensional array in php -

this loop $demo = array(); for($i=0;$i<count($big_array);$i++){ echo 'page['.$i.'][0]: '.$big_array[$i][0].'<br>'; for($j=1;$j<count($big_array[$i]);$j++){ echo 'email['.$i.']['.$j.']: '.$big_array[$i][$j].'<br>'; $demo[$big_array[$i][$j]][] = $big_array[$i][$j-1]; //something not ok } } gives me this: page[0][0]: http://www.example.com/impressum email[0][1]: sales@example.com email[0][2]: support@example.com page[1][0]: http://www.example.com/termsofuse email[1][1]: support@example.com email[1][2]: terms1@example.com email[1][3]: terms2@example.com email[1][4]: ad2@example.com page[2][0]: http://www.example.com/adpolicy email[2][1]: support@example.com email[2][2]: ad1@example.com email[2][3]: ad2@example.com email[2][4]: ad1@example.com how can transform result: sales@example.com http://www.example.com/impressum support@example.com http://www.example.com/impressum ...

haskell - Test several functions with the same list of value with quickCheck -

is possible quickcheck perform tests on several function same list of value aim of making benchmark on these function ? for example, prop_test1 prop_test2 prop_test3 checked same list of arbitrary values. quickcheckwithresult args prop_test1 quickcheckwithresult args prop_test2 quickcheckwithresult args prop_test3 if don't insist on using quickcheck, smallcheck might way go. it's quickcheck (bounded) exhaustive checks , produce same test values (when used same parameters).

mysql - specify updated record ID after $_POST in php -

i have page in php multiple row, @ right side of each row there save button, after editing row when click on save how post specified record id page update record on mysql. thank you when creating table in "page" means of php can take care create each row html form , define "save" button submit button. clicking button result in form getting sent request. another approach use javascript this: can add handler function click event of button. inside handler know button (so row) has been clicked , can use selector gather vallues row. can make either post request script, or, more elegant, make background ajax request. allow confirm success of save action without having reload whole page. many examples both approaches can found here on stackexchange or simple google search. php documentation starting point: http://php.net/manual/en/tutorial.forms.php

Force close webdriver despite of any alerts -

is there way force close webdriver inspite of alerts present? know can close alerts using alert api, issue don't know other situations may cause webdriver blocked. at present hangs on alert dialog , driver.close() not close it. need sure way close webdriver inspite of present may cause block. use driver.quit() instead of driver.close() such scenarios.

iOS 8 didReceiveAuthenticationChallenge not getting called for WKWebView Objective C -

i new ios development. have project have use wkwebview instead of uiwebview. simple webpage javascript objective-c , other way round integration. working fine except when try open server self-signed certificate. on safari shows dialog box can choose continue. on application cannot bypass this. for reason have run self-signed certificate. the delegate method didreceiveauthenticationchallenge never called. other delegate methods working fine. know didreceiveauthenticationchallenge depreciated in ios8 can please tell me workaround this. newbie complete working delegate method and/or other changes in code highly appreciated. nsurl *url = [nsurl urlwithstring:@"https://mywebsite.com/default.aspx"]; nsurlrequest *request = [[nsurlrequest alloc] initwithurl:url]; [[self webview] loadrequest:request]; } // , delegate method not getting called - (void)webview:(wkwebview *)webview didreceiveauthenticationchallenge:(nsurlauthenticationchallenge *)challenge complet...

java - int level is not showing in the SMS -

am creating project sends vale of battery sms when activity oepend,but sms received value 0 , not batter percentage can u private void getbatterypercentage() { broadcastreceiver batterylevelreceiver = new broadcastreceiver() { public void onreceive(context context, intent intent) { context.unregisterreceiver(this); currentlevel = intent.getintextra(batterymanager.extra_level, -1); final int scale = intent.getintextra(batterymanager.extra_scale, -1); level = -1; if (currentlevel >= 0 && scale > 0) { level = (currentlevel * 100) / scale; } batterypercent.settext("battery level remaining: " + level + " thanks"); } }; edittext phonenumber =(edittext)findviewbyid(r.id.phone_number); string phonenumbers = phonenumber.gettext().tostring(); intentfilter ba...

postgresql - Set encrypted postgres password without entering it as SQL -

this question has answer here: creating user encrypted password in postgresql 2 answers i set postgres db on server, logged in postgres (peer method), created user , want set encrypted password new user. the tutorials find say, can change password by: alter user other_user encrypted password 'passwd'; but not feel enter password clear sql console. saved in history, , can see it. is right way set password in postgres? i have ~/.pgpass in home : localhost:5432:*:postgres:123456 and query file password.txt : alter user other_user encrypted password 'passwd'; and run command: psql -u useradmin -h localhost -w -a -e -f password.txt remember: rm .psql_history

php - Can i get XML values where XML value is greater than some number? -

i getting xml feeds xml soccer feeder , i want select values xml feed id greater last id database ... how can that? there linq in .net can select condition? i know phplinq , there better idea without framework ? something this: $fixtures= $this->soccer->getfixturesbydateinterval( array("startdatestring"=>$start,"enddatestring"=>$end))->match->id->where(match->id > $number); this few feeds var_dump $fixtures without match->id->where etc... object(simplexmlelement)[5] public 'match' => array (size=11) 0 => object(simplexmlelement)[6] public 'id' => string '348257' (length=6) public 'date' => string '2015-06-19t00:00:00+00:00' (length=25) public 'league' => string 'brasileirao' (length=11) public 'round' => string '8' (length=1) public 'hometeam' => string 'figueirense...

javascript - How to change checkbox follow JSON string? -

i want change checkbox follow json string . don't know how . me json string, "1" mean checked , "0" mean unchecked [{"group_product":"g04","orange":1,"banana":0,"apple":1,"candy":0,"food":1}] and html code. <table id=table_product> <tr><td><input type="checkbox" class="checkbox1" id="orange" name="check[]" />orange</td></tr> <tr><td><input type="checkbox" class="checkbox1" id="banana" name="check[]" />banana</td></tr> <tr><td><input type="checkbox" class="checkbox1" id="apple" name="check[]" />apple</td></tr> <tr><td><input type="checkbox" class="checkbox1" id="candy" name="check[]" />candy</td></t...

uitableview - Table View UI error: Swift -

on last question asked code error in animal table view project, finished initial coding, ui turned strange. missing first letter of each animal name , table view prototype cell. example, amel should camel , hinoceros should rhinoceros. bug code here? import uikit class animaltableviewcontroller: uitableviewcontroller { var animalsdict = [string: [string]] () var animalselectiontitles = [string] () let animals = ["bear", "black swan", "buffalo", "camel", "cockatoo", "dog", "donkey", "emu", "giraffe", "greater rhea", "hippopotamus", "horse", "koala", "lion", "llama", "manatus", "meerkat", "panda", "peacock", "pig", "platypus", "polar bear", "rhinoceros", "seagull", "tasmania devil", "whale", "whale shark", ...

common lisp - Hunchentoot handler changes the definition of another function -

i wrote code manage postgresql database, , working on console. wish put on internal network via hunchentoot. i use clsql , packaged database code as: (defpackage :my-database (:use :common-lisp) (:documentation "several lines...") (:export almost-all-functions...)) (in-package #:my-database) (defun new-patient (name gender height weight) "adds new patient db. parameters of type string." (let* ((height (parse-integer height)) (weight (parse-integer weight)) (corrected-weight (calculate-corrected-weight height weight gender))) (clsql:insert-records :into 'patients :attributes '(height weight corrected-weight name gender patient-at-ward) :values (list height weight corrected-weight name gender t)))) i imported my-database package, , when use handler: (define-easy-handler (debug :uri "/debug") (name gender height weight) (let ((ad (substitute #\space #\+...

swift - No delegate, didFailToReceiveAdWithError -

Image
i have code: class viewcontrollergame: uiviewcontroller, adbannerviewdelegate { var bannerview:adbannerview! override func viewdidload() { super.viewdidload() self.candisplaybannerads = true bannerview?.delegate = self bannerview?.hidden = true } func bannerviewdidloadad(banner: adbannerview!) { bannerview?.hidden = false } func bannerviewactionshouldbegin(banner: adbannerview!, willleaveapplication willleave: bool) -> bool { return willleave } func bannerview(banner: adbannerview!, didfailtoreceiveadwitherror error: nserror!) { bannerview?.hidden = true } } but goes not in didfailtoreceiveadwitherror, when app goes in standby error: adbannerview: unhandled error (no delegate or delegate not implement didfailtoreceiveadwitherror:): error domain=aderrordomain code=1 "service session terminated. how can fix this? it seems you've implemented methods they're never called because banner delegate not set. if ...

c# - Dynamically add button at certain position -

i want dynamically add buttons in loop after specific text. have site questions , answer , want have 'vote best answer' button each question. consider following: for (int = 0 ; < num_of_answers ; i++) { //print answer...done //add button mark best... how? } it can lead script, point is, when button added, goes bottom of page , not near question want it. know how add button, how position want it? it not idea make controls dynamically in asp.net because of hard or in complex cases impossible handle events . instead can use repeater control. here examples msdn - repeater document c-sharpcorner i can make example if want.

javascript - Changing color of each row with jQuery dialog .append -

i building application allow adding tasks list , changing colour of them according selections made. i using build list of items, how achieve http://s4.postimg.org/npplicbnh/2222.png here .append code @narawa games helped me with. @ moment whenever new item added changes color of every other item added before same color. want able have different items in different colors. if ( valid ) { $( "#tasks2 tbody" ).append("\<div class='tasklist'><ul class='taskscreen2'><tr>" + "<td><h1>" + type.val() + "</h1></td>" +"<td class='title'><h3>" + title.val() + " </td>" +"<td>" + wordcount.val() + "</h3></td>" +"<td><p>" + description.val() + "</p></td>" + "<td>" + deadline.val...

c# - LINQ search query doesn't work -

i'm trying write search query in linq. below condition. where (!string.isnullorempty(namewithinitials) && tb.namewithinitials.contains(namewithinitials)) && (!string.isnullorempty(studentregno) && tbsr.studentregistrationno.contains(studentregno)) && (!string.isnullorempty(nic) && tb.nic.contains(nic)) && (!string.isnullorempty(fullname) && tbi.name.contains(fullname)) it doesn't return values if pass single parameter. example if pass 'chamara' fullname doesn't return result if pass parameters @ once returns matching records. i need work when pass several parameters dynamically you using , ( && ) everywhere, if @ least 1 of these conditions false, where condition false. try using or conditions instead: where (string.isnullorempty(namewithinitials) || tb.namewithinitials.contains(namewithinitials)) && (string.isnullorempty(studentregno) || tbsr.studentregistrat...

angularjs - how to synchronize countdown timer to all user -

i developing countdown timer app. user can register app , share own countdown timer; however, have problem here, how let user synchronize same countdown timer? use angular , nodejs + mongodb develop app. problem countdown timer running angularjs 1 user can see running timer, other people can't. should update every second number in database , query every second or running timer in backend? any suggestion ? i'd way: when timable action occurs server-side, store both start time and end time in database. upon page load, both numbers pulled client, figures out delta , starts own local countdown. gui can optionally show server-side end time, "time of record."

ruby on rails - Using a 'default' trait in FactoryGirl to avoid unnecessary association creation -

is possible define default trait in factorygirl? if define factory (where both question_response belongs_to question): factory :question_response question work_history trait :open question { factorygirl.create :question, question_type: 'open' } end end when factorygirl.create :question_response, :open first create default question , create inside trait, unnecessary operation. ideally i'd this: factory :question_response work_history trait :default question { factorygirl.create :question, question_type: 'yes_no' } end trait :open question { factorygirl.create :question, question_type: 'open' } end end and doing factorygirl.create :question use default trait, doesn't seem possible. when factorygirl.create :question_response, :open first create default question , create inside trait it's not true. if specify trait question , overwrite factory behavior before creation not create default ques...

r - geom_vlines multiple vlines per plot -

Image
how can ggplot produce similar library(ggplot2) library(reshape2) library(ecp) synthetic_control.data <- read.table("/path/synthetic_control.data.txt", quote="\"", comment.char="") n <- 2 s <- sample(1:100, n) idx <- c(s, 100+s, 200+s, 300+s, 400+s, 500+s) sample2 <- synthetic_control.data[idx,] df = as.data.frame(t(as.matrix(sample2))) #calculate change points changep <- e.divisive(as.matrix(df[1]), k=8, r = 400, alpha = 2, min.size = 3) changep = changep$estimates changep = changep[-c(1,length(changep))] changepoints = data.frame(changep,variable=colnames(df)[1]) for(series in 2:ncol(df)){ changep <- e.divisive(as.matrix(df[series]), k=8, r = 400, alpha = 2, min.size = 3) changep = changep$estimates changep = changep[-c(1,length(changep))] changepoints = rbind(changepoints, data.frame(changep,variable=colnames(df)[2])) } this interesting part plot: df$id = 1:nrow(df) dfmelt <- reshape2::melt(df, id.vars ...

Python Networking -

so have create socket , using function socket.bind() , keep on getting following error: 1 usage of each socket address (protocol/network address/port) permitted here code: import socket s = socket.socket() host = socket.gethostname() port = 12345 s.bind((host, port)) s.listen(5) while true: c , addr = s.accept() print('thank connecting to', addr) c.send('hello , connecting') c.close() the port / ip combination bound already. can not bind again. should check if other instance of program still running. if not, use other port.

xml - (//.) Expression in XPath -

i have little problem in getting xpath expression result ! let's have little xml file : <bookstore> <book> <title lang="en">learning java</title> <price>29.99</price> </book> <book> <title lang="en">learning xpath</title> <price>39.95</price> </book> </bookstore> what result of : //book[//.='lear'] thank what result of : //book[//.='lear'] you can dump xml sample , xpath expression in xpath tester , see result (f.e using http://www.freeformatter.com/xpath-tester.html , or whatever like). above xpath , xml sample, result nothing. given particular xml input, above xpath expression same //book[false()] . predicate (content of [] ) evaluate false because there no element containing exact string "lear" . "but can tell me what's useful dot after double slash symbol ?" to answer comment, see...

sql server - PIVOT giving incorrect output when no of columns increase -

Image
i have table channel_merge like channel_1 | channel_2 ---------------------- column1 | column343 column1 | column392 column1 | column267 column1 | column198 column1 | column400 column2 | column348 column2 | column97 column1 | column97 column3 | column343 column3 | column65 column4 | column33 where columnx values ranges between column1 column512 no of rows can vary between 8k 20k , wanted matrix (512x512) value representing number of entries between respective combination of columns in matrix. i broke 512 int groups of 100, process pivot , later append full matrix pivot finction used following pivot query select [column1],[column10],[column100],[column101],[column102],[column103],[column104],[column105],[column106],[column107],[column108],[column109],[column11],[column110],[column111],[column112],[column113],[column114]..100 columns final1 ( select channel_1,channel_1 channel_11,channel_2 channel_merge ) p pivot ( count(channel_11) channel_2 in ([co...