Posts

Showing posts from June, 2010

plsql - How to use sum() function inside stored procedure in oracle? -

the example below works fine , return rows. need summary of rows. declare x number; cursor c1 select sal,deptno emp; rw c1%rowtype; begin x:=0; open c1; loop fetch c1 rw; in 1..rw.deptno loop x:=x+rw.sal; end loop; exit when c1%notfound; dbms_output.put_line(x); end loop; close c1; end; / suppose have 3 employees , every employee's has different salary. salary has due 10 months , 20 months , 30 months. salary due long time. want add 2% bonus amount salary every month way: the below description single employee 10 months: month-1 salary = 800 => 800*2% = 16.00 => total = 800+16 =816 month-2 salary = 816 => 816*2% = 16.32 => total = 816+16.32 =832.32 ............................................................................ month-10 salary = 956.07 => 956.07*% = 19.12 => total = 956.07+19.12 =975.20 the months-1 total salary=816. month-2 salary=816. continue 10 months.every e...

java - Adding text at a position relative to a specific word -

i have pdf document text " approver name ". unique , appears once. i'm trying put image right side of text "approver name" . able insert image using below. need put on right side of " approve name " text. way position of text , keep image next text. image img = image.getinstance(resource); img.setabsoluteposition( (pagesize.postcard.getwidth() - img.getscaledwidth()) / 2, (pagesize.postcard.getheight() - img.getscaledheight()) / 2); document.add(img); what way position of text , keep image next text. why not ask stackoverflow these 2 questions? searching words in pdf , extracting using itext in android is possible find text position itext

mysql - Error "PHP Error wasArray to string conversion" -

Image
i create project using codeigniter now. but, got error message "php error wasarray string conversion". what's wrong? before... this controller: public function index($page = 'dashboard') { $data['num_rows'] = $this->admin_produk_model->count_product(); $this->load->view('admin/templates/header', $data); $this->load->view('admin/templates/sidebar', $data); $this->load->view('admin/pages/' . $page, $data); $this->load->view('admin/templates/footer', $data); } my model: public function count_product() { $this->db->select('*')->from('produk'); $q = $this->db->get(); return $q->num_rows(); } my view: <span class="info-box-number"><?php echo ['num_rows'];?></span> $q->num_rows() in model returns object , passing object view correctly, can use $num_rows in view file sh...

Read from file negative numbers C++ -

i have numbers file , of them negative. so, how can that? (c++) now i'm trying (without special): u1.txt file: 4 5 -1 6 -2 my code: ifstream fd(fd); int n1,n2,n3,n4,n5; fd>>n1>>n2>>n3>>n4>>n5; your code correct, except typo n4 missing. this: ifstream fd("u1.txt"); int n1,n2,n3,n4,n5; fd>>n1>>n2>>n3>>n4>>n5; will expect, modulo error conditions.

Select and update same table and row in one connection in mysql -

this may seem repeat question, seems questions involving more 1 table. when row in table selected, need +1 view count in same row. know can't use trigger or 2 statements in same query, both of these things done single connection database? preferred method both select row , +1 view field? it can done in same connection, can't think of way done using 1 query. here how in single transaction; start transaction; update tbl set view=view+1 id = 10; select * tbl id = 10; commit; a second "better" method can eliminates having read tbl table twice. update tbl set view = (@viewscount := view + 1) id = 10; and new value of views count this select @viewscount; a third way utilizing last_insert_id() function so update tbl set view = last_insert_id(view) + 1 id = 10; then new view count need execute query after update. can not execute other queries after update otherwise not intended value. select last_insert_id();

sql - full text search with multiple text input -

i'm trying full text search 2 text input fields. public function searchmatch() { $hex = input::get('hex'); $rgb = input::get('rgb') $products = db::table('products')->whereraw( "match(hex,rgb) against(? in boolean mode)", array($hex,$rgb) )->get(); return view('search')->with('products', $products); } however not work. tried storing both inputs array , did not work, works if use 1 input. best way around it? i'm using laravel 5.0. have looked solution across site have not found one. my view form looks this: {!! form::model(null, array('route' => array('match.search'))) !!} <ul> <li><div id="hex">hex:{!! form::text('hex') !!}</div></li> <li><div id="rgb">rgb:{!! form::text('rgb') !!}</div></li> <li><div id="picked"></div></li...

ios - UITableViewCell size -

i have table view cells in ios app. thing when cell loads need layout stuff on relative size of other elements. problem can't size because there no viewwillappear or viewdidload methods, have actual bounds(with autolayout , constraints applied). best way work cell's geometry , sizes in ios, can tell me ? auto layout , self-sizing cells (in ios 8). the layout system determine size of "stuff" in cells, , proper constraints determine cell's height.

javascript - CDATA showing up in my HTML page. Why? -

i have html page when load on phone there long text begins "cdata". didn't add page. minified , concatenated javascript gulp 1 file. have velocity.js , jquery libraries loaded. when reload page couple of times long text gone. how can rid of issue? have coded on own , didn't use libraries expect ones mentioned above. i grateful help! thanks! i think problem page speed script, inside script can see these lines: <script pagespeed_no_defer="">//<![cdata[ (function(){var g=this,h=function(b,d){var a=b.split("."),c=g;a[0]in c||!c.execscript||c.execscript("var "+a[0]);for(var e;a.length&&(e=a.shift());)a.length||void 0===d?c[e]?c=c[e]:c=c[e]={}:c[e]=d};var l=function(b){var d=b.length;if(0<d){for(var a=array(d),c=0;c<d;c++)a[c]=b[c];return a}return[]};var m=function(b){var d=window;if(d.addeventlistener)d.addeventlistener("load",b,!1);else if(d.attachevent)d.attachevent("onload",b);els...

javascript - Node.js - Call a system command or external command -

i've issue node.js. python, if wanted execute external command, used this: import subprocess subprocess.call("bower init", shell=true) i've read child_process.exec , spawn in node.js can't want. , what's want? i want execute external command (like bower init ) , see output in real time , interact bower itself. thing can receive final output don't allow me interact program. regards edit : saw this question answer doesn't work here. want send input when external program needs it. how this? var childprocess = require('child_process'); var child = childprocess.spawn('bower', ['init'], { env: process.env, stdio: 'inherit' }); child.on('close', function(code) { process.exit(code); }); seemed work me

javascript - Node.js getting around 'listener must be a function' error -

this question has answer here: javascript: possible pass variable callback function assigned variable? 4 answers i using node.js , steam-node write couple of bots steam (stored on array), each bot has own account , stuff. so, begin, here's part of code: function onlogon(index){ console.log('[steam] logged in on bot ' + index); bots[index].setpersonastate(steam.epersonastate.online); /*do other stuff*/ } (var = 0; < bots.length; i++){ /*foreach of bots, assign loggedon listener */ bots[i].on('loggedon', onlogon(i)); } and code giving me 'listener must function'. now, know error means, should set event listener this: bots[i].on('loggedon', onlogon); but doesnt work, because need pass variable event. i this: for (var = 0; < accounts.length; i++){ bots[i].on('loggedon', function() { ...

angularjs - Angular: 'Access-Control-Allow-Origin' header is present on the requested resource -

i've read alot of same or similar questions , answers configure server. client app angular.js "ionic" server app node.js , deployed on heroku . here server configuration: // set cors resource sharing app.use(function(req, res, next){ res.header('access-control-allow-origin', '*'); res.header('access-control-allow-methods', 'get,put,post,delete'); res.header('access-control-allow-headers', 'content-type, authorization'); res.header('access-control-allow-credentials', true); next(); }) note: client communicate server when run server locally my client app fail make http request , getting error: xmlhttprequest cannot load https://myheroku.herokuapp.com/api/x. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8100' therefore not allowed access. response had http status code 503. here request header: accept:*/* accept-encod...

android - Change EditText hint color when using TextInputLayout -

i using new textinputlayout design library. able show , change color of floating label. unfortunately actual edittext hint white. i have tried changing hintcolor in xml, styles, , programmatically , tried using android.support.v7.widget.appcompatedittext edittext hint shows white. here xml textinputlayout , edittext <android.support.design.widget.textinputlayout android:layout_width="match_parent" android:layout_height="wrap_content" android.support.design:hinttextappearance="@style/greentextinputlayout"> <edittext android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/city" android:textcolorhint="@color/black" android:hint="@string/city" /> </android.support.design.widget.textinputlayout> and here style using textinputlayout (i tried making hinttextcolor attribute black didn't...

Android Listview OnDragListener Item Position On Drop -

i attached listener on listview in main activity such: mylistview.ondraglistener(...); inside getview() of custom adapter, have ontouchlistener starts dragshadowbuilder renders image of specific listview item can follow finger around. what need in main activity somehow tell "position" of mylistview dropping image in. how can this? i've tried setting tags in custom adapter, problem entire listview view ondraglistener can't differentiate between items inside listview. bad can't use onitemclicklistener... any ideas? thanks!

rust - Recovering from `panic!` in another thread -

i know in rust there no try/catch, , can't throw rolling save thread panicking. i know should not create , handle errors this. example's sake. however, wondering best way recover panic is. have now: use std::thread; fn main() { println!("hello, world!"); let h = thread::spawn(|| { thread::sleep_ms(1000); panic!("boom"); }); let r = h.join(); match r { ok(r) => println!("all well! {:?}", r), err(e) => println!("got error! {:?}", e) } println!("exiting main!"); } is there better way handle errors other threads? there way capture message of panic? seems tell me error of type any . thanks! putting aside "you should using result possible," yes, how catch panic in rust. keep in mind "recover" perhaps not best way of phrasing in rust. don't recover panics in rust, isolate them, detect them. there no on error resume ...

xamarin.forms - Add ios project to xamarin forms solution with droid project -

i've got xamarin forms solution pcl , .droid project. want add ios solution. how do this. add dialog can select add new project, seems add lot more....so solution first created without ios checkmark.... btw. i'm using xamarin studio best regards add new empty ios project. add xamarin.forms nuget package. substitute appdelegate class one: [register ("appdelegate")] public class appdelegate : formsapplicationdelegate { public override bool finishedlaunching (uiapplication application, nsdictionary launchoptions) { xamarin.forms.forms.init(); loadapplication (new app ()); return base.finishedlaunching(application, launchoptions); } }

python - Get value of div and other elements on button click -

i have html form consists of divs , ul element. want data on button click. know how when there input type element involved how deal div's , list elements? html <div class="boxinner"> <form id="my_form" method="post"> <div class="inner-box-header"> %s </div> <div class="inner-sub-header"> %s </div> <div class="inner-box-footer"> <ul> <li> <img src="images/assets_icon_location.png" style="height:13px;width:10px;float:left;margin-right:3px;" alt=""> <span class="image-side-text">%s</span></li> <li id="ip-location">&#9899<span>%s - %s</span></li> </ul> </div> <div class="titlebox"> <input type="submit" value="cl...

c# - Value not change by method they remain same -

i want change values using method. values change in method not outside of remain same. trying change these value method 1st time have no idea can change or not. reference or :) code : method :- void weaponupdatemethod (int objupdatevalue, float time, string updatemoney, string savedata, float slidervalue) { buttonclick.play (); int t = objupdatevalue; if (t < 1 && totalmoney > 5000) { t = 1; totalmoney -= 5000; time = 12f; } else if (t != 2 && t < 2 && totalmoney > 10000) { t = 2; totalmoney -= 10000; time = 15f; } else if (t != 3 && t < 3 && totalmoney > 14000) { t = 3; totalmoney -= 14000; time = 17f; } else if (t != 4 && t < 4 && totalmoney > 25000) { t = 4; totalmoney -= 25000; time = 20f; } if (t == 0) { updatemoney = "" + 5000; } else if...

javascript - Issue with merging and reordering two arrays of objects -

i'm trying figure out how merge 2 arrays of objects. here's need do: field property unique identifier of each object output needs have objects listed in originalarray , including objects in originalarray not exist in localstoragearray order of localstoragearray needs maintained, attention paid previous requirement (order should be: bar , bee , foo , baz ) output needs contain following property values localstoragearray : hidden , width ( field give-in, since identifier) all other properties of originalarray need maintained in output here's wack @ it: var outputarray = []; localstoragearray.foreach(function(localitem){ originalarray.foreach(function(originalitem){ if(originalitem.field === localitem.field){ var item = json.parse(json.stringify(originalitem)); item.hidden = localitem.hidden; item.width = localitem.width; outputarray.push(item); } }); }); full js fiddle i able o...

ruby on rails - Getting NameError while linking Dragonfly gem to index.html.erb -

i have linked dragonfly gem project , uploads images creating posts via _form, when i'm trying add these created posts index.html.erb alltogether uploaded using dragonfly-gem images, shows me nameerror. have made operation in few projects, in project have no idea error comes from. here case: nameerror in posts#index undefined local variable or method `posts' #<#:0x66f9d20> extracted source (around line #5): 5. <%= link_to image_tag(posts.image.thumb('64x64!').url) %> posts controller: class postscontroller < applicationcontroller before_action :find_post, only: [:show, :edit, :update, :destroy] before_action :authenticate_user!, except: [:index, :show] def index @posts = post.all.order("created_at desc") end def show @post = post.find(params[:id]) end def new @post = current_user.posts.build end def create @post = current_user.posts.build(post_params) ...

java - MySQL error store boolean value into tinyint -

class code this of code class code may help. private resultset rs; private connection cn; private statement st; public void insertdata(string data) { try { st.executeupdate(data); { joptionpane.showmessagedialog(null, "data berhasil disimpan"); } } catch(exception e) { joptionpane.showmessagedialog(null, "gagal insert data"); } } insertdaftar class public class insertdaftar implements daftarinterface { public string nama; public boolean kuasa; code cd = new code(); public void setnama(string nama){ this.nama=nama; } public void setkuasa(boolean kuasa){ this.kuasa=kuasa; } public void akun(){ string data = "insert akun (nama,kuasa)"+"values('"+this.nama+"','"+this.kuasa+"')"; cd.insertdata(data); } i have created code boolean radio button. boolean akun_...

Xcode - account already has valid iOS Distribution Certificate -

my developer team has added new distribution certificate our apple developer account. downloaded it, , on keychain. however, message in xcode: you have valid ios distribution certificate in member center, not installed locally. if signing identity installed on mac, can export developer profile on mac , import on mac. can revoke current certificate , request new one. when go preferences > accounts > view details, see 1 certificate signing identity "ios development". how add new distribution certificate? thought enough install on keychain. when try drag certificate keychain signing identities in view details section, doesn't work because can't drag in there. i thought downloading distribution certificate enough have "installed locally" xcode said, apparently it's not effective. any or advice appreciated. thanks. xcode / preferences / accounts - apple id, member of developer team? bottom right (of accounts tab), under team nam...

batch file - Automatically disable mouse acceleration - Windows -

i have laptop , use mouse it. don't acceleration while using mouse. have disable acceleration every time plug mouse. there way automatically disable mouse acceleration, whenever plug mouse? know u can script un udev recognizes mouse plugged , auto disable mouse acceleration... how do on windows ? believe not possible simple batch-file. can use windows api in c++: you can register device notifications (like plugging in usb mouse) using registerdevicenotification handle hrecipient = hwnd; // window handle returned createwindow guid interfaceclassguid = { 0x378de44c, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd }; // guid_devinterface_mouse dev_broadcast_deviceinterface notificationfilter; zeromemory(&notificationfilter, sizeof(notificationfilter)); notificationfilter.dbcc_size = sizeof(dev_broadcast_deviceinterface); notificationfilter.dbcc_devicetype = dbt_devtyp_deviceinterface; notificationfilter.dbcc_classguid...

c# - Make whole SSRS report repeat by groups -

i'm not sure of best title question. i have particular problem seems pretty common haven't found way solve yet. let's have rdlc report customers, , has 3 sections subreports: customer_info (name, phone, e-mail) items observations as page has 21cm , report grows horizontally, need repeat whole report of sections after every 4 customers. if have 5 customers, there 3 pages(let's every subreport takes 1 page) first 4 customers, , 3 pages(with every section once again) 1 customer. is possible? doesn't seem somehing out of ordinary, can't figure how make work. everytime there more 4 customers, report breaks layout trying accommodate records in new table below tables of each subreport. expected result bring of exceeding data new pages. thanks in advance. edit: i made fiddle picture i'm trying achieve: report @ moment: <html> <head> <meta content="text/html; charset=utf-8" http-...

html - Container div not Aligning properly -

i have container div not aligning properly, nor can keep divs inside container div aligned right or left. keeps on coming out of main div or container. here's simple homepage design divs not indenting according layout: #container{ background-color:white; width:100%; height:1200px; } #logo{ background-color:yellow; width:30%; height:100px; float:left; } #header{ background-color:green; width:100%; height:100px; float:left; } #navigation{ width:100%; height:40px; background-color:white; float:left; } #webname{ background-color:gray; width:70%; height:100px; float:right; } #mainclass{ width:100%; height:950px; float:left; } #asideright{ background-color:red; width:10%; height:950px; float:right; } #asideleft{ background-color:purple; width:20%; height:950px; float:left; } #selection{ background-color:yellow; width:70%; height:950px; float:center; } #footer{ background-color:green; width:100...

java - SwipeRefreshLayout doesn't update list view -

i wanted add swipe refresh listview in fragment doesn't seem work doesn't update list view @ all. here how activity works: users open picturefragment list of images (listview) shown. users press "add button" open uploadimageactivity add in image. once done, uploadimageactivity close , users picturefragment (not updated latest image upload yet). user swipes down update, << doesn't update latest image listview! hope kind soul can me resolve this. public class picturefragment extends fragment { private listview listview; private int smiley_id; private string title, date, caption, image; private imagebutton addpicbutton; private swiperefreshlayout swiperefreshlayout; private pictureadapter adapter; private tabledatabase tabledatabase; private cursor cursor; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bun...

google chrome - Got 400 error for pre-flight options CORS token request from OWIN-based WebAPI -

it strange. i tried make cors request webapi2 (owin-based) gain authentication token. it fails every other times. 1st request fails, 2nd request go through. , 3rd fails, 4th go through. i don't understand why working half of times. i check browser request (chrome). the 1 got failed goes options method. 1 went through goes post. but use post method headers 'content-type': 'application/x-www-form-urlencoded' so guess question why sometime chrome/fire fox send preflight request sometime doesn't. btw, works totally fine in ie. you correct both chrome , firefox use preflight options request. so, prior executing post, chrome/firefox sends request options verb. if not receive response server tells browser allowed send cross domain request, you'll error , subsequent post not post. you have enable options in web.config (or using 1 of approaches listed in article): http://www.asp.net/web-api/overview/security/enabling-cross-origin-reques...

c++ - Is reading inactive union member of the same type as active one well-defined? -

this question has answer here: accessing same-type inactive member in unions 1 answer consider following structure: struct vec4 { union{float x; float r; float s}; union{float y; float g; float t}; union{float z; float b; float p}; union{float w; float a; float q}; }; something seems used in e.g. glm provide glsl-like types vec4 , vec2 etc.. but although intended usage make possible vec4 a(1,2,4,7); a.x=7; a.b=a.r; , seems undefined behavior, because, quoted here , in union, @ 1 of data members can active @ time, is, value of @ 1 of data members can stored in union @ time. wouldn't better e.g. use define structure following? struct vec4 { float x,y,z,w; float &r,&g,&b,&a; float &s,&t,&p,&q; vec4(float x,float y,float z,float w) :x(x),y(y),z(z),w(w), r(x),g(y),b(...

android - Rotate marker to the device heading at precise location when map is rotating. -

Image
using new version of mapsforge 0.5.1, map rotates fine onsensorchanged event. have added custom gps location marker @ gps point on onlocationchanged event. when map rotates, marker rotated point towards device heading in google maps using following code in marker's draw method. android.graphics.canvas androidcanvas = androidgraphicfactory.getcanvas(canvas); androidcanvas.save(); float px = (float) canvas.getwidth()/2; float py = (float) canvas.getheight()/2; androidcanvas.rotate(degree, px, py); canvas.drawbitmap(bitmap, left, top); androidcanvas.restore(); however when map dragged, marker's position disorients previous point of gps location. how calculate px , py value keep marker @ precise point of gps location on map when map rotating , marker pointing device heading. i know bit old, future researches found solution : first extend mapsforge marker , override draw() method copy paste content of draw method marker then add following in last conditio...

dynamic - p:spinner p:ajax and f:param mixed together, bean method executed multiple times -

i'm developping primefaces 4.0, jsf mojarra 2.1.7 , jboss_7.1.1_final. the tool i'm creating dialog window showing datatable dynamic columns (p:columns) those dynamic columns show pspinner : <p:spinner id="updateqj_#{colindex}_#{rowqj.idqbt}" widgetvar="updateqjjs_#{colindex}_#{rowqj.idqbt}" stepfactor="1" min="0" max="#{rowqj.qbttype}" value="#{rowqj.quantitedujour(qjcolonne.property)}" onkeydown="return false;" styleclass="editqj" rendered="#{not verrouille}" title="cliquez ici pour modifier la quantité journalière" > <p:ajax listener="#{recherche.updateqj}" update="@this, :formrecherche:growl" process="@this"/> ...

java - Validate with Gson -

i want check valid integer's when deserializing gson , report errors resultlist object. so have (register integer type) gsonbuilder: gson.registertypeadapter(integer.class, new integerdeserializer(resultlist)); and integerdeserializer looks like @override public integer deserialize(jsonelement element, type arg1, jsondeserializationcontext context) throws jsonparseexception { string integer = element.getasstring(); try { integer value = integer.valueof(integer); return value; } catch (numberformatexception e) { resultlist.adderror("?? fieldname ?? ", "invalid number"); return null; } } is there way field name of current integer parsed? if works can use generic way checking json fields.

cql - Understanding internal data storing by cassandra -

i have table create table comment_by_post ( postid uuid, userid uuid, cmntid timeuuid, cmnttxt text, cmntby text, time bigint, primary key ((postid, userid),cmntid) ) here internal data in table rowkey: 4978f728-0f96-11e5-a6c0-1697f925ec7b:4978f728-0f96-12e5-a6c0-1697f92e537a => (name=d3f02a30-126f-11e5-879b-e700f669bcfc:, value=, timestamp=1434270721107000) => (name=d3f02a30-126f-11e5-879b-e700f669bcfc:cmnttxt, value=636d6e743434, timestamp=1434270721107000) ------------------- rowkey: 4978f728-0f96-11e5-a6c0-1697f925ec7b:4978f728-0f96-12e5-a6c0-1697f92eec7a => (name=465fee30-126f-11e5-879b-e700f669bcfc:, value=, timestamp=1434270483603000) => (name=465fee30-126f-11e5-879b-e700f669bcfc:cmnttxt, value=636d6e7432, timestamp=1434270483603000) => (name=4ba89f40-126f-11e5-879b-e700f669bcfc:, value=, timestamp=1434270492468000) => (name=4ba89f40-126f-11e5-879b-e700f669bcfc:cmnttxt, value=636d6e7431, timestamp=1434270492468000) =...

linux - how to ssh run a tail and then send data to a mysql database -

this code ssh's , runs tail command on remote hots. pass tailed data mysql database using local script called insertperfmon.sh. how pass data generated in ssh session local shell script insertperfmon.sh. local shell script going send data database. however, need there first. ( ssh -nq -o stricthostkeychecking=no \ -i $pem_path/$pem_file $user@${host} -p $remote_port \ tail -n 5 $remote_home/data/perfmon* |insertperfmon.sh) if insertperfmon.sh is: #!/bin/bash mydata=$(cat) echo $mydata # process & send $mydata database the following should work: <your_ssh_command> | bash insertperfmon.sh

python - How to setup the same scale for X axis (timestamp) in multiple graphs using matplotlib -

i using python , matplotlib try generate following: 4 charts plotting amount of messages received in system vs delay in processing these messages, in given period of time, in intervals of 5 minutes. that is, x axis shows time moment a moment b (in format " %y-%m-%d %h:%m ") in intervals of 5 minutes, while left y axis shows amount of messages received @ given moment, , right y axis shows delays in processing these messages. now, got plotting both x axes in chart, need timestamps same every graph, is, must start , end @ same point in time, if there no events in times of charts (e.g., chart#1 starts @ 15:50 of 10/5/2015 , stopped @ 14:00 11/5/2015, if in 1 of them events start happening @ 17:00 of 10/5). , that's killer. does know how can this? lot does know how can this? yes. if stack overflow allow non-mcve posts in questions, simplistic answers, saying "yes", spring off box, bring no real experience great community stackover...

actionscript 3 - how to use the text box to change a frame in AS3 -

so making little game. numbers count , when reach number want change frame. e.g. numbers start counting , when reach 10 change frame 20. btw in action-script 3 in document class, create set ter function go frame when condition met. private var _counter:uint = 0; public function counter ():uint { return _counter; } public function set counter (value:uint):void { if (value == _counter) return; _counter = value; if(_counter == 10) gotoandstop(20); } now use counter if real variable: counter += 5; trace(counter); counter = 10; just clear: should not have counter variable in text field only. textfield way display it. should have real number variable, because textfield made string s, not numbers. if want display counter variable in textfield , in set function well: public function set counter (value:uint):void { if (value == _counter) return; _counter = value; textfield.text = _counter.tostring(); //display counter in text if(_c...

c# - Split array into another array -

i have string array this: string[] array = new string[3] {"man(21)", "woman(33)", "baby(4)"}; now want split array scheme: array = new string[6] {"man", "21", "woman", "33", "baby", "4"}; anybody have idea? you can use split , selectmany var result = array.selectmany(x => x.split(new[] { '(', ')' }, stringsplitoptions.removeemptyentries)).toarray();

python - Template include tag: Choose another template if it does not exist -

i include different template depending request. example: suppose request has: request.country = 'spain' request.city = 'madrid' i want include "index.html" view but: ---- if myapp/index_madrid.html exist {% include "myapp/index_madrid.html" %} ---- elif myapp/index_spain.html exist {% include "myapp/index_spain.html" %} ---- else go default version {% include "myapp/index.html" %} how can achieve behaviour in transparent way? mean, like: {% my_tag_include "myapp/index.html" %} {% my_tag_include "myapp/another_view.html" p='xxx' only%} {% my_tag_include "myapp/any_view.html" p='sss' a='juan' %} and achieve cascading loading explained before. thanks one possibility implement kind of logic in view: # views.py django.template.loader import select_template class myview(view): def get(self, request): include_template = sele...

html - PHP - imap count unseen emails gives always '1' as result -

trying count unseen emails in email box, script have counting however, when there no unseen emails result 1 , no 0. idea why? here code have far. php: $hostname = '{imap.example.com:993/imap/ssl}inbox'; $username = 'myemail@example.co.uk'; $password = 'mypass'; $imap = imap_open($hostname, $username, $password) or die("imap connection error"); $result = imap_search($imap, 'unseen'); $new_inbox_msg = count($result); echo $new_inbox_msg imap_search() returns array , not number, according documentation . so instead need: $result = imap_search($imap, 'unseen'); echo count($result); ok, sorry, miss interpreted documentation myself. here explanation of issue: function indeed return array, but array holding 1 result (count) per search attribute handed over. since specify single attribute ('unseen') always single element in array. that elements value number of messages matching ...

java - How can I control android webview activity changes when I change screen orientation? -

import android.app.activity; import android.app.alertdialog; import android.content.context; import android.content.dialoginterface; import android.content.intent; import android.content.res.configuration; import android.graphics.bitmap; import android.net.connectivitymanager; import android.net.networkinfo; import android.os.bundle; import android.support.v4.widget.swiperefreshlayout; import android.support.v4.widget.swiperefreshlayout.onrefreshlistener; import android.support.v7.app.actionbar; import android.support.v7.app.actionbaractivity; import android.view.keyevent; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.webkit.webchromeclient; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.progressbar; import com.gc.materialdesign.views.progressbardeterminate; import java.util.logging.handler; import javax.security.auth.destroyable; /** * created myozawoo on 4/9/15. */ public c...