Posts

Showing posts from May, 2010

python - How to separate a tuple with 2 parts into separate lists? -

so have tuple has 2 lists in it: x = (['a', 's', 'd'], ['1', '2', '3']) how make 2 lists? right code looks like: list1.append(x[1]) list1.append(x[2]) list1.append(x[3]) but can't add other 3 items separate list indexes 4, 5 , 6: list2.append(x[4]) list2.append(x[5]) -results in error list2.append(x[6]) how can above make list2? your tuple has 2 elements. reference directly: list1 = x[0] list2 = x[1] or list1, list2 = x this creates additional references 2 lists contained in x , not copies . if need new list objects same contents, create copies: list1, list2 = x[0][:], x[1][:] see how clone or copy list?

xcode - iOS MapView shows entire United States -

Image
i'm trying load region in mapview, view of entire u.s. ipad app runs in landscape mode. i'm thinking spans may not proper dimensions, i'm not sure how fix it. here's data have. ideas? thanks... i've solved similar problem adding cllocationmanager: self.locationmanager = [[cllocationmanager alloc] init]; self.locationmanager.delegate = self; // check ios 8. without guard, code crash "unknown selector" on ios 7. if ([self.locationmanager respondstoselector:@selector(requestwheninuseauthorization)]) { [self.locationmanager requestwheninuseauthorization]; } [self.locationmanager startupdatinglocation];

java - How to create a model, in Spring, from json where the foreign key is referenced as a long attribute? -

one group has many users: group import com.fasterxml.jackson.annotation.jsonignore; import com.fasterxml.jackson.annotation.jsonmanagedreference; import javax.persistence.*; import java.util.collection; import java.util.list; @entity @table(name = "groups") public class group { @id @column(name = "id") private long id; @column(name = "name") private string name; //@jsonmanagedreference @onetomany(mappedby = "group" //, fetch = fetchtype.eager //, cascade = cascadetype.all ) private list<users> itsuser; //getters , setters omitted clarity } users import com.fasterxml.jackson.annotation.jsonbackreference; import com.fasterxml.jackson.annotation.jsonignore; import com.fasterxml.jackson.annotation.jsonmanagedreference; import com.fasterxml.jackson.annotation.jsonproperty; import javax.persistence.*; import static javax.persistence.generationtype.sequence; @entit

ios - `-fembed-bitcode` Error when trying to archive app -

i trying submit new version of 1 of client's apps itunes connect, getting weird error -fembed-bitcode not supported on versions of ios prior 6.0 this first time submitting new version of app using xcode 7, i've submitted new versions of app fine in past xcode 6. bitcode new ios feature supports dynamic recompilation of uploaded binaries support future devices , hardware configurations apple. there option in xcode 7 under build settings > build options called enable bitcode can enabled or disabled app. additionally, there setting in itunes connect apps under pricing , availability > bitcode-auto-recompilation can set app.

wpf - RTF structure when typing -

i have wpf app uses richtextbox control. when i'm typing, don't understand rtf structure appears generate. i'm typing simple phrase (e.g. 3 miles), , result is: {\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 times new roman;}{\f2\fcharset0 segoe ui;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\fs24\f2 {\highlight1\ltrch about 3 }{\highlight1\ltrch miles }{\highlight1\ltrch }{\highlight1\ltrch less }\li0\ri0\sa0\sb0\fi0\ql\par} } } the point see here 3 words (about, 3, miles) appear separately (well, 'about' , '3' appear together, 'miles' not). but other times (i'm not sure it's because type whitespaces after or not), 3 words appear together. could please explain? the control creating unnecessarily long rtf repeating formatting information different words, though words have same format. unless trying mod

ios - watchOS2 and iOS8 connectivity - Swift -

for watchos1 there several limited, efficient methods available sharing data between watch , phone - openparentapp , appgroups , nsuserdefaults . with release of watchos2 , watchconnectivity framework - openparentapp method deprecated, appgroups , nsuserdefaults limited read-only functionality. important note here watchconnectivity supported ios9 devices. but somehow see apps on appstore claiming optimised watchos2 while having ios8 deployment target. am missing something? there other methods available sharing data sufficiently? some user may not have apple watch , may using ios8. support them, can set each deployment target version per each build target. likes these example targets in project: ios app (target: ios 8.x, must set watchconnectivity framework optional) watchos 2 app (target: ios 9.x & watchos 2) -> ios8 user can't install watch app. watchos 2 app exntension (target: ios 9.x & watchos 2) in ios app codes, can check w

r - How do you turn off colored text in testthat? -

i use package colorout color output in r (i don't use rstudio). when running tests in testthat prints out in color interfering colorout package printing lot of color codes. here example of output: r> library(colorout) r> devtools::test() loading mypackage testing mypackage 1;32m.0m1;32m.0m1;32m.0m how can turn off coloring in testthat ? found there option this: options(testthat.use_colours = false)

reactjs - Rendering sub navigation using react router routes and a shared data source -

i have large application switching react-router 1.x. the application has large nested navigation structure. / /page1 /page1/option1 /page1/option2 /page1/option3 /page1/option4 /page1/option4/option1 /page1/option4/option2 /page1/option4/option3 /page2 /page2/option1 /page2/option2 /page2/option3 /page2/option4 etc.. on /page1 sub navigation be: option1 | option2 | option 3 | option 4 and on /page/option4 option1 | option2 | option 3 i have been looking way power sub navigation components off route config, pages need defined in 1 place, far have not been able find example. normal approach such problem, such example exist? update so conceptually i'm thinking along lines of .net sitemap provider , navigation , breadcrumb trail , routing work off hierarchical definition of pages. i'm wondering if route definition react router can source, or can driven different source, , how achieved. <route path="/"

html - Loop through drop down and create separate Outlook email body -

i have dashboard. cell values based on drop down list value (drop down list = name of months). send each dashboard 5 different customers. have loop in code because of customers (for = 1 5), , have loop change email body based on drop down list value. issue email body same - not changing based on drop down value. sub custommailmessage() dim oapp object dim omail object dim rng range dim sig string dim inputrange range sig = readsignature("internal.htm") set rng = thisworkbook.worksheets("sheet2").range("a1:m3") set dvcell = worksheets("sheet2").range("s1") set inputrange = evaluate(dvcell.validation.formula1) each c in inputrange = 1 5 dvcell = c.value set oapp = createobject("outlook.application") set omail = oapp.createitem(0) omail .to = thisworkbook.works

html - Unable to display 3d pdf image on web page -

i want display 3d pdf image on web page not display code <object data="2010nissanaltima.pdf" type="application/pdf" width="630" height="450"></object> pdf 3d annotations not supported pdf readers, have make sure file been rendered adobe acrobat reader instead of 1 of internal pdf reader alternatives provided web-browsers chrome , firefox. see post about change these settings in chrome example: https://superuser.com/questions/735751/chrome-open-pdfs-in-adobe-not-in-the-browser

android - Issue with GGlympseLite.start() -

when creating glympse first time in activity, call start() which required before sendticket() the glympse doesn't show in notifications until after hit send in glympse wizard. great, works. after stopping glympse using normal code given in wrapper class _glympse.stop() _glympse = null it stops. great, works too. now when want show wizard again create new glympse, have call start() before call sendticket() the problem after call start() , before hit "send" in glympse wizard, notification shows in android time remaining on stopped glympse. don't want notification there. how make sure stopped glympse not show in android's notifications when creating new one? i think trouble terminology off. the glympse object started , stopped glympse platform (the services manage location gathering, uploading, etc.) the ticket object gets created , sent out user's location can shared specific period of time. tickets have expire method c

ios - Swift optional type issue -

so i'm new @ swift , ios programming. i'm trying record accelerometer , gyroscope date , display on screen. tutorials managed finish code , kind of understand code. keep getting errors. , if follow suggestion xcode gives me more errors.. so code: import uikit import coremotion class viewcontroller: uiviewcontroller { //instance variables var currentmaxaccelx: double = 0.0 var currentmaxaccely: double = 0.0 var currentmaxaccelz: double = 0.0 var currentmaxrotx: double = 0.0 var currentmaxroty: double = 0.0 var currentmaxrotz: double = 0.0 var motionmanager = cmmotionmanager() //outlets @iboutlet var accx: uilabel? @iboutlet var accy: uilabel? @iboutlet var accz: uilabel? @iboutlet var maxaccx: uilabel? @iboutlet var maxaccy: uilabel? @iboutlet var maxaccz: uilabel? @iboutlet var rotx: uilabel? @iboutlet var roty: uilabel? @iboutlet var rotz: uilabel? @iboutlet var maxrotx: uilabel? @

ruby on rails - How can I convert a snakecased hash into camelcase in javascript -

i'm used work javascript connects rails backend , of time 1 of them has budge accept others formatting rules i.e. snake_case ruby , camelcase javascript. there several methods replace strings between 2 formats, better consider deep replacement of keys in hash in more direct way. i'm giving method worked out me, in cofeescript, if need javascript version of can convert in coffescript site . class converter convertstring: (string)-> #switch needed format string.replace(/(\_[a-z])/g, ($1)-> $1.touppercase().replace('_','')) convertobject: (obj)-> newobj = {} k,v of obj val = if typeof v "object" , not array.isarray(v) @camelizeobject(v) else v key = @camelizestring(k) newobj[key] = val newobj

excel - How to tabulate data from multiple sheets into a PivotTable? -

Image
i have multiple sheets in excel 2010 each containing table of data. sheets represent different types of equipment user, of there hundreds, holding on to. now, way keep track of each user looking @ separate sheets , tedious me. therefore, wanted tabulate them pivottable such when filter specific user, see equipment holding on to. here 1 table sheet called "laptop": and here table sheet called "ip_phone": all layouts same except "laptop" has 6 columns, rest four.

php - Laravel - hasManyThrough and eager loading, get column from related -

i'm getting weird stuff going on when trying eager load related model using hasmanythrough. i have community model has function called 'roommates' users have community id in column called 'community', see below code. public function roommates() { return $this->hasmanythrough('app\user', 'app\community', 'id', 'community'); } then user model grabbed auth after login , eager loads related models, , displaying columns want. id, name, email $user = user::where('id', auth::id())->with(['community.roommates' => function ($query) { $query->select('users.id', 'name', 'email'); }])->first(); however json response isn't expected, id being returned appears id of community, though have specified 'users.id' { "status": true, "data": { "id": 3, "name": "foo bar", "

postgresql - Postgres: query schedule given day, time_of_day, and time zone name -

i'm writing "send me messages @ time" app. i'm storing recurrence information in manner: schedules ---------- days_of_week: [3, 4, 5] hours_of_day: [8, 13, 22] time_zone: "pacific time (us & canada)" works fine in displaying, need write frequent cron job grabs schedules "right (utc)". so, if the cron job running @ 09:00 utc monday, need grab schedules monday in days_of_week ( where days_of_week @> array[1] ) hours_of_day @ 09:00 utc. given hours_of_day stored array of integers, storing user's time_zone. so user may say: "deliver me message @ 9am monday" (which store [9]), means 9am in their time zone. questions: any way query schedules given these parameters? if not, there better way structure data ensure easier querying through postgres? schema flexible. thanks in advance! postgres has superb facilities working timezones, , i've written similar you're asking here using at time zone

c# - Entity Framework resetting int values to 0 on inherited object -

Image
i've been 4 hours trying find out i'm doing wrong tpt hierarchy, it's been big pain in neck. i have base class: public partial class registry { public int id_audit{get;set;} public string cud{get;set;} //key value public bool canceled{get;set;} public virtual icollection<articles> articles {get;set;} public virtual icollection<paid> paids {get;set;} //other base properties } public partial class sale : registry { public int idsale{get;set;} } public partial class cuote : registry { public int idcuote{get;set;} public int consec{get;set;} public int modification{get;set;} //other cuote properties } at runtime interacts registry object until it's decided object going be: sale or cuote , made extension class export base class derived class public partial class registry { public sales tosale() { sale r = new sale { canceled = this.canceled, cu

php - The form's view data is expected to be an instance of another class error creating form instance of another entity -

i following error when trying create form entity pass through view. i have 2 entities in context courseguide , courseguiderow , pass through form view of courseguiderowtype view - how can this? the form's view data expected instance of class crmpicco\coursebundle\entity\courseguide, instance of class crmpicco\coursebundle\entity\courseguiderow. can avoid error setting "data_class" option null or adding view transformer transforms instance of class crmpicco\coursebundle\entity\courseguiderow instance of crmpicco\coursebundle\entity\courseguide. this controller: // courseguidecontroller.php public function viewaction(request $request) { if (!$courseid = $request->get('id')) { throw new notfoundhttpexception('no course id provided in ' . __method__); } $resource = $this->get('crmpicco.repository.course_guide_row')->createnew(); $form = $this->getform($resource); // ... } m

java - After getting latetest update of testng (6.9), not able to run testng.xml -

i updated testng plugin in eclipse ide, after not able execute testng.xml, able execute test case separately testng. notes: submitted issue eclipse dev team. please let me know if have other way solve issue. eclipse versions: mars (4.5) platform support: windows -64 bit java- 1.8.0.60-b27 do folowing delete existing testng plugin restart eclipse go install new software , add: http://beust.com/eclipse-old/eclipse_6.9.5.201508210528/ install version of plugin. restart eclipse check if works expected. in case solved problem.

c# - Cannot create StorageItem in Outlook Add-In -

Image
i'm trying run code: this.storage = application.session.getdefaultfolder(outlook.oldefaultfolders.olfoldercontacts) .getstorage("ws_up_storage", outlook.olstorageidentifiertype.olidentifybymessageclass); it runs on machines, on others throws exception: i tried other folder names, olfolderinbox , olfoldercalendar . i've looked @ microsoft docs this, , says error expected if folder 1 of following: the folder microsoft exchange public folder, internet message access protocol (imap), msn hotmail, or microsoft sharepoint foundation folder. the user permission folder read-only. the store provider not support hidden items. the sad fact is, not know how check 1 of these true , if it's @ possible. how go determining cause of problem , addressing it? the error 0x80040102 mapi_e_no_support, means store not support hidden (associated) items. read pr_mdb_provider property (dasl name http://schemas.microsoft.com/mapi/prop

web scraping - Perl Scrappy select using class attribute -

i trying scrape using perl scrappy . select html elements class attribute using 'select'. <p> <h1> <a href='http://test.com'>test</a> <a href='http://list.com'>list</a> </h1> </p> <p class='parent-1'> <h1> <a class='child-1' href="http://sample.com">samplelink</a> <a class='child-2' href="http://list.com">list</a> </h1> </p> i need element('a' tag) class name 'child-1' child nod of <p class='parent-1'> using select method. i have tried this #!/usr/bin/perl use scrappy; $scraper = scrappy->new; $scraper->get($url); $scraper->select('p a')->data; but select first 'p' tag also. could please me this? bearing in mind choroba's warning , select <a> element class of child-1 child of <p> element class of pare

java - How do you create and render a 3D Fractal? -

so i've been assigned recursive art project ap cs class , have bunch of spare time, i've decided try little bit more ambitious. my plan create 3d fractal , either rendered , shaded in visualization gl, or represented via spatially mapping respective equations' outputs points on cube , drawing those. if explanation seems unclear, please check out links @ bottom images. now, don't need fractal able modified in-program. need render single bufferedimage, i'll putting directly on jframe. my experience in java, far project goes, bit limited. i've drawn mandelbrot , julia set fractals before, i have little no experience drawing/rendering objects in 3d in java. stuff can , figure out myself though, no worries here. thus, question: how 1 map fractal should in 2nd dimension (e.g. log(no. of subdivided entities)*log(side length of subdivision) = 2) to 3rd dimension (e.g. log(no. of subdivided entities)*log(side length of subdivision) = 3)? i'm lost trying

c# - PerformanceCounter - Custom counters file view is out of memory -

while doing load testing on our .net win32 application, ran exception: system.typeinitializationexception: type initializer 'myclass' threw exception. ---> system.invalidoperationexception: custom counters file view out of memory. @ system.diagnostics.sharedperformancecounter.calculatememory(int32 oldoffset, int32 totalsize, int32& alignmentadjustment) @ system.diagnostics.sharedperformancecounter.createinstance(categoryentry* categorypointer, int32 instancenamehashcode, string instancename, performancecounterinstancelifetime lifetime) @ system.diagnostics.sharedperformancecounter.getcounter(string countername, string instancename, boolean enablereuse, performancecounterinstancelifetime lifetime) @ system.diagnostics.sharedperformancecounter..ctor(string catname, string countername, string instancename, performancecounterinstancelifetime lifetime) @ system.diagnostics.performancecounter.initializeimpl() @ system.diagnostics.performancecounter..cto

rust - Allowing both static variables and boxes as a function argument? -

i have struct, instantiate statically, , i'd users allocate on heap. possible allow both in arguments function? pub struct mydata { x: i32 } static allocated_statically: mydata = mydata {x: 1}; // should signature be? fn use_data(instance: box<mydata>) { println!("{}", instance.x); } fn main () { use_data(box::new(mydata{x: 2})); // doesn't work use_data(allocated_statically); } in both instances, can pass pointer function. pub struct mydata { x: i32 } static allocated_statically: mydata = mydata { x: 1 }; // should signature be? fn use_data(instance: &mydata) { println!("{}", instance.x); } fn main () { use_data(&box::new(mydata{ x: 2 })); use_data(&allocated_statically); } note in both cases, caller needs use & operator take address of value. in first call, operator yields &box<mydata> , compiler automatically converts &mydata because box implements deref t

python - Pixelated fonts when plot is saved as jpeg -

Image
when save matplotlib figure jpeg tick fonts pixelated. i'm not sure going on or if there hack fix this. have insight? %matplotlib nbagg import matplotlib.pyplot plt import numpy np x = np.linspace(-1.2,1.2,1000,endpoint=true) y = np.copy(x) x,y = np.meshgrid(x,y) z = -x**2 + y**2 - y**3 fig = plt.figure() ax = fig.add_subplot(111) cs = plt.contour(x,y,z, [0,-0.1,0.1], colors=['black','blue', 'gray']) plt.clabel(cs, fontsize=14, inline=1, fmt='%1.1f', manual=[(-0.15,0), (-0.4,0), (0.25,0.5)]) plt.savefig('plot.png', format='png') plt.savefig('plot.jpg', format='jpg') plt.savefig('plot.tiff', format='tiff') here plot.png: here plot.jpg: here plot.tiff: i believe related previous question had: anti-aliased fonts in animations as noted above, situation appears dependent on backend used. can avoid issue using: import matplotlib matplotlib.use('webagg') as

flannel - kubernetes install on ubuntu close connection in deploying -

when installing kubernetes on 3 ubuntu14.04 node,it going deploying , stopped. had 3 nodes of cluster: 172.25.2.31 ukub01 172.25.2.32 ukub02 172.25.2.33 ukub03 , followed document install: http://kubernetes.io/v1.0/docs/getting-started-guides/ubuntu.html config-default.sh setting is: export nodes=${nodes:-"root@ukub01 root@ukub02 root@ukub03 "} role=${role:-"ai i"} export num_minions=${num_minions:-3} export service_cluster_ip_range=${service_cluster_ip_range:-172.25.3.0/24} export flannel_net=${flannel_net:-172.16.0.0/16} deploying messages: root@ukub01:/opt/kubernetes/cluster# kubernetes_provider=ubuntu ./kube-up.sh ... starting cluster using provider: ubuntu ... calling verify-prereqs identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa) ... calling kube-up deploying master , node on machine ukub01 make-ca-cert.sh 100%

python - Using Custom User DB Structure in Mysql for Django 1.8 -

i have question regarding table structure user if extending functionalities, using mysql database. given models.py file class libraryuser(models.model): user_id = models.onetoonefield(user) is_catalogue_subscriber = models.integerfield(default=1) is_research_subscriber = models.integerfield(default=1) library_membership_number = models.charfield(max_length=64) i have table structure sql create table library_user( user_id int(10) primary key is_catalogue_subscriber integer(1) default 1 is_research_subscriber = integer(1) default 1 library_membership_number = varchar(16) ) so now, when fire server , access accounts in admin page, django throwing error: exception type: operationalerror exception value: (1054, "unknown column 'library_user.id' in 'where clause'") use user = models.onetoonefield(user, primary_key=true) i.e. drop _id in attribute name. in case want define richer user model (i.e. add more attribute

javascript - Toggle Div tag inside a datalist -

<asp:datalist id="dldatalist" runat="server"> <itemtemplate> <p> <h4> <div class="ntitle" id='<%# eval("email_id") %>'> <asp:label id="label30" runat="server" text='<% #eval("departure_country") %>'></asp:label> - <asp:label id="label31" runat="server" text='<% #eval("arrival_country") %>'></asp:label> </div> </h4> </p> <div class="ncontent" id='d<%# eval("email_id") %>'> <asp:label id="label32" runat="server" text="company name" width="250px"></asp:label> <asp:l

ios - Remove duplicates from NSMutableArray of NSDictionary depending on value of key -

i have nsmutablearray of, say, 10 nsmutablearrays . each of these nsmutablearrays contains different number of nsdictionary objects have made model class. data api response. first time make api call, response whole data. on, when api call made, returns data modified. when new data api response, contains data in array of dictionaries slight modifications. model class's structure below: subcategory.h @interface subcategory : mtlmodel <mtljsonserializing> @property (nonatomic, retain) nsstring *subcategoryid; @property (nonatomic, retain) nsstring *subcategoryname; @property (nonatomic, retain) nsstring *status; @end json object returned this: { "sub_category" = ( { id = 55ed48123; name = "sub category 1"; status = 1; }, { id = 55ed47ed3; name = "sub category 2";

tags - Comma is not working with Bootstrap TagsInput and Bootstrap Typeahead -

i going use bootstrap tagsinput , bootstrap typeahead in 1 of project. when start typing, typeahead show suggestions. if press [enter], add correctly. there problem when type somthing , press [comma button , ] nothing. here input: <input type="text" autocomplete="false" id="tags" name="tags"> js codes: $('#tags').tagsinput({ confirmkeys: [13, 188], typeahead : { afterselect: function(val) { this.$element.val(""); }, displaykey: 'text', valuekey: 'value', source: [ { "value":"test1", "text":"test1" }, { "value":"test2", "text":"test2" } ] }, freeinput: true, itemvalue: 'value', itemtext: 'text', });

Getting phone number from contacts using ContentProvider - Android -

Image
i making small app can contacts of phone using content provider , display them in listview illustrated. i want select row of listview , automically make phone call specific contact. tried things,but don't work. ideas? here code. public class mainactivity extends listactivity implements adapterview.onitemclicklistener{ arrayadapter<string> adapter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); contentresolver cr = getcontentresolver(); cursor c = cr.query(contactscontract.contacts.content_uri, new string[] {contactscontract.contacts.display_name}, null, null, null); list<string> contacts = new arraylist<string>(); if (c.movetofirst()) { { contacts.add(c.getstring(c.getcolumnindex(contactscontract.contacts.display_name))); } while (c.movetonext()); } adapter = new arrayadapter<string>(this, r.layout.activity_main, contac

search within array PHP -

i have array contains data. example --- $data = array( 'category 1' => array( array('id'=> 0, 'name' => 'john', 'category' => 'category1'), array('id'=> 1, 'name' => 'jack', 'category' => 'category1'), array('id'=> 2, 'name' => 'jame', 'category' => 'category1'), ), 'category 2' => array( array('id'=> 0, 'name' => 'mile', 'category' => 'category2'), array('id'=> 1, 'name' => 'mike', 'category' => 'category2'), array('id'=> 2, 'name' => 'matt', 'category' => 'category2'), ) ); now how can write function --- if ($post ='category 1') { // filter name category => category1 } expected output --

php - Laravel check if image path string is image -

i'm passing image path paremeter when link clicked, need check if image security reasons. when try code, $filename '15612.jpg': $filename = $_get['filename']; $image = array('file' => file::get('unverified-images/'.$filename)); $rules = array('file' => 'image'); $validator = validator::make($image, $rules); if ($validator->fails()) { session::flash('error', 'not image'); return redirect::to('controlpanel'); } all .jpg files have tested give 'not image', when try .txt file doesn't give error, why this? i'm guessing im doing wrong, validator supposed fail when it's not image, right? i know validator takes input::file() instead of file::get() , how can use if i'm not using form? this may case of avoiding validator, , doing check yourself, do: $allowedmimetypes = ['image/jpeg','image/gif','image/png','image/bmp','im

php array , how to display array data in email -

$qua1 = "5"; $querynotification= "select * stock stockqty <= :qua1 "; $stmt3 = $conn->prepare($querynotification); $stmt3->bindparam(':qua1',$qua1); $stmt3->execute(); while ($querynotrow = $stmt3->fetch()){ $a=array("qty"=>$querynotrow['stockqty'],"name "=>$querynotrow['stockname'],"cb "=>$querynotrow['stockprice']); // $array[$querynotrow['stockqty']] = $querynotrow['stockname']; foreach( $a $row ): $b = "stockqty = " . $querynotrow['stockqty'] . " , stockname = " . $querynotrow['stockname'] . "<br>"; endforeach; echo $b; } if add send email code inside foreach loop , system send many email according on how many data. how can send data 1 email?? foreach( $a $row ): echo "stockqty = " . $row['qty'] . " , stockname = " . $row['name'] . "<br>&q

php - cakephp 3 using scopes when logging -

i configured logger orders in app.php 'orders' => [ 'classname' => 'cake\log\engine\filelog', 'path' => logs, 'file' => 'orders', 'levels' => ['info'], 'scopes' => ['orders'], ] and in 1 model of mine did: log::info("there's order", 'orders'); i expected log message being written in orders.log shows in debug.log too. according documentation: if there configured logger scope, log messages directed loggers. if log message written unknown scope, loggers handle level of message log message. what doing wrong? as wandering around, found this: https://github.com/daoandco/cakephp-logging to restrict scope 1 logger, add default logger config: 'scopes' => false like this: 'debug' => [ 'classname' => 'cake\log\engine\filelog', 'path' => logs, 'f

How to sync additional fields in pivot table [Laravel 5] -

i need update additional filed user_id in pivot table... tried this: $commet = comment::find(2); $commet->likes()->sync([2,'user_id'=>1]); but filed updated 0 . solution this? i think sync array isn't right. try: $commet->likes()->sync(array( 1 => array('user_id' => 1), 2 => array('user_id' => 5), ... )); ie. sync(array( related_id => array('pivot_field' => value), ... ));

How to resolve this bash python interaction? -

i have 3 files, let's see 1 one. params.conf [a] [b] [c] [d] [e] parsing.py from configparser import safeconfigparser parser = safeconfigparser() parser.read('params.conf') lst=parser.sections() print lst demo.sh #! /bin/bash value=$(python parsing.py) echo "$value" after running demo.sh , should output ['a','b','c','d','e'] , getting that. but, there several problem when going next level. i want use list elements, @ moment need use sed parse within bash file don't want, rather love access list array in bash can use later. currently printing list , can't that. because have multiple list in python file, , can't afford print each of them , retrieve bash. so, can return variable python bash somehow, searching hack source bash file bash file. eventually want have multiple functions in python file , try access particular functions return value bash. can achieve that? rather calling w

javascript - jQuery .text() not working with HTML -

with piece of code below: if (params.showtooltip) { map.label.text(mapdata.pathes[code].name); jquery(params.container).trigger(labelshowevent, [map.label, code]); if (!labelshowevent.isdefaultprevented()) { map.label.show(); map.labelwidth = map.label.width(); map.labelheight = map.label.height(); } } i'm getting things in displayed label: <strong>x name</strong><br>second line<br>third line what need in displayed label: x name second line third line i guess need convert parse map.label.txt html don´t know how it. not 100% sure you're asking, try using .html() instead of .text() . .text() adds whatever string provide plain text inside html element, whereas .html() renders html elements within string.

java - Applicaton has stopped error after create instance of AlertDialog -

i have project classes. one class extends activity has button. oncreate method of class. protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.select_car); /////// codes , behaviors here till arrive @ 1 of methods acts on button. when the button clicked, data inserted db, before want confirmation end user selected corrected or not. first want set positive answer, here did in specific button. choose.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { //i want confirm end user, did final alertdialog.builder builder = new alertdialog.builder(getapplication()); builder.setmessage("are sure this?") .settitle("alert"); builder.setpositivebutton("ok", new dialoginterface.onclicklistener() { @override

public activity - Rails: Public_Activity Gem - uninitialised constant -

i trying make app rails 4. i have installed public_activity gem. i followed ryan bates railscast , took controller based approach, , lighter common option (as opposed tracking model). in activities_controller have: class activitiescontroller < applicationcontroller def index @activities = publicactivity::activity.order("created_at desc") end end in project.rb, have: include publicactivity::common in projects controller, create action, have: @project.create_activity :create, owner: current_user in activity view - index, have: <% activities.each |activity| %> <div class="col-md-4"> <div class="indexdisplay"> <span class="indexheading"> <%= link_to activity.owner.name, activity.owner if activity.owner %> </span> <span class="indexsubtext"> <%= render_activity

Java: BufferedReader lines compared to String issues -

i have program reading text file has list of items, creates arraylist consisting of items reads, compares few chosen words. example, text file contains (without numbering): book desk food phone suit and reads each 1 , adds arraylist. when tried comparing string s = "book" each element in arraylist, find s not equal anything. have in method: for (int = 0; < list.size(); i++) { if (s.equals(list.get(i)) return true; } s.contains() doesn't work either. when print arraylist, there's additional whitespace @ end of each string element. how can comparison work when s = "book"? why there additional whitespace? use trim() remove leading , trailing whitespace. if (s.equals(list.get(i).trim()) return true; } instead of if (s.equals(list.get(i)) return true; }

Django drop downs in model -

i'm providing choices in dropdown in model this: class foodtype(models.model): type = models.charfield(max_length=30, unique=true) def __unicode__(self): return self.type class food(models.model): name = models.charfield(max_length=30, unique=true) type = models.foreignkey(foodtype) def __unicode__(self): return self.name i did rather hardcoded choices because want provide option add/delete/change foodtypes via admin once app deployed. realised once if foodtype deleted food dependent on, food deleted, don't want. want able keep food records unless explicitly want delete one. is there better way still allows user modify foodtypes via admin? thanks :) you can set on_delete parameter of foreignkey field value different cascade (the default value). ex: type = models.foreignkey(foodtype, null=true, on_delete=models.set_null)

angularjs - Angular js , How to upload image using paperclip in Rails API? -

hi trying create application using rails , angular js . here have api marketplace , using gem called paperclip . in general work perfect means in simple rails trying add image using angularjs . here want upload image using paperclip . attaching codes below have done far . here marketplace model : class marketplace < activerecord::base belongs_to :user has_attached_file :image, styles: {large: "600x600",medim: "300x300",thumb:"150x150#" } validates_attachment_content_type :image, :content_type => /\aimage\/.*\z/ validates :name, :tittle, :description, presence: true end and marketplace controller: class marketplacescontroller < applicationcontroller before_filter :authenticate_user!, :except => [:show, :index] #before_action :set_market_place, only: [:show] before_action :marketplace_owner, only: [:edit, :update, :destroy] skip_before_action :verify_authenticity_tok

python - ImportError: cannot import name MongoClient -

i installed , pymongo first time , had trouble. when running example basic python tutorial on mongodb website response: traceback (most recent call last): file "pymongo.py", line 1, in <module> pymongo import mongoclient file "/users/user/documents/tweepy scrapers/pymongo.py", line 1, in <module> pymongo import mongoclient importerror: cannot import name mongoclient the code looks this: from pymongo import mongoclient datetime import datetime client = mongoclient() db = client.test result = db.restaurants.insert_one( { "address": { "street": "2 avenue", "zipcode": "10075", "building": "1480", "coord": [-73.9557413, 40.7720266] }, "borough": "manhattan", "cuisine": "italian", "grades": [ {

rest - AngularJS DELETE with Tomcat causes 405 Request method 'DELETE' not supported -

i'm using spring data neo4j rest backend served on tomcat (8.0.27) angular frontend, served locally @ http://localhost:8080/ . when try delete record either $http.delete() or $resource().delete(), tomcat returns 405 not supported error. however, using $http({method: 'delete', url: '/competitors/13'}) works fine. unfortunately, not allow me use angular $resource service instead of $http, goal. (as aside, put creates same 405 response delete) i able use delete command line. works fine: curl -x delete http://localhost:8080/competitors/13 i have disable csrf in websecurityconfig in case has it. i have added readonly init-param web.xml try force tomcat accept delete, so: <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>pr