Posts

Showing posts from May, 2010

angularjs - Angular: How to perform search on button click -

this sample code user write data in textbox , result filter accordingly how can filter data clicking button? <div ng-app="myapp" ng-controller="mycontroller"> <label>field: <select ng-model="selectedfieldname"> <option value="">--select account--</option> <option ng-repeat="(fieldname,fieldvalue) in customer[0]" ng-value="fieldname | uppercase">{{fieldname | uppercase}}</option> </select> </label> <label>data: <input ng-model="searchtext"></label> <table class="table table-striped table-bordered"> <tr> <td>id</td> <td>first name</td> <td>last name</td> <td>salary</td> <td>date of birth</td> <td>city</td> <td>phone</td> ...

Android GridView not responding to OnItemClickListener -

i found people had problem well, none of existing solutions worked me. have fragment (called headlinesfragment), assigns onitemclicklistener gridview containing images. images appear fine, touch/click event never fired. tried multiple combinations of android:clickable="false"/android:focusable="false", etc nothings works me public static class headlinesfragment extends fragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.menufragment, container, false); return rootview; } public class imageadapter extends baseadapter { private context context; integer[] imageids = { r.drawable.pasta05, r.drawable.pasta05, r.drawable.pasta05, r.drawable.pasta05, r.drawable.pasta05, r.drawable.pasta05, r.drawa...

javascript - Save canvas as jpg to desktop -

this question has answer here: html5 canvas png file 4 answers i trying save image (jpeg) desktop html5canvas. can open in new window window.open(canvas.todataurl('png'), ""); , how can save desktop? thanks. download attribute there new download attribute in html5 allow specify file-name links. i made saving canvas. has link ("download image") - <a id="downloadlnk" download="yourfilename.jpg">download image</a> and function: function download() { var dt = canvas.todataurl('image/jpeg'); this.href = dt; }; downloadlnk.addeventlistener('click', download, false); you can change file-name dynamically setting attribute downloadlnk.download = 'myfilename.jpg' . demo archives.

java - JSP pages not loading on loaclhost while working with Tomcat7 on Eclipse IDE -

i working on project using java servlets , jsp. earlier project running fine, when running project, server setup jsp pages not running , others not show css applied it. also console shows warning. apr 19, 2016 8:24:57 pm org.apache.catalina.core.aprlifecyclelistener init info: loaded apr based apache tomcat native library 1.1.33 using apr version 1.5.2. apr 19, 2016 8:24:57 pm org.apache.catalina.core.aprlifecyclelistener init info: apr capabilities: ipv6 [true], sendfile [true], accept filters [false], random [true]. apr 19, 2016 8:24:58 pm org.apache.tomcat.util.digester.setpropertiesrule begin warning: [setpropertiesrule]{server/service/engine/host/context} setting property 'source' 'org.eclipse.jst.jee.server:tpc' did not find matching property. apr 19, 2016 8:24:58 pm org.apache.catalina.core.aprlifecyclelistener initializessl info: openssl initialized (openssl 1.0.1f 6 jan 2014) apr 19, 2016 8:24:58 pm org.apache.coyote.abstractprotocol init info: initial...

plsql - Oracle: Capturing Specific Oracle Message with EXCEPTION_INIT -

i want handle exception ora-000942 , following manual , discussion . since ora- error no predefined name, want use exception_init. when run code, continue ora-000942 message, not expected via procedure level handler. create table foobar (foobar_id varchar(1)); declare procedure p_add_to_foobar p_missing_table exception; pragma exception_init(p_missing_table, -00942); begin insert foobaz select '1' dual; exception when p_missing_table dbms_output.put_line('missing table'); end p_add_to_foobar; begin p_add_to_foobar; dbms_output.put_line('done'); end; question: how procedure level exception handle -942 error? the error you're getting being thrown pl/sql compiler when tries compile statement insert foobaz select 1 dual because of course foobaz table doesn't exist. in-line sql statements have valid @ compile time, , compiler throws exception. to around you'll have use dynamic sql, in: ...

java - How to maintain the focus point in a Pan/Zoom Android Layout while zooming? -

i have custom layout extends framelayout , supports need. scrolling , zooming child view or layout works well. 1 thing having trouble maintaining focus point while zooming. center point between pinching fingers moves off screen, work google maps app focus(center) point maintained. here's code. public class betterzoomlayout extends framelayout { // state objects , values related gesture tracking. private scalegesturedetector mscalegesturedetector; private gesturedetectorcompat mgesturedetector; private static final float min_zoom = 1.0f; private static final float max_zoom = 4.0f; private float scale = 1.0f; private float lastscalefactor = 0f; // how translate canvas private float distancex = 0f; private float distancey = 0f; public betterzoomlayout(context context) { super(context); init(context); } public betterzoomlayout(context context, attributeset attrs) { super(context, attrs); init(context); } public betterzoomlayout(context conte...

html - img auto width height and max-height -

i have code here: <table class="media imgtable" border="1" width="auto" height="auto" style=""><tbody> <tr><td class="xclick" width="auto" height="auto" align="left" valign="center"> <div class="xclick" style="position: relative; left: -1px; top: 3px; width: 200px; padding: 0px 1%; border: 1px solid silver; border-bottom: none; background-color: #add8e6;"><?php echo $label; ?></div> </td></tr> <tr><td class="xclick" width="auto" height="auto" align="center" valign="center" style="position: relative;"> <img id="img" src="<?php echo $src; ?>" style="width: auto; height: auto;" /> </td></tr></tbody></table> and looks this it perfect. want. images large , overflow scree...

r - Row division for even number rows -

i trying divide first row second , third row fourth , fifth row sixth , onward large data table. there way without computation. input name month income john jan 10000 john_county jan 20000 tanya jan 20000 tanya_county jan 40000 output name month per_income john jan 50% tanya jan 50% in r can use , odd index: odds <- c(true, false) ii[odds,"per_income"] <- paste0(ii[odds,3] / ii[!odds,3] * 100,"%") ii[odds,] # name month income per_income # 1 john jan 10000 50% # 3 tanya jan 20000 50%

javascript - checking input length by getElementById is not working -

function checklength(input) { var element = document.getelementbyid('t').value; if(document.calculator.t.value.length == 10) { alert("ivalid length - 10 characters only!"); } if(element.value.length > 10) { alert("ivalid length - 10 characters only!"); } } <form name="calculator"> <input type="text" maxlength="10" name="answer" id="t" onkeyup="isallowedsymbol(this);checklength(this); " placeholder="enter data" > <br /> <input type="button" value=" 1 " onclick="calculator.answer.value += '1'" /> <input type="button" value=" 2 " onclick="calculator.answer.value += '2'" /> <input type="button" value=" 3 " onclick="calculator.answer.value += '3'" /> <input type="button" value=...

ios - How to parse JSON data properly if some data is NSNull -

i'm pulling data via twitter's search api. once receive data, trying parse , save data tweetdetails class (which hold author's name, url of profile pic, text of tweet, location of tweet, tweet id , user id). in cases, tweets not have location (i think has if they're retweeted), , dictionary (here being tweetsdict["place"]) otherwise hold information, instead returns nsnull. on occasions, receive error could not cast value of type 'nsnull' (0x1093a1600) 'nsdictionary' (0x1093a0fe8). here code trying parse data , save objects in tweetdetails class client.sendtwitterrequest(request) { (response, data, connectionerror) -> void in if connectionerror != nil { print("error: \(connectionerror)") } { let json = try nsjsonserialization.jsonobjectwithdata(data!, options: []) if let tweets = json["statuses"] as? [nsdictionary] { twe...

jQuery script doesn't work in Wordpress -

i know problem has been asked alot of times can't jquery work in wordpress. i have form going used wp_ajax before point wanted ensure interact jquery. the form html placed on page , looks this: <div id = "content"> <form action= "" method= "post" id= "hfwpform"> <label for= "fname">first name</label></br> <input type= "text" name= "fname" id= "fname" required></br> <label for= "email">email address</label></br> <input type= "email" name= "email" id= "email" required></br> <label for= "message">your message</label></br> <textarea name= "message" id= "message"></textarea> <input type= "hidden" name= "action" value= "contact_form"> ...

go - Does calling a function break recover()? -

i using library recover() s panics, , using code simplifies following: func main() { defer rec() panic("x") } func rec() { rec2() } func rec2() { fmt.printf("recovered: %v\n", recover()) } the output of is: recovered: <nil> panic: x ... more panic output ... notably, recover() returns nil instead of error. intended behavior? recover must called directly deferred function. from language spec : the return value of recover nil if of following conditions holds: panic's argument nil; the goroutine not panicking; recover not called directly deferred function.

ruby on rails - ng-token-auth for all subdomains -

i'm working on rails app angular front end , we're using ng-token-auth , devise_token_auth authentication. we've got working pretty well, need persist session across different subdomains ( www.app.com , api.app.com , test.app.com , example). i'm trying set cookieops object: $authprovider.configure({ apiurl: '', cookieops: { domain: '*.app.com' } }); but seems have no effect. accomplished this? we using ng-token-auth on different subdomains. try , replace cookieops: { domain: 'app.com' } . should work (remove *. prefix)

codenameone - Websocket with codename one -

will be able use same websocket code js too? or there special code needed depending on platform? also able extend urlimage.createtostorage() method load our own websocket based backend rather url? , possible make work seamless in devices? it possible use websockets connection javascript build see this discussion . notice if need connect different server origin need proxy request keep same origin behavior. you can't override create methods of urlimage static. can download files thru websocket , open them using encodedimage.create method accepts byte array.

java - Hibernate duplicates elements in parent collection while it is populating with newly persisted childs -

can explain following strange behaviour encountered? trying persist new child objects , simultaneously add them to parent collection. @ end there twice many elements in parent collection expected. let me show example: @entity public class { @generatedvalue(strategy = generationtype.identity) @id private integer id; @onetomany(mappedby = "a") private list<b> bs = new arraylist<>(); public integer getid() { return id; } public void setid(integer id) { this.id = id; } public list<b> getbs() { return bs; } public void setbs(list<b> bs) { this.bs = bs; } } @entity public class b { @generatedvalue(strategy = generationtype.identity) @id private integer id; @manytoone private a; public integer getid() { return id; } public void setid(integer id) { this.id = id; } public geta() { return a; } public void seta(a a) { this.a = a; } } test case: @test public void test() ...

python - matplotlib - plotting a timeseries using matplotlib -

03/12 20:23:26.11: 04:23:26 l9 <mx acc magnum xdv:00111a0000000117 00d3001200870172 01ff6000f01cfe81 3d26000000000300 03/12 20:23:26.11: 04:23:26 l9 <mx acc mid 0x1500 len 26 xdv:00111a0000000117 00d3001200870172 01ff6000f01cfe81 3d26000000000300 03/12 20:23:26.11: 04:23:26 l8 <mx jk31 (mx) jsp:17.37.6.99: size = 166, data: 00345c4101003031 e463ef0113108701 5a01ff6008f01cfe 81ab170000000003 ef01131087015a01 ff6008f01cfe81ab 170000000003ef01 131087015b01ff60 00f01cfe81701b00 00000003ef011310 87015b01ff6000f0 1cfe81701b000000 0003ef0113108701 5c01ff2000f01cfe 81cb240000000003 ef01131087015c01 57cc00f01cfe81cb 240000000003ef01 131087015d01ff20 00f01cfe815b2900 00000003ef011310 87015d01ff2000f0 1cfe815b29000000 0003ef0113108701 5e01ff6000f01cfe 819d280000000003 ef01131087015e01 ff6000f01cfe819d 0003 03/15 20:23:26.11: 04:23:26 l8 <kx jk49 (kx) jsp:15.33.2.93: size = 163, data: 00647741000030ef 01131087015a01...

lotus notes - xPages don't work after design update -

load xpage refresh db design reload xpage either f5 or ctrl+f5. then functions stop working without errors. e.g. nothing happen if click buttons or menu items. after restarting web browser functions come still doesn't work. after cleaning browser's cache 90% ui start working still need reload page few times. there xpage app properties or domino properties adjust fix problem , make xpage app work smooth after design refresh design refresh didn't reload custom java classes when refreshing 8.5.3 fp1. fixed, believe, in fp2. doesn't sound it's causing problem here. design refresh not reload jar files. requires issuing "restart task http" console. ("tell http restart" doesn't reload xpages needs.) if application using single copy xpage design hold xpages design, not update until issue "restart task http" server. design seems cached server better performance, refreshing design of scxd database doesn't reload de...

javascript - Submitting a PHP upload once files have been selected -

i have image upload script using php simple multiple file select , upload function below: mysql_connect("localhost", "root", "") or die("error"); mysql_select_db("repo") or die("error"); $imgerror = ''; if(isset($_post['log'])){ foreach($_files['files']['tmp_name'] $key => $name_tmp){ $name = $_files['files']['name'][$key]; $tmpnm = $_files['files']['tmp_name'][$key]; $type = $_files['files']['type'][$key]; $size = $_files['files']['size'][$key]; $dir = "content/images/".$name; $move = move_uploaded_file($tmpnm,$dir); if($move){ $hsl = mysql_query("insert files values('','$client','$name','$type','$size',now())"); if ($hsl){ $imgerror = "image(s) uploaded succ...

bash - Need Assistance Understanding ls -d command in linux -

i'm trying wrap head around 'ls -d' command. i run command 'ls -d' in given directory , '.' i run command 'ls -d */ , directories i run command -ls -d * , files, including aren't directories. the man page states this: list directories themselves, not contents can please explain how switch supposed work? the things understand are: ls lists current directory, otherwise known . , default. ls -d makes ls show directory it's listing, not contents of directory. the behaviors describe follow that: ls -d showing . showing directory you're in -- default target of ls no arguments given. ls -d */ tells shell run ls each directory under current 1 passed argument ; ls -d shows entries each of arguments, behaving report. ls -d * tells shell run ls each entry in current directory passed argument. ls lists 1 entry each such argument, not showing contents of each argument directory name otherwise would.

How to bind mongodb search result to asp.net C# gridview -

i having trouble binding mongodb search result asp.net c# gridview. whenever run program, throws nullreferenceexception: "object reference not set instance of object." after debugging, found gridview id (gridview1) null. however, have no idea why gridview1 null. appreciated. here markup page: <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" backcolor="white" gridlines="both" bordercolor="#d8d8d8" borderwidth="1px" cellpadding="4" forecolor="black" allowpaging="true" pagersettings-position="topandbottom" allowsorting="true" datakeynames="_id" height="50px" borderstyle="none" pagesize="50" font-size="8pt" cssclass="sp_datalabel" width="99%" onpageindexchanging="gv_pageindexchanging" onrowdatabound="gv_rowdatabound" onrowdele...

java - how to clear ALL retained mqtt messages from mosquitto -

i've seen mosquitto_pub -h [server] -r -n -t [xyz] syntax clearing out 1 off messages. problem device developers have posted lot of garbage messages. have java/paho code base i'd modify automatically needed, can't seem publish 0 byte message. tried client.publish(topic,null); but didn't seem work. any suggestions on how delete everything, en mass. there 2 options using paho client code depending on of 2 publish methods use. mqttmessage msg = new mqttmessage(new byte[0]); msg.setretained(true); client.publish(topic, msg); or client.publish(topic, new byte[0],0,true); the other option stop mosquitto , delete persistence file , restart

java - Share RestTemplate's MessageConverters across multiple instances -

benchmarks made showed 70% of time creating new resttamplate() messageconverters , wondered if it's safe create 1 set of converters , use across multiple instances, different threads. edit: motivation logging "on wire" traffic. thought implementing using clienthttprequestinterceptor . since each request should logged different file, thought create new resttemplate each set of requests, different interceptor. this javadoc of httpmessageconverter doesn't explicitly require it, intention implementations thread safe. if thread safe, safe use across multiple resttemplate instances. resttemplate other http client use. shouldn't typically need more 1 instance per application. (some exceptions exist proxies, ssl configurations, etc.)

c++ - Order of evaluation and undefined behaviour -

speaking in context of c++11 standard (which no longer has concept of sequence points, know) want understand how 2 simplest examples defined. int = 0; = i++; // #0 = ++i; // #1 there 2 topics on explain examples within c++11 context. here said #0 invokes ub , #1 well-defined. here said both examples undefined. ambiguity confuses me much. i've read well-structured reference 3 times topic seems way complicated me. . let's analyze example #0 : i = i++; . corresponding quotes are: the value computation of built-in postincrement , postdecrement operators sequenced before side-effect. the side effect (modification of left argument) of built-in assignment operator , of built-in compound assignment operators sequenced after value computation (but not side effects) of both left , right arguments, , sequenced before value computation of assignment expression (that is, before returning reference modified object) if side effect on scalar o...

apache - httaccess redirect 1 domain to http, others to https. all for non-www -

i use htaaccess load magento websites. problem have 1 domain without ssl, possible redirect 1 domain http, while others redirected https. domains should point non-www version. my current htaacces: options +symlinksifownermatch rewriteengine on rewritecond %{http_host} ^www\.(.*)$ [nc] rewriterule ^(.*)$ http://%1/$1 [r=301,l] rewritecond %{http_host} .*abc\.com [nc] rewriterule .* - [e=mage_run_code:abc] rewritecond %{http_host} .*abc\.com [nc] rewriterule .* - [e=mage_run_type:website] rewritecond %{http_host} .*qwe\.de [nc] rewriterule .* - [e=mage_run_code:qwe] rewritecond %{http_host} .*qwe\.pl [nc] rewriterule .* - [e=mage_run_type:website] rewritecond %{http_host} .*zxc\.fr [nc] rewriterule .* - [e=mage_run_code:zxc] rewritecond %{http_host} .*zxc\.fr [nc] rewriterule .* - [e=mage_run_type:website] i qwe.de redirected http. while other domain should point https. help! this problem htaccess not magento try this rewriteengine on rewritecond %{http...

list - Larevel pivot table perimissions chack -

Image
when click on role detail lists permissions . my controller : public function permissions($id) { $all_permissions = permission::all(); // permissions $role = role::with('permissions')->where('id', '=', $id)->get(); // role , role permissions return view('auth.permissions',compact('role','all_permission')); } all permissions in role of pivot tables list permissions want selected my view file: @foreach($role $rol) {{ $rol->name }} <tbody> @foreach($all_permissions $permision) <tr> <td> {{ $permision->id }} </td> <td> {{ $permision->name }}</td> <td> {{ $permision->label }} </td> <td> {{ $permision->updates_at }} </td> <td> <input type="checkbox" class="make-switch" checked data-size="small" data-on-color="success...

django - Read a list of models and block new creations -

i have order model users can create , modify. an admin user can list of orders of days , send list. i before admin sends list, closes orders current day, orders closed until next day. at moment, not see how avoid race condition: - admin closes orders , gets list - user submits order @ same time , thinks order taken account. the solution have imagined far is: the admin clicks button submits false order indicates orders closed day when form posted, list of orders retrieved when posting order, first check if false order present. if present, validation fail. but think race conditions still possible. is there possibility manage @ database level ? example, when closing commands, add constraint in database on date (date new orders must @ least data of following day) ? you can use atomic decorator database transaction in order check false order. if add check within atomic decorator check race condition can throw error , reset closing day admin order. https://doc...

c - gcc can't find define in header -

i'm using header called lib.h organize source code. header like: #define tot_rep 10 #define tot_pat 10 #define time_rep 15 the source file include header, when compile gcc i'm getting this: error: ‘time_rep’ undeclared (first use in function) so tried compile gcc -e -dm , got this: ... #define sigusr2 12 #define time_rep 15 #define ____mbstate_t_defined 1 #define __sigrtmin 32 ... i tried gcc -e , in outuput found macro replaced value. what can solve this? edit: code time_rep used this: while((!ending|| *(shmaddress+0)!=0)&& quitsignal==0){ totfolder=0; buf=(char*)calloc(2,sizeof(char)); patientstring=(char*)calloc(2,sizeof(char)); sleep(time_rep); while(read(fd,buf,sizeof(char))>0){ /*read file , data*/ } } edit 2: tried rename lib.h , seems work can't understand why if gcc -e -dm found macro can't compile code. anyway answer woodrow barlow: i have lib.h , rep.c rep.c includ...

c# - Passing Parameter From Main to Detail in MVVMCross -

i trying pass selected item list detail view, myitem null in detailviewmodel though not in myviewmodel . myviewmodel.cs public virtual icommand itemselected { { return new mvxcommand<myviewmodel>(item =>{selecteditem = item;}); } } public myviewmodel selecteditem { { return _selecteditem; } set { _selecteditem = value; // myitem not null here!!! showviewmodel<mydetailviewmodel>(new { date = date, myitem = _selecteditem }); raisepropertychanged(() => selecteditem); } } mydetailviewmodel.cs public class mydetailviewmodel: mvxviewmodel { private myviewmodel _myitem; public void init(datetime date, myviewmodel myitem = null) { // myitem null here!!! _myitem = myitem; } } you can use parameter object, because can pass 1 parameter. crate nested class parameter this. public c...

Android Help Button setOnclickListener -

my app works after assigning button bbtn setonclicklistener app doesn't load on emulator , gives me following errors : activitymanager: starting: intent { act=android.intent.action.main cat=[android.intent.category.launcher] cmp=com.hawa.hawa_pro/.mainactivity } activitymanager: warning: activity not started, current task has been brought front code: package com.hawa.hawa_pro; import android.os.bundle; import android.app.actionbar.tab; import android.app.activity; import android.app.tabactivity; import android.content.intent; import android.util.log; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.tabhost; import android.content.res.resources; public class mainactivity extends tabactivity { private tabhost mtabhost; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); butt...

php - Unit test method with Silex\Application as parameter -

in project have class sessionmanager sets , clears session variables sticky forms etc. every method in class takes in silex\application object parameter. how can unit test these methods? create silex application object in each test method? i'm new silex , unit testing , not sure how handle this. example of 1 method: public static function setmessage($message, $messageclass, application &$app) { // store message array, content , class keys $app['session']->set('message', array( 'content' => $message, 'class' => $messageclass )); } firstly think $app should not dependency of sessionmanager; $app['session'] should be. should dependency of object (ie: passed constructor) not of individual method. but doesn't change tactic solving problem. need create mock of session, covers dependent method need call, eg: // in test class // ... public function setup(){ $mockedsession = $th...

unity3d - Colliding objects bouncing off when isTrigger is true instead of passing through -

i have looped through game objects set istrigger property before collision occurs though property true collision object still occurs. please see relevant code below: void oncollisionenter2d(collision2d col) { if (col.gameobject.tag == "object1") { (int = 0; < badguys.count; i++) { badguys[i].getbadguygameobject().getcomponent<collider2d>().istrigger = true; } } else if (col.gameobject.tag == "object2") { // collision object1 occurs before object2, though istrigger true colliding object doesn't pass through badguys game objects, bounces off on collision } else if (col.gameobject.tag == "object3") { (int = 0; < badguys.count; i++) { badguys[i].getbadguygameobject().getcomponent<collider2d>().istrigger = false; } } else if (col.gameobject.tag == "badguy") { } } collision object1 occurs before object2, though ist...

rabbitmq - Celery, route all tasks in a Django project to a specific queue -

i have machine runs 2 copies of same django project, let's call them a , b , , want use celery process background tasks. i set supervisor launch 2 workers, 1 each project, given tasks have same names in both projects, tasks run wrong worker. my next step use different queue each worker, using -q queuename parameter. using rabbitmqctl list_queues see both queues created. command i'm using issue workers is python3 -m celery worker -a project -l info -q q1 --hostname=celery1@ubuntu and python3 -m celery worker -a project -l info -q q2 --hostname=celery2@ubuntu the question is, how route tasks project a queue a , , tasks project b queue b ? yes, i've seen can add parameter task decorator select queue, i'm looking global setting or that. edit 1 : i've tried using celery_default_queue doesn't work, setting gets ignored. i've tried creating dumb router, this: class myrouter(object): def route_for_task(self, task, args=none, kwargs=no...

java - Troubles with AndroidSlidingUpPanel with Eclipse - Error Inflating class -

Image
i'm trying use androidslidinguppanel library (in eclipse) , have error: 04-19 20:09:48.413: e/androidruntime(13760): java.lang.runtimeexception: unable start activity componentinfo{com.mendozatourapp/com.mendozatourapp.activitys.mapsactivity}: android.view.inflateexception: binary xml file line #8: error inflating class com.sothree.slidinguppanel.library.slidinguppanellayout this layout: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".demoactivity" > <com.sothree.slidinguppanel.slidinguppanellayout xmlns:sothree="http://schemas.android.com/apk/lib/res-auto" android:id="@+id/sliding_layout" android:layout_width="match_par...

regex - regular expression for title case - Python -

i need find combination of 2 consecutive title case words. this code far, text='hi name moh shai , python code regex , needs expertise' rex=r'[a-z][a-z]+\s+[a-z][a-z]+' re.findall(rex,text) this gives me, ['moh shai', 'this is', 'python code', 'needs some'] however, need combinations. like, ['moh shai', 'this is', 'python code', 'needs some','some expertise'] can please help? you can use regex lookahead in combination re.finditer function in order desired outcome: import re text='hi name moh shai , python code regex , needs expertise' rex=r'(?=([a-z][a-z]+\s+[a-z][a-z]+))' matches = re.finditer(rex,text) results = [match.group(1) match in matches] now results contain information need: >>> results ['moh shai', 'this is', 'python code', 'needs some', 'some expertise'] edit: it's worth, don...

regex - How to use parse special characters literally in Apache rewrite rule? -

so have apache rewrite rule: rewriterule ^news.php?viewstory=([0-9]+)$ index.php?page=news&viewstory=$1 it's needed i'm changing structure of website, , need take account old structure. it works correctly, apart 1 thing. need parse ? character middle part ( ^news.php?... ) literally - not take special character. want other special characters work normally. what's correct way this? can't find working solutions anywhere. you can't use query string way. need use query string in condition check if there. use captured backreference in rule. let me know how works you. rewriteengine on rewritecond %{query_string} ^viewstory=([0-9]+)$ rewriterule ^news\.php$ index.php?page=news&viewstory=%1 [r=301,l]

multithreading - Threads and Processors -

i'm learning multithreading, threads, threadpools, , such. have read number of threads cannot more number of logical processors computer has (or @ least there no advantage gained since cpu cannot handle more). so expected behavior if write code created hundreds of threads on computer say, 12 logical processors? queue up? wait each other? or give error? if have process benefit 100 continuously running threads, have 12 cores, best way handle this? open task manager see hundreds of processes , thousands of threads running. how work? also, if i'm running program in windows, bunch of other applications running (ie. chrome, ms excel, skype, ect...), , perhaps bunch of background services (ie. windows defender, wifi services, ect...) these other applications take logical processors, decreasing number of logical processors available threaded program? as thilo hinted at, modern personal computers perpetually creating, executing, , destroying dozens if not hundreds of th...

pandas - Map column names if data is same in two dataframes -

i have 2 pandas dataframes df1 = b c 1 2 3 2 3 4 3 4 5 df2 = x y z 1 2 3 2 3 4 3 4 5 need map based on data if data same map column names enter code here output = col1 col2 x b y c z i cannot find built-in function support this, hence loop on columns: pairs = [] col1 in df1.columns: col2 in df2.columns: if df1[col1].equals(df2[col2]): pairs.append((col1, col2)) output = pandas.dataframe(pairs, columns=['col1', 'col2'])

symfony1 - Symfony 1.2 to 2.3 migration -

i've got pretty big symfony 1.2 project migrate. first, modified .htaccess can have pages handled symfony 2. what i'd do, make migration smoother, able render sf2 action/templates/methods/... inside sf1. i added autoloader sf1 app, can access twig rendering methods , other stuff. but how can call sf2 action ? for example, if want migrate footer first, need php methods, not rendering. in sf1 component, should ? if you've got suggestion way of migrating, don't hesitate ! edit 1 : apparently, way render full twig template, and/or in template call other partial twig templates render(url, params) . here sf1 code able render twig templates : public static function gettwig() { require_once __dir__.'sf2_path/vendor/twig/extensions/lib/twig/extensions/autoloader.php'; twig_autoloader::register(); $loader = new twig_loader_filesystem( __dir__.'sf2_path/sf2/src/vendor/bundle/'); $twig = new twig_environment($loader, array( ...