Posts

Showing posts from January, 2010

apache spark - Does the scala ! subprocess command waits for the subprocess to finish? -

so, have following kind of code running in each map tasks on spark. @volatile var res = (someprogram + filename) ! var cmdres = ("rm " + filename) !; the filenames each map tasks unique. basic idea once first command finishes, second command deletes file. however, notice program complain file not exist. seems subprocess call not synchronous, is, not wait subprocess complete. correct. , if indeed case, how can correct that? as can see in docs , ! method blocks until exit. docs it: starts process represented builder, blocks until exits, , returns exit code. it's possible should checking exit code interpret result , deal exceptional cases. when creating process commands concatenation, better off using seq extensions (as opposed string ones) create processbuilder . docs include helper, might you: // uses ! exit code def fileexists(name: string) = seq("test", "-f", name).! == 0

javascript - Rendering concentric hexes on Canvas -

Image
i've written loop in javascript render rings of concentric hexagons around central hexagon on html canvas. i start innermost ring, draw hex @ 3 o'clock, continue around in circle until hexes rendered. move on next ring , repeat. when draw hexagons way (instead of tiling them using solely x , y offsets) hexagon not divisible 60 not same distance center hex divisible 60 (because these hexes comprise flat edges, not vertices, of larger hex). the problem i'm having these hexes (those not divisible 60 degrees) rendering in off position. i'm not sure if floating point math problem, problem algorithm, problem rusty trig, or plain stupidity. i'm betting 3 out of 4. cut chase, @ line if (alpha % 60 !== 0) in code below. as point of information, decided draw grid way because needed easy way map coordinates of each hex data structure, each hex being identified ring # , id# within ring. if there better way i'm ears, however, i'd still know why rendering off...

io redirection - How To Pipe Java Version in Batch File -

how can find java version , set variable? i've tried this: for /f "tokens=*" %%a in ('java -version | find "version"') (set var1=%%a) but java isn't redirecting output find . post suggested solution java -version 2>&1 | findstr "version" >tmp.txt /f "tokens=*" %%x in (tmp.txt) (set var1=%%x) echo %var1% del tmp.txt but avoid using temp file. java.exe seems output version information @ stderr, correct code is: for /f "tokens=*" %%a in ('java -version 2^>^&1 ^| find "version"') (set var1=%%a) as can see, > , & , | escaped ^ .

html - jQuery Toggle - Sticky on Bottom - Reverse -

i trying make toggle function exact 1 : http://gyazo.com/26fc509c540e5175c07593b57caef386 but have troubles make reverse, contact box must showed down instead up, exact gif file this have right : http://codepen.io/anon/pen/gprvea can me please? thankyou this html : <div class="widget-style" id="widget"><a id="widget" hef="#"> click here more info</a></div> <div class="contact-style" id ="contact" > contact <hr> <p>more information in here</p> <p>and more information in here</p> <p>more information in here</p> <p>and more information in here</p> </div> this css: .widget-style { width: 300px; height: 20px; background-color:black; color:white; font-size:18px; text-align: center; vertical-align:bottom; padding:14px; margin-left:40%; position:fixed; bottom:0; cursor:pointer; } .contact-style {...

mysql - PHP & Laravel: ConvertingVARCHAR value to FLOAT in query -

i have stored in table 2 fields lat , long , these columns have datatype of varchar now in laravel have following variables: $ne_lat = 21.405122657695813; $ne_lng = -102.32061363281252; $sw_lat = 19.984311565790197; $sw_lng = -104.19652916015627; wich want use in query compare against table data this: $agencies = db::table('users') ->whereraw('lat < ? , lat > ? , long < ? , long > ?',[$ne_lat,$sw_lat,$ne_lng,$sw_lng]) i've tried cast this: $agencies = db::table('users') ->whereraw('cast(lat float) < ? , cast(lat float) > ? , cast(long float) < ? , cast(long float) > ?',[$ne_lat,$sw_lat,$ne_lng,$sw_lng]) but doesn't display results (i'm not getting error messages since query shows in json) doesn't show up. doing wrong query? thanks in advance (int)(your value); or can use: intval(string) here sample: <?php echo intval(42); // 42 echo...

reactjs - Render an Element with React -

honestly don't think best title, i've no idea how explain it. so sorry it. i'm trying write component parse links(thar not anchor tag) , emoji , render links or image. for emoji i'm using amazing component: https://github.com/banyan/react-emoji it works well, problem simple links...i don't have found way render links, instead of text of link tag. this code: # @cjsx react.dom @linkify = react.createclass displayname: 'linkify' mixins: [reactemoji] componentdidmount: -> componentwillunmount: -> render: -> <div> {@parselinks(@props.text)} </div> parselinks: (text) -> pattern = /(ht|f)tps?:\/\/[^\"<]*?(?=\s|$|<\/[^a]>)/gi results = text.match(pattern) new_text = text if results , results.length > 0 result in results link_html = react.createelement('a', {href: result}, result) new_text = new_text.replace(result, link_html) ...

c# - How to draw a rectangle on a button click? -

i want when click button, add 1 rectangle form can add in form paint how want can't add shape rectangle click button , searched didn't find solution it here know how it? this code in form paint private void form1_paint(object sender, painteventargs e) { locationx = locationx + 20; locationy = locationy + 20; e.graphics.drawrectangle(pens.black, new rectangle(10 + locationx, 10 + locationy, 50, 30)); } and 1 button code private void button1_click(object sender, eventargs e) { this.paint += form1_paint; } but not working when click button. why not working? the line this.paint += form1_paint; associate event paint of form function form1_paint. it doesn't trigger it. want 1 time, not everytime hit button. to trigger paint event, usual way call invalidate() method of form class. in fact, invalidate method of control . form derivate control , have ac...

html - Navigation bar displaying weirdly after adding new transition -

so added animation navigation bar @ repo.itechy21.com , made drop down text push right side of drop down when want centred. relevant css attached below (along html) css: /* start nav bar*/ #header { height: 100px; margin-left: auto; margin-right: auto; text-align: center; } #content { margin-left: auto; margin-right: auto; padding: 20px; text-align: center } #menu, #menu nav { margin:0 auto; padding:0; position: center; text-align: center } #menu { display: inline-block; list-style:none; background-color: #98bf21; border-radius: 10px; text-align: center } #menu li { float: left; position: relative; list-style: none; text-align: center } #menu > li:hover > ul { display:block; background-color: #98bf21; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; visibility:visible; opacity:1; filter:alpha(opacity=100); } #menu > li > ul { /*animati...

c# - Thread Join() causes Task.RunSynchronously not to finish -

calling _thread.join() causes getconsumingenumerable loop stuck on last element. why behavior occur? public abstract class actorbase : idisposable { private readonly blockingcollection<task> _queue = new blockingcollection<task>(new concurrentqueue<task>()); private readonly thread _thread; private bool _isdisposed; protected actorbase() { _thread = new thread(processmessages); _thread.start(); } protected void queuetask(task task) { if (_isdisposed) { throw new exception("actor disposed, cannot queue task."); } _queue.add(task); } private void processmessages() { foreach (var task in _queue.getconsumingenumerable()) { task.runsynchronously(); } } public void dispose() { _isdisposed = true; _queue.completeadding(); _thread.join(); } } public class sampleactor : actorbase { private strin...

android - How I can be notified when a Facebook page - I don't own- published a new post ? -

i creating news app , want add facebook pages of news websites. dont want pull new posts every 30 minutes example. want notified when there new post. i read real time updates https://developers.facebook.com/docs/graph-api/real-time-updates/v2.3 but says must owner of page or can link app page can't do. is there alternative solution ? there 1 alternative solution: can use app or user token check new posts manually cron job - using page feed endpoint.

playframework - How to change active buttons in a dynamically generated bootstrap pagination? -

Image
i have quiz system, can ask questions on different pages. page 1 shows picture of tree, page 2 of else... , user can write questions specific page. now try implement simple pagination (i have seen example play-computer-base example, dont think need that), cant change pages. this pagination far: when user clicks on 2 , should switch it. therefore implemented navigation-element: <nav> <ul class="pagination"> @for(index <- 1 10){ <li class="@("active".when(index == currentpage))"><a href="@routes.application.index()">@index <span class="sr-only">(current)</span></a></li> } </ul> </nav> the problem within "active".when(index == currentpage) part, not correct @ moment. scala template, there way change active state of current button? just try if condition currentpage inside for loop. should work. <nav...

android - Notification in Service on isolated process throws NPE -

i nullpointer, every time try send notification service runs on isolted service. the exception: java.lang.nullpointerexception @ android.app.notificationmanager.notify(notificationmanager.java:136) @ android.app.notificationmanager.notify(notificationmanager.java:109) @ de.nwo.client.modules.service.nwoservice.createorupdatenotification(nwoservice.java:66) @ de.nwo.client.modules.service.nwoservice.access$000(nwoservice.java:23) @ de.nwo.client.modules.service.nwoservice$1.run(nwoservice.java:47) @ android.os.handler.handlecallback(handler.java:730) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:5103) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.j...

asp.net web api - OWIN Authentication Server for multiple applications -

i in process of implementing solution has mvc client (lets call client @ localhost:4077/) webapi service (called api @ localhost:4078/) i have implemented owin oauth in api wanted know whether owin implemented in separate solution (lets call auth @ localhost:4079/token) generate token client, client passes api (as bearer authorisation token) the reason querying there additional webapi services accessed client , i'd use owin between client , api services. the issue not sure if token generated auth service used authorise requests on client , api services. has implemented , if provide example, pretty new owin , oauth appreciated separating authorization server resource server extremely easy: work without code if use iis , if have configured identical machine keys on both applications/servers. supporting multiple resource servers bit harder implement owin oauth2 server if need select endpoints access token can gain access to. if don't care that, configure res...

android - How to call and send a string to Tab List Fragment from fragment activity -

i have 3 tabs list fragments('a','b' , 'c') , have navigation drawer list contains list of data filtering content of lists in 3 tabs. want when click on item in navigation drawer list, current tab content should refresh , should show new data in list. if lets in tab , select item navigation drawer, how send string tab a, tab list content refreshed? fragment activity getactionbar().setdisplayshowtitleenabled(false); getactionbar().sethomebuttonenabled(false); getactionbar().seticon(r.drawable.clip1); actionbar = getactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); actionbar.setdisplayoptions(0, actionbar.display_show_title); settitle("records"); actionbar.tablistener tablistener = new actionbar.tablistener(){ @override public void ontabselected(android.app.actionbar.tab tab, android.app.fragmenttransaction ft) { // todo auto-generated method...

cassandra - Spark Master does not start with DSE 4.7 and OpsCenter 5.1.3 -

i upgraded datastax 4.6.3 => 4.7, , having trouble running spark. problem seems spark master not configured properly. use opscenter 5.1.3, , started 3 node analytics cluster. strangely, nodes has setting spark_enabled=0, , had set 1 manually. now, however, spark master not configured properly. in /var/log/cassandra/system.log, long output of: [spark-worker-init-0] 2015-06-13 21:59:54,027 sparkworkerrunner.java:49 - spark master not ready @ (no configured master) info [spark-worker-init-0] 2015-06-13 21:59:55,028 sparkworkerrunner.java:49 - spark master not ready @ (no configured master) info [spark-worker-init-0] 2015-06-13 21:59:56,028 sparkworkerrunner.java:49 - spark master not ready @ (no configured master) i try run dse spark, , following error: java.io.ioexception: spark master address cannot retrieved. should not happening dse 4.7+ unless cluster on 50% down or booted in last minute. @ com.datastax.bdp.plugin.sparkplugin.getmasteraddress(sparkplugin.java:25...

Android - Uniform word spacing TextView -

in android app i'm using textview display info. problem have following: words of text appear far last one, while others keep aligned others, in example: hello, how you? my code follows: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:id="@+id/my_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="17sp" android:layout_centerhorizontal="true" android:text="do want app access microphone? (by using feature .........................., because need propulsion .........." /> </relativelayout> how can fix this? thank you

python - Configuring client throughput in simple TCP server -

i given sample project goes this: client connects server b. a sends packet b, b returns same packet a. client sending throughput configurable measure turnaround time per packet. now step 3 confusing me. using python, way can think of "configuring throughput" set delay between characters in string. take string "test" start timer, send "t" server, , have server return it. once server returns it, stop timer , log it. then call sleep() determined amount of time (this configurable part) then same letters e s t logging, time in-between. however, seems silly, because not @ affecting relationship between client , server, setting delay between characters being sent. or missing something? there way of "configuring" client a's throughput, , if so, mean? thank you. you can make client a's throughput configurable - on broader window of 1 second. first of sending single packets 1 characters going 'negat...

python - How to implement variants/variations of a function -

this first question, sincerely apologize posting mistakes sure make. did first search through answered questions, didn't find suitable solution, although recognize might not have searched using correct terminology or keywords. i have general function have evaluated in python. gets passed optimizer (fmin_cobyla), , i'd prefer take single argument. i'd able have option of using different variations (variants? flavors?) of function might controlled flag. since want evaluated doesn't make sense have bunch of if or case statements within function (right?), have if statements around definitions of function variants: if flag==1: def f(x): in range(0,len(x)*3,3): a[i:i+3,i:i+3]=1/x[i/3]*np.eye(3) tmp=np.linalg.solve(a,b) y=somecmodulefunction(tmp) return y elif flag==2: def f(x): in range(0,len(x)*3,3): a[i:i+3,i:i+3]=x[i/3]*np.eye(3) tmp=np.linalg.solve(a,b) y=somecmodulefunctio...

python - What to set `SPARK_HOME` to? -

installed apache-maven-3.3.3, scala 2.11.6, ran: $ git clone git://github.com/apache/spark.git -b branch-1.4 $ cd spark $ build/mvn -dskiptests clean package finally: $ git clone https://github.com/apache/incubator-zeppelin $ cd incubator-zeppelin/ $ mvn install -dskiptests then ran server: $ bin/zeppelin-daemon.sh start running simple notebook beginning %pyspark , got error py4j not being found. did pip install py4j ( ref ). now i'm getting error: pyspark not responding traceback (most recent call last): file "/tmp/zeppelin_pyspark.py", line 22, in <module> pyspark.conf import sparkconf importerror: no module named pyspark.conf i've tried setting spark_home to: /spark/python:/spark/python/lib . no change. two environment variables required: spark_home=/spark pythonpath=$spark_home/python:$spark_home/python/lib/py4j-version-src.zip:$pythonpath

java - Why is this URI valid by RCF 2396 standards? -

i playing around non stringy types application loader i've been developing. typo, forgot include protocol part of specific uri. expected java test fail due invalid uri... statement seems work... uri uri = uri.create("contacts.addresses.genericaddress") to me, theres no standard using dot scheme part... , thought scheme part required? does know why? i'll add comment answer because think it's correct: from java uri documentation: "specified grammar in rfc 2396, appendix a" , appendix allows uri relative path, no host name or scheme. "this.and.that" might file name "this.html" (dot's valid file element name -- i.e., pchars in path segment).

uitableview - How do I access the attribute of a one to many relationship and pass to another tableview? -

so have 2 entities in coredata (a , b). has many bs , b can belong 1 a. have managed display on tableview , when tap cell, should segue tableview controller displays list of bs. using nsfetchedresultscontroller monitor tableview. in didselectrowatindexpath method, have: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { self.tappedindex = indexpath; nslog(@"index tapped %@",self.tappedindex); nslog(@"%@",[self.fetchedmanagedresultscontroller objectatindexpath:self.tappedindex] ); } the output nslog is: <b: 0x1700b1a00> (entity: b; id: 0xd000000000500000 <x-coredata://5a01cf10-0e90-496f-9b84-faf68346d6dc/customer/p20> ; data: { items = "<relationship fault: 0x174221ee0 'items'>"; name = "connie brittani "; phone = 8034233759; }) my question how pass items second tableview. appreciated! so read more on faults , learned it's not error more of u...

hibernate - HibernateDAOSupport vs HibernateTemplate -

i trying understand benefit hibernatedaosupport provides on hibernatetemplate. hibernatetemplate pretty everything. why need extend hibernatedaosupport , gethibernatetemplate , operations rather injecting hibernatetemplate , operations. benefit when dao classes extend hibernatedaosupport. i know not recommended use hibernatedaosupport , hibernatetemplate anymore trying understand difference. this little guess work after skimming through api: it looks @ first there hibernatetemplate hid session , if needed access session daosupport offer that. from hibernatedaosupport javadoc: this base class intended hibernatetemplate usage can used when working hibernate session directly, example when relying on transactional sessions. convenience getsession() , releasesession(org.hibernate.session) methods provided usage style. but getsession method in daosupport deprecated hibernatesession, has same method now. thing left in daosupport, don't in template seems release...

c - Change letter with number -

i'm doing exercise, practice, point receive string of numbers , letters, check if it's letter, transforme number rule a = 10, z = 35 and place in array. operations after. i know how except rule part, no idea how check letter , how replace right number. know there's way like if(string[x] == 'a-z') but i'm neither sure how works, or how pick right number knowing it's letter. there many approaches, more portable others. the following looks the string[x] in array. if successful, pointer difference between , start value. const char *alphanum = "0123456789abcdefghijklmnopqrstuvwxyz"; char *p = strchr(alphanum, string[x]); if (p == null || *p == '\0') { ; // not digit or a-z } else { int value = p - alphanum; // value; } i'll leave handling of a-z op. (convert upper or use array) if code assumes ascii, a z in sequential order: int tovalue(char ch) { if (ch >= 'a' && ...

templates - Magento url routing: how to locate the controller/views for a given url -

Image
i'm new magento , i'm trying find files/code based on url: somedomainfortesting.com/index.php/catalogsearch/result/?q=test i put test domain name above security purposes, in general i'm trying find file(views/controller) above url. i'm new magento. it's complicated, speaking, magento urls have 3 parts (zend framework 1 style) http://somedomainfortesting.com/index.php/front-name/controller-name/action-name the "front name" identifies module folder can find controller in. for example, controllers urls catalogsearch frontname can found in #file: app/code/core/mage/catalogsearch/controllers/ you'd know because in mage_catalogsearch configuration file, there's configued frontname ( <frontname>catalogsearch</frontname> ) #file: app/code/core/mage/catalogsearch/etc/config.xml <routers> <catalogsearch> <use>standard</use> <args> ...

javascript - return first element from array as computed property from Ember controller subclass -

i trying return first element of array computed property template controller. code below. 100% array , template. problem syntax in controller. array works made of work objects. , ideally return first element work. possible in javascript? best. //controller works.js import ember "ember"; export default ember.controller.extend({ firstelement: function () { var arr = this.get('model'); return arr[0]; console.log(arr[0]); }.property('work') }); //template works.js <div class="right"> {{#liquid-with model |currentmodel|}} {{firstelement}} {{/liquid-with}} </div> //route works.js import ember 'ember'; var work = ember.object.extend({ name: '', year: '', description:'', image:'', logo:'', work_id: function() { return this.get('name').dasherize(); }.property('name'), }); var minibook = work.create({ id: 1, name: ...

How to pass or declare array members in c? -

i developed program supposed pass following members of array of double purchase following function: float beverages () { char response; double purchase [8]= {3.50, 3.80, 3.90, 4.20, 4.00, 4.30, 3.00, 3.10}; printf("\nenter order: "); scanf("%c", response); if (response == 'l') { purchase [0]; printf("you have chosen regular long black coffee\n"); printf("that %.2f dollars", purchase [0]); } else if (response == 'l') { purchase [1]; printf("you have chosen large long black coffee\n"); printf("that %.2f dollars", purchase [1]); } else if (response == 'f') { purchase [2]; printf("you have chosen regular flat white coffee\n"); printf("that %.2f dollars", purchase [2]); } else if (response == 'f') { purchase [3]; printf ("you have chosen lar...

oracle - ORA-00947 : Not Enough Values while putting values into a type inside a procedure -

i have created oracle types: create or replace type "results_admin" object ( rownumber number, asset_id varchar2(1000 char), book_id varchar2(10 char), asset_name varchar2(50 char) , book_author varchar2(30 char) , asset_location varchar2(30 char), asset_cat varchar2(50 char), asset_type varchar2(10 char), publisher_name varchar2(50 char), books_available number ); create or replace type "result_admin_temp" table of lms.results_admin; here procedure uses them: create or replace procedure "retrieve_asset_admin" ( aid in asset_details.asset_id%type, aname in asset_details.asset_name%type, acat in asset_details.asset_cat%type, atypeid in asset_details.asset_type_id%type, bauthor in asset_details.book_author%type, aloc in asset_details.asset_location%type, pub in asset_publisher.publisher_name%type, pagenumber in number, asset_cur out sys_refcursor ) v_fpgnbr numbe...

netlogo - Using a breed-own variable in another breed? -

hello trying write code in netlogo in can use own variable named energy of breed named green-cars in breed named red-cars. problem depending of value of variable want create new red-cars command hatch-red car used hatch new turtle of breed can used asking same breed it. using value of energy green-cars variable want use value in yellow-cars context, can do? think in doing in report procedure i'm not familiar kind of procedures. suggestions? this code: breed [green-cars green-car] breed [red-cars red-car] green-cars-own [energy] go ask green-cars [manipulate-cars] end manipulate-cars if [energy] of one-of green-cars > 0 [ let induction sum [energy] of green-cars in-radius 1 let mean (induction / 3) let se ((- kse * (mean - count red-cars))) if se > 0 [ ask one-of red-cars[ hatch-red-cars se [ set shape "cars" set color red set size 1 set xcor (38 + random-float -76 ) ...

opencart - Notice: Error: Could not load language module/magnorcms! in //system/library/language.php on line 39 -

i have installed opencart theme , can watch here: taswikdz.com but have error in header notice: error: not load language module/magnorcms! in //system/library/language.php on line 39 files here: module/magnorcms.php <?php class controllermodulemagnorcms extends controller { protected function index($setting) { $this->language->load('module/magnorcms'); $this->data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_name')); $get_lan_id = $this->config->get('config_language_id'); $this->data['magnorcms_header'] = html_entity_decode(isset($setting['headertitle'][$get_lan_id]) ? $setting['headertitle'][$get_lan_id] : '' , ent_quotes, 'utf-8'); $this->data['message'] = html_entity_decode(isset($setting['description'][$get_lan_id]) ? $setting['des...

javascript - Use TypeScript lib.core.d.ts instead of lib.d.ts -

it seems typescript compiler includes lib.d.ts or lib.es6.d.ts (depending on compiler target). in our application have websocket class defined in lib.d.ts . we're running our application under node.js , not in web browser, don't need of definitions lib.d.ts . instead lib.core.d.ts sufficient (and solve websocket conflict of course). is possible tell typescript compiler global type definition file use? use --nolib compiler option exclude lib.d.ts , add reference lib.core.d.ts in source files. equivalent tsconfig.json "nolib": true . if need node.js definitions, can use definitely typed one .

git - GitHub API returned Url meaning -

take simple api example, https://api.github.com/users/zhuhuihuihui in json formatted response, you'll find following, "following_url":"https://api.github.com/users/zhuhuihuihui/following {/other_user} ", "gists_url": "https://api.github.com/users/zhuhuihuihui/gists {/gist_id} ", "starred_url": "https://api.github.com/users/zhuhuihuihui/starred {/owner}{/repo}" , ok, know following_url , starred_url sub api can call fetch user following, or repos user has starred. but, braces mean? 1 i've made bold . how use them? those placeholders value, need replace actual value in order use links. it serves remind user how access, instance, following_url user. without {/other_user} , url https://api.github.com/users/zhuhuihuihui/following list users followed. with {/other_user} , url https://api.github.com/users/zhuhuihuihui/following/xxx check if follow user xxx .

c# - How to validate this data entry form in ASP.NET Web Forms? -

i new asp.net webforms developer , struggling validating data entry form. should use server-side validation , has using pure c#. wondering if there best approach validate following form instead of have multiple nested if-else statement makes confusion , makes code difficult understand. asp.net form: <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-xs-2">type</label> <div class="col-xs-4"> <asp:textbox id="txttype" runat="server"></asp:textbox> </div> <label class="control-label col-xs-2">category</label> <div class="col-xs-4"> <asp:textbox id="txtcategory" runat="server"></asp:textbox> ...

ios - Phone call from Apple Watch with openSystem API? -

as watched wwdc 2015 session video "introducing watchkit watchos 2" (at 13:29), saw possible make phone calls directly on apple watch opensystem api. how can use api in swift? you can use opensystemurl method, available on shared wkextension object. pass tel: url method initiate phone call. if let telurl=nsurl(string:"tel:5553478") { let wkextension=wkextension.sharedextension() wkextension.opensystemurl(telurl) }

Determine if coordinate is inside region (MKMapView, solve in PHP) -

i'm using mkmapview , send php program visible region (center lat, center lon, span lat, span lon). need determine if coordinate inside region using php. i'm hoping there's standard formula somewhere, haven't found one. i'll keep trying come formula, it's surprisingly complicated (hopefully not as haversine, don't believe have figured out myself). lets try logic $toprightlongitude = $centerlongitude + $spanlongitude/2; if($toprightlongitude > 180 , ($pointlongitude < 0)) $toprightlongitude = $toprightlongitude - 360; // (180*2) - positive becomes negative $bottomleftlongitude = $centerlongitude - $spanlongitude/2; if($bottomleftlongitude< -180 , ($pointlongitude > 0)) $bottomleftlongitude= 360 + $bottomleftlongitude; // negative , become positive $toprightlatitude = $centerlatitude + $spanlatitude/2; if($toprightlatitude > 90 , ($pointlatitude < 0)) $toprightlatitude = $toprightlatitude - 180; // (90*2) - posit...

java - Android- Logic behind setOnClickListener -

i new java/android programming , unfortunately don't under stand logic behind piece of code: button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { // perform action on click } }); i have alredy read whole lot of tutorials unfortunately in no 1 far code gets explained in detail. maybe because it's basic every decent object oriented programmer understand reason structure right away. i wondering why need use new view.onclicklistener() as parameter? setonclicklistener method. in other words why doesn't like button.setonclicklistener( public void onclick(view v) { // perform action on click }); this work? besides not quite sure why onclick method requires paramterer of view v . i quite thankful since rather puzzled. view.onclicklistener interface need implement when want handle click events. in code, doing doing new view.onclickliste...

java - is == operator meant for primitives comparing -

it's written on == checks if 2 objects share same memory reference or not. why getting output false in below code? public class { public static void main(string args[]) { double d1 = new double(12.0); double d2 = d1; d1 = d1 + 1.0; system.out.println(d1 == d2); } } is due autoboxing double gets converted double in line d1 = d1 + 1.0 , == checks primitive values? confused. expected output true . can clear away doubts? i think source of confusion arises line: d1 = d1 + 1.0; lets start beginning. lets call references objects dx , objects ox . to start write: double d1 = new double(12.0); so have reference d1 point object o1 double 12.0 . next write: double d2 = d1; so have reference d1 , reference d2 both point object o1 double 12.0 . next write: d1 = d1 + 1.0; so have new object o2 , repoint reference d1 point @ o2 . never forget immutable means, in java primitive wrapper types always immut...

ios - How to cast controller to a specific protocol instead of a class in Swift? -

this protocol : protocol dbviewanimationtransitioning { var viewforanimation: uiview? { set } } example of usage inside prepareforsegue: : override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if let controller = segue.destinationviewcontroller as? dbviewanimationtransitioning { controller.viewforanimation = sender as? uiview //cannot assign to viewforanimation in controller } } everything fine when cast specific controller f.e. dbfindviewcontroller . need cast specific protocol not class . how accomplish this? because protocol isn't class/struct cannot assign because may struct make no sense because copied. try making class protocol declaring protocol dbviewanimationtransitioning : class

c# - How to find a point given its distance from two other points? -

given points , b on 2d plane, how find coordinates of point c, distant l1 , l2 b? more specifically, how do in c# unity (using vectors)? i've found algebraic method of achieving this, have no idea start in turning working code. your points , b centers of 2 circles, distances l1 , l2 radius of these circles: determine 2 circles intersect in c#: http://csharphelper.com/blog/2014/09/determine-where-two-circles-intersect-in-c/ here have code can copy paste project

multithreading - android audio record schedule, service or thread -

i trying write android app starts thread or service when button pressed. app records audio 10 minutes in morning , 10 minutes in evening 5 days in row. there no need ui available once app has been started. have been trying using service have tried thread. newbie world of scripting, love advice on path best, thread or service? you need separate thread ran inside of service onstartcommand code. and reading more tutorials https://developer.android.com/training/run-background-service/create-service.html

android - Who to limit Sprite with tilt control, to screen boundaries? -

im trying limit sprite screen edges. i'm using script unity manual , i've added clamp movement. issue screen bounded different each resolution, , cant figure out how use "camera.worldtoviewportpoint" in here... bound 0.1f , 0.9f want replace real screen bounds or size. atm working sprite moving in small bounds , not real screen size. please :) here code far: public float speed = 10.0f; public float posx; public float posy; void update() { vector3 dir = vector3.zero; dir.x = input.acceleration.x; dir.y = input.acceleration.y; if (dir.sqrmagnitude > 1) dir.normalize (); dir *= time.deltatime; transform.translate (dir * speed); transform.position = new vector3(mathf.clamp(transform.position.x, 0.1f, 0.9f),mathf.clamp(transform.position.y, 0.1f, 0.9f), 0); }

php - Yii and Instagram Real time api subscription -

i trying add subscription instagram real-time api setting callback_url yii (1.1.16) driven page , everytime api calls page gets server error (500). on apache log this: 173.252.114.111 - - [14/jun/2015:10:09:35 +0000] "get /site/instagram?hub.verify_token=mytoken&hub.challenge=xxx&hub.mode=subscribe http/1.1" 500 341 "-" "python-httplib2/0.8 (gzip)" when change callback_url php page without yii (www.mydomain.com/instagram.php) works without problems. 173.252.114.111 - - [14/jun/2015:09:53:08 +0000] "get /instagram.php?hub.verify_token=mytoken&hub.challenge=xxx&hub.mode=subscribe http/1.1" 200 200 "-" "python-httplib2/0.8 (gzip)" the code use in controller: public function actioninstagram() { $this->layout = false; echo $_get["hub_challenge"]; yii::app()->end(); } does know why yii giving error? ok, found out happening. seems instagram realtime api uses python ...

javascript - reduce a lot of require() function -

i have lot of commonjs modules , need add of them array. therefore, have huge repeated code: //container module var module1 = require('module1'), module2 = require('module2'), ... module25 = require('module25') var container = []; container.push(module1); container.push(module2); ... container.push(module25); module.exports = container; is possible reduce code? don't want make them globaly. see only solution, it's inject container inside each module, don't want modules know container . if understand problem correctly, wish export array of modules , access array, i.e. require , somewhere else. if correct, this: // requires-file module.exports = [ require('module1'), require('module2'), // ... ]; or more functional programming approach, appeal more me, people prefer different styles: module.exports = ['module1', 'module2', /*...*/].map(function(m) {return require(m);}); ...

Open utf8 encoded filename in c++ Windows -

consider following code: #include <iostream> #include <boost\locale.hpp> #include <windows.h> #include <fstream> std::string toutf8(std::wstring str) { std::string ret; int len = widechartomultibyte(cp_utf8, 0, str.c_str(), str.length(), null, 0, null, null); if (len > 0) { ret.resize(len); widechartomultibyte(cp_utf8, 0, str.c_str(), str.length(), &ret[0], len, null, null); } return ret; } int main() { std::wstring wfilename = l"d://private//test//एउटा फोल्दर//भित्रको फाईल.txt"; std::string utf8path = toutf8(wfilename ); std::ifstream ifilestream(utf8path , std::ifstream::in | std::ifstream::binary); if(ifilestream.is_open()) { std::cout << "opened file\n"; //do work here. } else { std::cout << "cannot opened file\n"; } return 0; } if running file, cannot open file entering else block. using boost:...