Posts

Showing posts from August, 2013

On my Website in PHP, Check if user liked my Facebook page -

if visitor website logged facebook, want check if have 'liked' facebook page. if not want ask them 'like' (e.g. via overlay popup). don't want prompt request users have 'liked' page. of course point check 'in background' without asking users extended permissions, if wanted user use app. i have found several references on how accomplish via facebook's php sdk, seems referring older version of sdk, , no longer work. i total n00b when comes stuff. i've been able manage setup sdk environment: require_once 'src/facebook/autoload.php'; //create facebook service $fb = new facebook\facebook ([ 'app_id' => '-----------------', 'app_secret' => '--------------------', 'default_graph_version' => 'v2.4' ]); what method/methods can use new sdk above check this? in old methods found check done via $fb->api("/me/likes/page_id"); , , page's id ref...

ios - Better way to check for a Int in a textbox -

i learning xcode , creating program textbox(txt box) in user enters value, button (btncalc) performs calculation, , label (lblcalcdnumber) shows calc'd number. have selected number pad displayed dropdown keyboard want check make sure if enter other number nothing happens. code have works feel there should cleaner solution. essential want them enter integers in textbook. // mark: actions @ibaction func btncalc(sender: uibutton) { // let txtbox text beome int let number1 = int(txtbox.text!) // let possibleint convert mystring int check nil, txtbox becomes optional let possibleint = int(txtbox.text!) let number = 25 if possibleint != nil { let combinednumber = "\(int(number1!) * number)" lblcalcednumber.text = combinednumber } else { txtbox.text = "" txtbox.placeholder = "please enter valid number" } } you can use if , let create optional. if value not ni...

sql server - SQL sum values of duplicate rows into the first one (or last one) -

i want merge duplicated rows (with same doctype, docnum , item) , sum value of 'qtd' column first 1 or last one. delete duplicate rows keeping 1 caries total value. (the line number not important after deleting can allow not sequential numbers) actually have query detect duplicated rows, need query merge value , delete duplicated rows remain after merge. ps: big table doctype, docnum , item cannot expressed in query this... doctype='stket' , docum='1' , item='4506' must found "automatically" table: docs (initial duplicated rows) doctype docnum line item qtd stket 1 1 **4506** 10.00 stket 1 2 3860 27.00 stket 1 3 **4506** 4.00 stket 2 1 3860 7.00 stket 3 1 **4048** 2.00 stket 3 2 **4048** 5.00 stket 3 3 4876 11.00 stket 4 1 3860 1.0...

multithreading - How can I run code on a background thread on Android? -

i want code run in background continuously. don't want in service. there other way possible? i have tried calling thread class in activity activity remains in background sometime , stops. thread class stops working. class testthread implements runnable { @override public void run() { file file = new file(environment.getexternalstoragedirectory(),"/bpcltracker/gpsdata.txt"); int i=0; randomaccessfile in = null; try { in = new randomaccessfile(file, "rw"); } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } //string line =null; while (true) { httpentity entity=null; try { i...

Changing a TextView on an Android Widget from within the onReceive method rather than onUpdate -

i'm developing application runs service regularly sends broadcasts current state. broadcasts received appwidgetprovider using onreceive method: @override public void onreceive(context context, intent intent) { super.onreceive(context, intent); if (intent.getaction().equals(action_status_changed)) { bundle b = intent.getbundleextra("updateinfo"); remoteviews views = new remoteviews(context.getpackagename(), r.layout.widget_app_control); // doesn't work reason views.settextviewtext(r.id.informationtextview, b.getstring(myservice.bit_of_information)); // update widgets appwidgetmanager appwidgetmanager = appwidgetmanager.getinstance(context); int[] appwidgetids = appwidgetmanager.getappwidgetids(new componentname(context, appcontrolwidgetprovider.class)); this.onupdate(context, appwidgetmanager, appwidgetids); } } however, though i've added call onupdate , new text meant set using ...

Using jquery and ajax to update a partial using Ruby on Rails -

i've had issue days , been unable figure out... have 'like' , 'unlike' button. when user "likes" post, updates should occur in data base , button should flip "unlike". works on backend - database updates fine, button never switches "like" "unlike". if manually refresh page switched, doesn't happen without refresh. not have errors logged or in console. shared/_like.html.erb <%= form_for(current_user.likes.build, remote: true) |f| %> <div><%= hidden_field_tag :post_id, post.id %></div> <%= f.submit "like", class: "btn btn-primary" %> <% end %> shared/_unlike.html.erb <%= form_for(current_user.likes.find_by_post_id(post.id), html: {method: :delete }, remote: true) |f| %> <%= f. submit "unlike", class: "btn" %> <% end %> these rendered through: post/_post.html.erb <div id="like_form"> <% if pos...

java - Android studio sqlite image from drawable insert into database and retrieve into listview -

i have problem in inserting image sqlite. here's code inserting string query290 = "insert scholar_table(name,top,continent,region,location,introduction,alumni,icon) " + "values ('wesleyan university philippines','290','luzon','region 3','nueva ecija','wup intro','wup alumni','" + r.drawable.top1 +"')"; sqlhandler.executequery(query290); string query291 = "insert scholar_table(name,top,continent,region,location,introduction,alumni, icon) " + "values ('university of philippines diliman','1','luzon','ncr','quezon city','upd intro','upd alumni','" + r.drawable.top10 + "')"; sqlhandler.executequery(query291); my schooldb class public class schooldb { private string id, name, top, continent, region, location, intro...

matlab - save multiple matrices in dir after truncating -

i working code, based on previous user examples. trying read ascii files in directory specified , read first 80 rows of data each file (1020 total rows , 2 columns, originally). routine not give me errors it's unclear me how data stored in matlab, , how can manipulate each of new matrices of 80 rows i've created. can give each .asc file truncated new file name or matrix assignment? next need peakfinding algorithm on 80 rows in each file, need each of them stored separately. thanks! folder = fullfile('users', ...'documents', 'matlab'); f = dir(fullfile(folder, '*.asc')); matrices = struct(); ii = 1 : numel(f) name = fullfile(folder, f(ii).name); o = dlmread(name); matrices.(f(ii).name) = o(1:80,:); end this won't work. the loop loops files in directory. each file read temporary matrix o, first 80 lines stored structure matrices. but: matrices structure referenced full file nam...

vb.net - what's the best approach to do this in crystal report? -

Image
what's best approach in crystal report ? got 3 tables main table, sub table main , 1 item table sub of sub..it goes this.. maintable - stored main accounts. idkey accnt amount ------------------------------------ 01 construction 1000.00 02 maintenance 500.00 subtable - table sub account main table stored. - idkey table , main table equal. idkey idsub subaccnt amount ----------------------------------------- 01 01 watchtower 800.00 01 02 level 9 wall 200.00 02 03 monthly maintenance 500.00 itemtable - table items of sub table stored. - idsub of table , subtable equal. idsub items cost ----------------------------------- 01 cement 100.00 01 steel 100.00 01 labor 400.00 02 rocks 100.00 02 labor 100.00 03 labor 500.00 now want r...

javascript - d3 select throws invalid query selector error -

this structure of svg elements: <g class="point" transform="translate(241,197)"> <circle></circle> <text class="pointindex" x="-4px" y="-10px">1</text> <g class="deletepoint" transform="translate(0,16)"> <circle></circle> <text x="-3px" y="3px">x</text> </g> </g> i created following function: function deletepoint(deletecircle) { var circletext = d3.select(deletecircle.parentnode + '> text') } console.log(deletecircle) returns: <g class="deletepoint" transform="translate(0,16)"> <circle></circle> <text x="-3px" y="3px">x</text> </g> what want find text here: <text class="pointindex" x="-4px" y="-10px">1</text> (in case 1 ) did deletecircle.parentnode...

datagridview - C# Key press Event handling -

i have problem application. use customized tabcontrol in neotabcontrollibrary. and, in neotabpage, have several datagridview. here problem. in datagridview, when press up/down key, works properly. seleceted cell moves up/down. but, when press right/left key, event works on tabcontrol not on datagridview. i don't need key navigate function on tabcontrol. want use key navigate on selected cell moving only. is there way fix it? please help. to provide accurate answear best if provided code. while not ideal in case not need right/left key anywhere else on specific form use protected override bool processcmdkey(ref message msg, keys keydata) { //do stuff here return base.processcmdkey(ref msg, keydata); } method specify behaviour of 2 keys.

python - shuffle vs permute numpy -

what difference between numpy.random.shuffle(x) , numpy.random.permutation(x) ? i have read doc pages not understand if there difference between 2 when want randomly shuffle elements of array. to more precise suppose have array x=[1,4,2,8] . if want generate random permutations of x, difference between shuffle(x) , permutation(x) ? np.random.permutation has 2 differences np.random.shuffle : if passed array, return shuffled copy of array; np.random.shuffle shuffles array inplace if passed integer, return shuffled range i.e. np.random.shuffle(np.arange(n)) if x integer, randomly permute np.arange(x). if x array, make copy , shuffle elements randomly. the source code might understand this: 3280 def permutation(self, object x): ... 3307 if isinstance(x, (int, np.integer)): 3308 arr = np.arange(x) 3309 else: 3310 arr = np.array(x) 3311 self.shuffle(arr) 3312 return arr ...

java - android COuntDownTimer stop and start new one -

the program making includes 2 different count down. first, user has type in password within time limit , press button. if user can't input password before time limit, over. however, if user able input password correctly before time limit, new timer should start. public class malibucountdowntimer extends countdowntimer { public malibucountdowntimer(long starttime, long interval) { super(starttime, interval); } @override public void onfinish() { if(hasplanted == false) { text.settext("time's up!"); mtextview.settext("cya"); btnenable(false); startb.setenabled(false); } } @override public void ontick(long millisuntilfinished) { text.settext(""+string.format("%02d:%02d:%03d", timeunit.milliseconds.tominutes(millisuntilfinished) - timeunit.hours.tominutes(timeunit.milliseconds.tohours(millisun...

css - How do I Integrate Two Menu Wordpress Plugins? -

i'm looking have logo drop down menu on site, http://sheisbiddy.com/home/ found widget changes menu item photo (it's called menu image) worked beautifully. added widget (max mega menu) able add dropdown menu , customize , make life easier (less coding! yay!). problem overrode other widget , there isn't logo. tried using custom css feature add still isn't working (i asked in different question here: http://bit.ly/1pj1s3e ). there anyway these plugins play nice together? or there better way both logo , dropdown menu? appreciate advice have! last step until site ready go. if plugin conflict, theres chance because there conflicting styles in each one, , 1 takes priority on other. finding styles , commenting them out or deleting them might solve issue. in worse situation, there name conflict, seems doubtful here.

authentication - Wechat login for mobile website -

wechat has convenient qr-code login option (sorry, chinese only) desktop websites. scan code wechat, click ok, , you're logged in. however, i'm struggling how implement same functionality when same website accessed via mobile? i'm in same situation , keep getting unanswered issue google i'll try give more information based on have far. first let's clarify talking wechat in scope of china country. wechat in china has far more features compared other countries. basically there 3 ways login wechat on website : wechat login qr code. more designed desktop site , easiest way login wechat users point of view wechat login mobile site via wechat mobile application. when user using mobile wechat application, click on link within mobile wechat app redirects user mobile version of site still in scope of wechat app. see on gmail mobile application , click on link, still in mobile app browsing mobile website. wechat login mobile site via web browser. in cas...

r - Merge and aggregate result to original data -

this question has answer here: calculate group mean (or other summary stats) , assign original data 4 answers i have dataframe df, 3 variables : id, category , quantity : id category quantity 01 ab 235 02 bc 987 03 ab 366 04 cd 287 i want add fourth variable sum of whole category. now, : df <- merge(df,aggregate(df$quantity,list(df$category),sum), by.x="category", by.y="group.1") names(df)[4] <- "sum.category" it works, don't find satisfying, there's better way? here option data.table . convert 'data.frame' 'data.table' ( setdt(df1) ), grouped 'category', assign ( := ) sum of 'quantity' new column ('sum.category'). library(data.table) setdt(df1)[,sum.category:= sum(quantity) , category] df1 # id category quantity sum.category ...

algorithm - Example of Big O of 2^n -

so can picture algorithm has complexity of n^c, number of nested loops. for (var = 0; < dataset.len; i++ { (var j = 0; j < dataset.len; j++) { //do stuff , j } } log splits data set in half every time, binary search (not entirely sure code looks like). but simple example of algorithm c^n or more 2^n. o(2^n) based on loops through data? or how data split? or else entirely? algorithms running time o(2^n) recursive algorithms solve problem of size n recursively solving 2 smaller problems of size n-1. this program, instance prints out moves necessary solve famous "towers of hanoi" problem n disks in pseudo-code void solve_hanoi(int n, string from_peg, string to_peg, string spare_peg) { if (n<1) { return; } if (n>1) { solve_hanoi(n-1, from_peg, spare_peg, to_peg); } print "move " + from_peg + " " + to_peg; if (n>1) { solve_hanoi(n-1, spare_peg, to_peg, from...

cakephp - authentication using a different table and column -

how change user table name , column name authentication in cakephp. default taking users table name. class appcontroller extends controller { public $components = array( 'session','security', 'auth' => array( 'loginredirect' => array('controller' => 'project', 'action' => 'index', 'project details'), 'logoutredirect' => array('controller' => 'users', 'action' => 'login') ) ); function beforefilter() { $this->auth->allow('login'); } } model : app::uses('appmodel', 'model'); class users extends appmodel { var $usetable = 'manager'; } in appcontroller's beforefilter() method add following code function beforefilter(){ parent::beforefilter(); $this->auth->authenticate = array( authcomponent...

fortran - I cannot work out the error in the script -

i new programming , cannot debug program. whenever run it gives same error: return type mismatch of function f @ (1) my code is: real function f(x) implicit none real:: x f=exp(-x)-x end function program easycod implicit none real::xl,xu,xr,fu,test,xrold,fl,fr integer ::i i=1,50 xr=xrold xr=(xl+xu)/2.0 fr =f(xr) fl =f(xl) test=fl*fr if (test>0.0) xl=xr fr=fl else if (test<0.0) xu=xr end if if (test==0.0) exit print*,xr end end program there few things wrong code. first, getting compiler error because haven't declared function f in program : program easycode implicit none real :: xl, xu, xr, fu, test, xrold, fl, fr real :: f ! <----------------- add line integer :: then assigning xr twice...

javascript - Too many browser.wait calls in protractorjs -

my test steps test logout flow are, 1) click logout button 2) wait url change login.html 3) wait login page text fields loaded. code looks like, //wait logout menu/button browser.wait(function(){ return element(by.buttontext('log out')).ispresent() }) element(by.buttontext('log out')).click() //wait url change login.html browser.wait(function(){ return browser.getcurrenturl().then(function(url){ return url.indexof("login") != -1 }) }) //wait login page text boxes browser.wait(function(){ return element(by.css('[type=text]')).ispresent() }) this makes code lengthy since, wrapping each action inside browser.wait call. there way can avoid browser.wait . tried adding, browser.manage().timeouts().implicitlywait(5000) but then, no element found using locator: by.buttontext("log out") error. protractor has inbuilt expectedconditions checks, don't have write custom function time. here's how wai...

python - WTForms decimal separator (for non-English apps) -

for non-english apps it's common use , decimal separator. can't find reference changing decimal formatting based on locale. is possible wtforms? the current wtforms code uses python decimal module, totally ignores locale settings separators (in fact, documentation presents an example builds string representation building string representation itself). you can change line 561 of fields\core.py is format = '%%0.%df' % self.places to: format = '%%0,%df' % self.places but ugly patch, suggest open issue fix properly

java - Spring MVC display data from database -

i trying display data database, getting error loginsuccess.java package java4s; import java.util.list; import javax.servlet.http.httpsession; import org.springframework.beans.factory.annotation.autowired; import org.springframework.context.annotation.scope; import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.modelattribute; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.servlet.modelandview; import java4s.employeeservice; @controller @scope("session") public class loginsuccesscontroller { @autowired employeeservice emp_service; @requestmapping(value = "/login", method=requestmethod.post) public modelandview loginvalidateform(modelmap model, @modelattribute("loginform") employee employee, httpsession session) { if(emp_service...

php - Codeigniter: how to check if username already exists from mysql database -

i'm working on codeigniter. not expert using framework. have registration form of employee , want display " username exists " beside username input after submit button. here image of tables mysql database: image of tables mysql database here controller (home.php): public function viewaddemployeeform() { $this->load->model('model_home'); $data = array(); $data['dropdown'] = $this->model_home->get_dropdown(); $this->load->view('imports/header'); $this->load->view('imports/menu'); $this->load->view('emp_add', $data); } public function saveemployee() { $this->load->model('model_home'); $p = new model_home(); $p->date_employed = $this->input->post('date_emp'); $p->designation_id = $this->input->post('emp_desi'); $p->username = $this->input->post(...

ASP.NET session out proble. frequently logout problems -

i have created asp.net mvc razor application authentication. used custom implementation of authorizeattribute. when run locally, works fine, when upload , run website logs out while working without leaving website idle. how can solve it? if asp.net session stored in memory , recycle app domain, loose sessions in memory. if control web server, might research reason recycles: see . if want sessions persist across these events need other session state modes

ios - How to use Swift closure in OC -

in swift uiviewcontroller , code: import foundation import uikit typealias sayhello = ()->string @objc class swiftviewcontroller:uiviewcontroller{ var sayhello:sayhello? override func viewdidload() { super.viewdidload() if let helloclosure = sayhello{ helloclosure() } }} in oc uiviewcontroller , code: swiftviewcontroller.sayhello = ^(){ return "hello block"; }; when xcode compile oc file ,it shows error: incompatible block pointer types assigning 'nsstring * _nonnull(^_nullable)(void)'from 'char *(^)(void)' where mistake ... (sorry, forgot @ before "hello block" in oc file. it's careless mistake. works fine. thank you!) you forgot @ before "hello block" , returning c-string, , because didn't explicitly specified return type block, compiler infers char* , incompatible nsstring* . if declare block ^nsstring*(){ , you'll error telling return value doesn't matc...

java - Why does creating an array from primitives copy them? -

in program public static void main(string[] args){ int x = 1; int y = 2; int[] z = new int[]{x, y}; z[0] = 3; system.out.println(x); //prints 1 } i expected 3 printed. 1 was. why? thought java makes copy of references, i.e. when pass refrence method, method operate reference same object. it's c++ pointers , primitive types. so tried consult jls 10.6 , didn't find useful it. maybe i've got misunderstanding primitive types in java. clarify? why creating array primitives copy them? for same reason that: int = 5; int b = a; ...copies value of a b , without creating kind of link between a , b : value copied, not kind of reference variable. re comment: but when operate on reference types, reference copies, doesn't it? yes, does, number gets copied in int scenario. b = a (or array initializer) works exactly same way regardless of whether a , b primitive type variables or reference type variables: value in...

c# - Outlook 2010 VSTO AddIn: UI freezes randomly, while adding folders to PST asynchronously -

my c# vsto outlook 2010 addin adds hundreds of mapi folders imported pst file asynchronously. (pst exists in outlook foldertree) here example: task.factory.startnew(() => { ... //get pststore var rootfolder = pststore.getrootfolder(); (int = 0; < 500; i++) { var folder = rootfolder.folders.add("test" + datetime.now.ticks); thread.spinwait(1000); //emulate work marshal.releasecomobject(folder); } marshal.releasecomobject(rootfolder); }); the outlook ui freezes randomly @ rootfolder.folders.add(...) 2-3 sec. after 20, after 50 added folders. any / tip appreciated. expect addin stop working in outlook 2013 or newer: oom raises error detects being called thread other primary outlook thread. note applies com addins run inside outlook.exe address space. out-of-proc access marshaled main outlook thread com system (but defeats whole purpose of using oom separate thread). only extended mapi (c++ or delphi) can use...

MySqli Database connection access denied php -

hey i'm connecting db in php would, info there , correct. checked password few times. there here ruin connection? here's (nice , vague) error message: connection failed: access denied user 'user'@'localhost' database 'db' <?php header('access-control-allow-origin: *'); ?> <style> </style> <html> <body> <?php $servername = "localhost"; $username = "user"; $password = "password"; $dbname = "db"; // create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // check connection if (!$conn) { die("connection failed: " . mysqli_connect_error()); } connection failed: access denied user 'user'@'localhost' database 'db' nope thats not vague, accurate can get. user user not have permission access database db on localhost if password correct. no if else or guesses or chances...

android - Parse: Retrieve all data from different table at once -

i trying data different table tried use method. however, understand loop synchronous loop didn't stop when parse fetching data. did idea how solve it? there got parse method or intent services may situation? private void getallinformation(){ string controlname; for(int i=0; i<3;i++){ if(i==0){ controlname = appconfiguration.strevent; } else if(i==1){ controlname = appconfiguration.strstore; } else if (i==2){ controlname = appconfiguration.strpromotion; } else{ return; } parsequery<parseobject> query = parsequery.getquery(controlname); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> objectlist, parseexception e) { if(e!=null){ toast.maketext(getapplicationcontext(),"error loading.please try again",toast.length_long ).sho...

bash switch-case statement gives syntax error -

#!/bin/bash echo "title: " read title echo "" until [ -n "$title" ] echo "please enter title: " read title echo "" done echo "author: " read author echo "" until [ -n "$author" ] echo "please enter author: " read author echo "" done check= cat ./bookdb.txt | egrep -ie "\b""$title""\b" | egrep -ie "\b""$author""\b" if [ -z "$check" ] echo "error! book not exist!" #need code continue else echo "book found!" all= cat ./bookdb.txt | grep -i "$title" oldtitle=`echo "$all" | cut -d ":" -f1` oldauthor=`echo "$all" | cut -d ":" -f2` oldprice=`echo "$all" | cut -d ":" -f3` oldavail=`echo "$all" | cut -d ":" -f4` oldsold=`echo "$all" | cut -d ":" -f5`...

math - Java plot values in a virtual graph and find the integral area. -

quick question. got 10 000 lines information. have 2 values on each line. line in format : (time , water speed). want use numerical integration solve how water passed sensor, i'm confused how go solving in java. i assume graph nice, don't need graphical, maybe array-list trick. any tips, hint , tricks appreciated. you can use trapezoidal rule this: sort intervals time, calculate sum follows: // assume time expressed using class time[] time = ... // assume water speed double, expressed in volume per unit of time. // further assume time units match units in denominator of water speed, // e.g. if speed in galons per minute, time unit minutes; // if speed in galons per second, time unit seconds, , on double[] speed = ... double sum = 0; (int = 0 ; < time.length-1 ; i++) { double deltat = time[i+1].subtract(time[i]).totimeunits(); // formula trapezoidal rule on non-uniform grid sum += (speed[i]+speed[i+1])*deltat; } double totalflow = sum / 2; ...

android - SQLiteException: near "=": syntax error (code 1): (Closed) -

the app forces closed everytime run it. when checked logcat, error keeps on popping out. android.database.sqlite.sqliteexception: near "=": syntax error (code 1): , while compiling: select * tblresultswheretopid=1andusname=fbbh @ android.app.activitythread.performlaunchactivity(activitythread.java:2351) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2403) @ android.app.activitythread.access$600(activitythread.java:165) @ android.app.activitythread$h.handlemessage(activitythread.java:1373) @ android.os.handler.dispatchmessage(handler.java:107) @ android.os.looper.loop(looper.java:194) @ android.app.activitythread.main(activitythread.java:5391) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:833) @ com.android.internal.os.zygotein...

ios - CAScrollLayer not working on Video -

i trying create image animation on video of cascrolllayer able add images on cascrolllayer it's not scrolling when video played appreciable below code have tried far. calayer *layer; // self.view = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, 460)]; scrolllayer = [cascrolllayer layer]; scrolllayer.backgroundcolor = [[uicolor blackcolor] cgcolor]; scrolllayer.bounds = parentlayer.bounds; scrolllayer.contentsrect = cgrectmake(0, 0, scrolllayer.bounds.size.width*images.count, scrolllayer.bounds.size.height); scrolllayer.borderwidth = 2.5; scrolllayer.bordercolor = [[uicolor redcolor] cgcolor]; scrolllayer.position = cgpointmake(self.view.center.x, self.view.center.y - 20); scrolllayer.scrollmode = kcascrollhorizontally; scrolllayer.speed = 2.0; // [self.view.layer addsublayer:scrolllayer]; [parentlayer insertsublayer:scrolllayer atindex:0]; for(int i=0; i<[images count]; i++) { uiimage *image = [images objectatin...

how i can correct this error in ruby installed ruby is 1.9.3 and it shows the path of installed ruby 2.0.0 -

what probem , how can solve rubygems environment: - rubygems version: 1.8.23 - ruby version: 1.9.3 (2013-05-15 patchlevel 429) [x86_64-linux] - installation directory: /home8/novapext/.rvm/gems/ruby-2.0.0-p648 - ruby executable: /usr/bin/ruby - executable directory: /home8/novapext/.rvm/gems/ruby-2.0.0-p648/bin - rubygems platforms: - ruby - x86_64-linux - gem paths: - /home8/novapext/.rvm/gems/ruby-2.0.0-p648 - /home8/novapext/.rvm/gems/ruby-2.0.0-p648:/home8/novapext/.rvm/gems /ruby-2.0.0-p648@global - gem configuration: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - "gem" => "--remote --gen-rdoc --run-tests" - "gemhome" => "/home8/novapext/.rvm/gems/ruby-2.0.0-p648" - "gempath" => "/home8/novapext/.rvm/gems/ruby-2.0.0-p648:/home8/novapext/.rvm/gems/ruby-2.0.0-p648@global" - "rd...

javascript - Change Attributes for Dynamically added elements -

how can change (type) attribute dynamically added buttons? in below code, label names changing perfectly, when trying change button types applying added dynamic buttons, requirement have change every button type different types (means: 1st button submit, 2nd reset, 3rd cancel). in code if change 2nd button type 'reset' @ same time first button type going reset type... can u please tell me how can change button type every added element ... ?? working demo updated: var app = angular.module('myapp', ['ngsanitize']); app.controller('buttonctrl', function($scope, $compile) { var counter = 0; $scope.buttonfields = []; $scope.add_button = function(index) { $scope.buttonfields[counter] = {button: 'submit'}; var buttonhtml = '<div ng-click="selectbutton(buttonfields[\'' + counter + '\'])"><button id="button_type">{{buttonfields[' + counter + '].button...

javascript - echo php variable in Highcharts -

how echo php variable script of highchart js? im using column chart <?php $value=75 ?> at series section series: [{ name: 'traf', data: [<?php echo $value?>, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }] any solution helps. mixing php js bad habit, can either store $value in hidden field: <input type="hidden" value="<?=$value?>" id="txtchart" name="txtchart" /> then in javascript: var txtchart = $("#txtchart").val(); series: [{ name: 'traf', data: [txtchart, 71.5, 106.4....] }]

python - Pythonic way to simplify multiply 2 pandas columns with condition -

i looking way how can simplify below examples: self.df[target_name] = self.df.apply(lambda row: 1 if row['winner'] == 1 , row['winner_over_2_5'] == 1 else 0, axis=1) like: self.df[target_name] = self.df[(self.df.winner == 1)] & self.df[(self.df.winner_over_2_5 == 1)] # not it's not correct and more complex below df["profit"] = np.where((df[target_name] == df["predicted"]) & (df["predicted"] == 0), df['match_home'] * df['home_stake'], np.where((dfml[target_name] == df["predicted"]) & (df["predicted"] == 1), df['match_draw'] * df['draw_stake'], np.where((df[target_name] == df["predicted"]) & (df["predicted"] == 2), df['match_a...

google chrome - Why video is started from last end position? -

i have problem youtube-api when load video. using loadvideobyid function. have tried cuevideobyid result same. ok, here about. when play video @ youtube page , finish in example middle. youtube remember position , next time enter video play position. im logged in in chrome browser. when load video @ page using youtube api function mentioned before starts video remembered position. i tried use stopvideo or seekto(0) after loading doesnt work. when change time of video , press stop , play next start again remember position. know solution ? js fiddle: https://jsfiddle.net/or2w8fpd/6/ just open video youtube side stop in middle, check if youtube saved position future (if return video progress start) open jsfiddle , try it. remember logged in chrome browser

angularjs - how to use angular 1 variables inside the angular 2 component -

login.js var app= angular.module('login',[]); app.controller('loginctrl', function($scope) { $scope.sayhello="hello"+ $scope.username; }).directive('logindir', function(){ return { scope:{}, templateurl: 'logintpl.html', controller: 'loginctrl' }; }); var adapter = new ng.upgrade.upgradeadapter(); appcomponent = ng.core .component({ selector: 'login', directives: [adapter.upgradeng1component('logindir')], template: '<login-dir></login-dir>' }) .class({ constructor: function() {} }); app.directive('login', adapter.downgradeng2component(appcomponent)); document.addeventlistener('domcontentloaded', function() { adapter.bootstrap(document.body, ['login']); console.log(adapter); }); logintpl.html <input type="name" ng-model="username"> how can use $scope.sayhello variable inside component. eg: compone...