Posts

Showing posts from June, 2013

objective c - How to make a set of levels for my iOS game -

so have these 5 setter methods set game i'm making positions objects placed. are: - (void) settoinitialstatemain { [super clearboard]; [super setcellstate:stoneone forcolumn:1 androw:1]; [super setcellstate:stonetwo forcolumn:2 androw:3]; } and 4 other setters that. let's have 50 levels, , positions objects per level ready implemented 5 setters, how able this, if @ all? how can make press number 1-50 on screen, , program know pressed level 32, load positions level 32 (to applied in setter methods when called @ beginning stage of loading)?

javascript - Combine input box and select box to create a search bar -

i have input box serves search box, , populate select box querying sql database. example, there 2 organizations called "dummy organization" , "dummy 2" in db. when user starts typing "du", select box fills 2 organizations. want combine these 2 fields: input box (that acts search box) , select box (which displays results). research shows selectize.js can useful, since i'm new js, can't figure out how. can please me? code below: js gets data db: <script type="text/javascript"> function searchq(){ var searchtxt = $("input[name='search']").val(); $.post("search.php", {searchval: searchtxt},function(output4){ $("#output4").html(output4); } </script> the form: <form action="newbrand.php" method="post" id="form"> <br> brand name: <input type="text" name="bname" required /><br><

java - Webdriver throwing "Cannot navigate to invalid URL" error -

webdriver able navigate base url unable perform actions in clicking link or getting page title. the: driver.getcurrenturl() is throwing: unhandled inspector error: {"code":-32603,"message":"cannot navigate invalid url" not sure how fix it. can check if have prepended http in url. think solve issue in case did not use it. change navigate part as: driver.navigate().to("http://www.example.com"); in second ex too, use following: driver.navigate().to("http://www.url.com/"); driver.findelement(by.linktext("login").click(); complete source code: import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.chrome.chromedriver; import org.openqa.selenium.safari.safaridriver; public class checkwebdriver { private final webdriver driver = new safaridriver(); void checklogin(){ string baseurl = "http://newtours.demoaut.com/"; driver.get(ba

html - How to make divs responsive using a custom wordpress theme? -

Image
i have custom wordpress theme using, , editing 1 of pages. created 3 divs should align horizontally in center of page. figured out how aligned correctly, need responsive. when view web page mobile device, div's not appear on screen , there no scroll bar. please see image how should look. 3 div's display "find answers, submit ticket, , chat agent" links: here code create these divs: <center> <div style="width: 900px;"> <a href="http://neawebservices.com/client/knowledgebase.php" target="_blank"><div style="float: left; width: 200px; margin-right: 20px; border-radius: 25px; border: 2px solid #007ebf; padding: 20px; height: 150px; text-align: center;"> <h3 class="priceplanhr">find answers</h3> <img class="alignnone wp-image-980 size-full" src="http://neawebservices.com/wp-content/uploads/2016/04/64-x-64.png" alt="" width="66&quo

How to load react-native-map on android application -

i have below code use react-native-map on android genymotion simulator. , followed instruction https://github.com/lelandrichardson/react-native-maps/blob/master/docs/installation.md setup dependencies. when run react-native run-android, doesn't show ui. instead, shows while page line in middle. able load map on ios device similar code. wrong code android? import react, { appregistry, component, stylesheet, text, view, image, listview, textinput, touchablehighlight, dimensions, //mapview, } 'react-native'; import mapview 'react-native-maps'; const styles = stylesheet.create({ map: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, }, container: { flexdirection: 'row', justifycontent: 'space-between', padding: 30, flex: 1, alignitems: 'center' }, inputtext: { height: 36, padding: 4, marginright: 5, flex: 4, fontsize: 18

javascript - Using jquery to edit css attribute of a text without selector -

i trying apply smiley(emoji) users comments on page. example :) applied css attributes replaced with. there way can use javascript or jquery achieve this? $(":)").css("background-image", "url('smile.gif')"); my problem selector part, since dont want apply css whole div. you need wrp html text ':)' html , can add css/jq it. see below javascript code , try add css "smiley" class document.body.innerhtml = document.body.innerhtml.replace(':)', '');

python 2.7 - Why a "Lost Paradise" in code, that ran many months in py2.7, now np.ndarray() not found in namespaces, while [import numpy as np] was executed? -

Image
was there namespace handling change between 2.7.9 , 2.7.11? tl;dr: after providing 450+ answers on stack overflow. know stack overflow rules , strived narrow/isolate issue, below-mentioned reasons, practically impossible post fair mcve. below posted in-vivo diagnostics has proved, there no namespace-issues np.ndarray calls until first line trying access / use numpy ( np ) symbol line 14644 (14630 in orignal numbering) adsegfloat = np.ndarray( ( 80, 7 ), ... where thereto working numpy call raises exception: unboundlocalerror: local variable 'np' referenced before assignment intro: purpose of quantitative modelling, rather extensive python module code being re-used in distributed processing framework operated technical analyses , predictions. due fact, quant-models ( being used predictions ) generated @ remarkable cost of small tens-of-cpu-core-hours, there deployed additional measures allowing stateful module reload( quantfx ) -s, these protect elabora

get video duration from URL in android app -

i'm working on app user can see video's information , title stored on server. i'm done except no matter how code it, cannot video duration given url. lets take demo video somewhere on internet: click here video path want app video duration without need open video itself. the code i'm trying use on android this: mediametadataretriever retriever = new mediametadataretriever(); retriever.setdatasource("https://12-lvl3-pdl.vimeocdn.com/01/1386/0/6932347/10573836.mp4?expires=1461047937&token=037972137fdfc4c2d9902"); string time = retriever.extractmetadata(mediametadataretriever.metadata_key_duration); long timeinmillisec = long.parselong( time ); long duration = timeinmillisec / 1000; long hours = duration / 3600; long minutes = (duration - hours * 3600) / 60; long seconds = duration - (hours * 3600 + minutes * 60); toast.maketext(context,long.tostring(timeinmillisec),toast.length_short).show(); but result i'm g

ruby on rails 4 - Resizing the window in Capybara with rack_test -

i'm using rack_test driver capybara , i'm trying resize window. the best example find on this gist , resize method not seem work rack_test > capybara.current_driver => :rack_test > page.driver.resize(200, 200) nomethoderror: undefined method `resize' #<capybara::racktest::driver:0x007fe4eb83bc60> (pry):22:in `block (2 levels) in <top (required)>' i've tried various other combinations i've seen online no luck. there easier way resize browser window? thanks! the rack_test driver has no concept of windows or page size. strictly html parser, no layout , minimal css processing (basically inline display: none checking). if need window resizing need switch 1 of real browser drivers.

c# - Add icon in PropertyGrid -

Image
i'm trying display icon every cell in propertygrid image shown below so question is, possible make in wpf propertygrid? if yes, how? thanks in advance! we have considered “add icon in propertygrid” feature , available in of our upcoming releases.

sql - Finding top 3 IDs with the largest count, by group - is it possible to avoid a triple nested query? -

i need find top 3 'userids' 'time' in terms of count in 'table'. example of input , output: table id userid time 1 '1' 2 '1' 3 b '2' 4 b '4' 5 b '4' etc desired result: time userid number rank '1' 17 1 '1' c 11 2 '1' q 9 3 '2' b 13 1 '2' c 9 2 '2' m 7 3 etc i've been able accomplish using triple query there way simplify? select userid, number, time, rank ( select userid, number, time, rank() on (partition time order number desc) rank (select count(distinct(id)) number, userid, time table group 2, 3) ) rank <= 3 i'm wondering if 'having' clause applicable here, since seems slow otherwise. are happy this? ;with cte_ranking (

javascript - Active link while scrolling -

Image
i'm trying add active link, while people scrolling, section on have active class. i've been using fiddle post: change active menu item on page scroll? i can't work in code though. below have far, , website http://whitneyedenlewis.com thanks! whitney, the fiddle post mentioned does work, need add id <ul> it's <ul id="top-menu"> . after adding , using code in aforementioned fiddle, see active class moving other links in navigation. there, you'll still have little more do, should answer question.

javascript - Call keypress event on button click? -

i have below jquery code execute on keypress execute same on button click. please me. $('#itemselected').live('keypress', function() { //some code using $(this) also. } var myfunction = function(event){ console.debug(event); //do stuff here }; $('#itemselected').on('keypress', function(event) { myfunction(event); } $('#itemselected').on('click', function(event) { myfunction(event); }

text mining - Perplexity in topic modeling -

i have run lda using topic models package on training data. how can determine perplexity of fitted model? read instruction, not sure code should use. here's have far: burnin <- 500 iter <- 1000 #keep <- 30 k <- 4 results_training <- lda(dtm_training, k, method = "gibbs", control = list(burnin = burnin, iter = iter)) terms <- terms(results_training, 10) topic <- topics(results_training, 4) # posterior probability each document on each topic posterior <- posterior(results_training)[[2]] it works perfectly, question how can use perplexity on testing data (results_testing)? , how can interpret result of perplexity? thanks

c++ - struct size not as expected when using bit fields -

this question has answer here: why isn't sizeof struct equal sum of sizeof of each member? 11 answers padding in structures in c 5 answers with below code: struct s { unsigned char b1 : 3; int i; }; i can deduce char b1 of 1 byte , using 3 bits of , int 4 bytes when try print out size of s, 8 bytes instead of 5 bytes(1 char+4 int) expected , not understanding obvious. can explain why size of s 8 bytes?

math - How would you calculate the sum of interior angles from a SVG path? -

for example, path 1 below: <path d="m 35 50 l 35 35 l 90 90 z" fill="goldenrod"/> if contour closed (z-command) , simple polygon, sum of interior angle s is sa = 180 * (n - 2) where n number of vertices. here 3 vertices, sa = 180 (it works concave polygons, not self-intesecting ones (they 'not simple'))

dequeue in Queue of Data Structure? -

i can't understand 1 paragraph when read data structure , algorithm analysis in java. can tell me? in applications sure number of enqueues not larger capacity of queue, wraparound not necessary. stacks, dequeues performed unless calling routines queue not empty. error checks skipped operation, except in critical code. not justifiable, because time savings achieve minimal. thanks without seeing full context in paragraph sits, exact answer might difficult. appears saying dequeue operations performed when queue known not empty. therefore, error checks empty queue skipped operation, on basis saving time not performing check. however, time savings realized not doing empty check minimal, , risk of not checkout outweighs minimal performance gain. in more human readable terms, when working queues (as stacks), there potential need make sure queue not empty before trying dequeue (removal) operation. check ignored on grounds saves time , boosts performance. book readin

c# - With a custom control that's inside of an ItemTemplate (Repeater), how can I access values from the repeater item? -

i have control, custom button. button sits inside of <itemtemplate> . i'm needing access databound values parent, <itemtemplate> . for example, <%#eval("firstname")%> can done within <itemtemplate> , not within control itself, other exposing values via property tags. note : know how pass these values via property/attribute tags. can't in case. i've been playing around databinder.eval can't seem access need. examples of attempts: dim parent repeateritem = ctype(me.namingcontainer, repeateritem) dim test = databinder.eval(parent.dataitem, "firstname") test = databinder.eval(me.namingcontainer, "dataitem.firstname") test = databinder.eval(directcast(directcast(parent, repeateritem), idataitemcontainer).dataitem, "firstname") i've never had before, , want strictly code-behind. can climb control tree , see "namingcontainer" in fact repeateritem. am missing something? c# or vb.ne

linux - svn relocate not showing in svn help list what does it mean? -

when type svn help shows list of commands svn relocate not there in list . mean ? svn version 1.6.11 ropdel (pdel, pd) propedit (pedit, pe) propget (pget, pg) proplist (plist, pl) propset (pset, ps) resolve resolved revert status (stat, st) switch (sw) unlock it means svn relocate not available in svn 1.6. you can find documentation @ 1.7/svn.ref.svn.c.relocate.html as mentioned in " relocate without relocate in subversion? ", in 1.6, was: svn switch --relocate old_url new_url as opposed 1.7: svn relocate new_url

Azure DocumentDb "high water mark"/timestamp -

i'm looking implement process pull "new" records documentdb, new "all documents added or modified since last time process run." sql server has rowversion this, guaranteed unique , monotonically increasing across rows , columns in database. i see documentdb has _ts, (according documentation) used high water mark azure search indexing, how work? if multiple documents inserted @ same time read takes place, it's possible of them have same _ts value. on next read, if comparison against _ts strictly greater than, documents missed; if it's greater-than-or-equals, documents pulled second time. is _ts safe use this? the _ts property specific document, not collection of documents. represents time particular document updated (in seconds, since jan 1 1970). the _ts property not give high water mark across documents in collection. each document has own independent _ts property (which may have same value document's _ts property). see thi

r - Build data frame from multiple rvest elements -

i trying web scraping of journal article metadata (title, authors, abstract, etc.). have list of pages need navigate , each page has information need (except table of contents pages in list). built function piece each part of page list , i'm trying go through each page , end data frame of results. here have: article.links <- c("http://onlinelibrary.wiley.com/doi/10.1002/jee.20116/abstract", "http://onlinelibrary.wiley.com/doi/10.1002/jee.20120/abstract", "http://onlinelibrary.wiley.com/doi/10.1002/jee.20117/abstract" ) pager <- function(page) { new.row = vector("list", 4) page <- read_html(page) #doi new.row[1] <- page %>% html_node("#doi") %>% html_text() #title new.row[2] <- page %>% html_node(".maintitle") %>% html_text() #authors new.row[3] <- page %>% html_node("#authors") %>% html_text() #abstract new.row[4] <-

python - How to populate JSON dump from a form to a django template? -

i importing post request form template.html view.py using data=json.dumps(request.post) the data @ view.py in format: {"5": "25", "4": "28", "6": "21"} while running dictionary syntax on it, error pops data in string form. how convert dictionary? further, need populate 'key' , 'value' of dictionary template. please me out? try this: >>> = '{"5": "25", "4": "28", "6": "21"}' >>> type(a) <type 'str'> >>> >>> import ast >>> x = ast.literal_eval(a) >>> type(x) <type 'dict'> >>> >>> x.keys() ['5', '4', '6'] >>> x.values() ['25', '28', '21']

array in R error in next variable -

Image
so try assign value in array. write code in r studio and works. results correct. when insert third variable, comes error. fourth variable , on i've tried other names third variable error still there. whats problem ? thank in advance i think problem facing is: you not declaring 'bb' , try declare 'bb' before use it. > bb<-0 > for(i in 1:10){ + a[i]=3*i + b[i]=4*i + bb[i]=5*i + } > bb[3] [1] 15

decode - Google Maps decoded GMSPath incorrect iOS -

Image
so, use directions api in app. however, when decode polyline response, not show correctly. here code: //construct request url nsstring *urlstring = [nsstring stringwithformat: @"%@?origin=%f,%f&destination=%f,%f&sensor=true&key=%@", @"https://maps.googleapis.com/maps/api/directions/json", usermarker.position.latitude, usermarker.position.longitude, place.coordinate.latitude, place.coordinate.longitude, @"aizasydrtha-amivvylupcp46_vf1ezjjfbwrcy"]; nsurl *directionsurl = [nsurl urlwithstring:urlstring]; //get directions in json format dispatch_async(dispatch_get_main_queue(), ^{ nsdata* data = [nsdata datawithcontentsofurl:directionsurl]; nserror* error; if(data){ nsdictionary *json = [nsjsonser

javascript - Disabling a Button -

i need trying make button disable after has been clicked, grateful , if need anymore information ask me, thanks! appreciated. function addgame() { var side = $("#side").val(); var steamid = $("#steamid").val(); var amount = $("#amount").val(); var buttontext = document.getelementbyid('creategamebutton').innerhtml; if(buttontext=='are sure?') { $.ajax( { url: 'addgame.php', type: 'post', data: 'side=' + side + '&steamid=' + steamid + '&amount=' + amount, datatype: 'text', success: function (data) { document.getelementbyid('game-alert').innerhtml = data; $("#game-alert").fadein(); refreshgames(); document.getelementbyid('creategamebutton').innerhtml = 'create game';

sql server - Create Database Snapshot for remote database on local machine -

i having subtle problem in creating database snapshot. connected remote database. want create snapshot on local machine. possible or allowed? i typing query below > create database samplesnapshot on ( name = 'sample', filename = > 'c:\samplefile' ) snapshot of sample; go and getting exception msg 262, level 14, state 1, line 1 create database permission denied in database 'master'. i having following questions: when specify path in query snapshot created on local machine or server machine? if local machine how create snapshot on server machine itself. no. client/server means send instructions server. execute on server. means c:\ relative server, not client machine.

javascript - FabricJS CurvedText object (extended) is not getting displayed on updating spacing and text properties -

i have updated fabric curvedtext extension because of our requirement different. want set auto spacing between characters covers full circle. got solutions after updating code in fabric curvedtext extension. while changing text of object (on keyup event of textbox), recalculate spacing , setting spacing , text via settext , set("spacing", val) properties . in situations, i can not see object on canvas i can see pointer of object on canvas mouse hover effect. remove characters textbox in snippet , object hide after remove characters. same thing happens when add characters in textbox. updated curved text extension . var radius = 100; var circum = math.floor(2 * math.pi * radius); var spacing = 0; var fontfamily = 'arial'; var fontsize = 30; var text; var lineheight = 1; var topa = 100; var left = 200; var char = 0; var textwidth = 0; var obj; var canvas, ctx; $(document).ready(function () { canvas = new fabric.canvas('c&#

.net - Multiple services or single service with multiple threads -

we rewriting our .net application. current application has 4 windows services. first service accepts requests ui , updates ui publishing events refreshing ui. service internally uses 2 thrall pools max 16 threads each service gui. requests ui requires business processing passed on worker process windows services(there 2 such windows service).msmq used passing requests , forth between services. fourth windows service acts load balancing , directs requests first service workers. services running on same box now while rewriting, know if should maintain same architecture or can clubbed same service separate threads. better performance perspective. for running on same box, think may require scale multiple boxes in future? the architecture involving multiple services more scalable, more maintainable , more flexible. of key benefits are, your architecture more loosely coupled you can scale each service / workload separately you can replace each service in different tech

google oauth - YouTube API - avoid authentication screen in browser -

i have youtube class uploads video on youtube using oauth authentication. when tested on local workspace, worked fine opened browser asking if access youtube channel permitted. now, class should work on server. there no browser can open , that's problem. works point. does have idea how redirekt/avoid or else browser window? thanks lot help! best wishes. if want submit video on behalf of user, user has authenticate , authorize application somewhere. (if using v3 api) there flows work server-side application, though: https://developers.google.com/youtube/v3/guides/moving_to_oauth#using-oauth-20-for-server-side-standalone-scripts https://developers.google.com/youtube/v3/guides/auth/server-side-web-apps#obtaining_access_tokens

java - Android internet permission missing -

i've added internet permission in androidmanifest.xml, still internet permission missing error thrown. androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="info.androidhive.slidingmenu" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="11" android:targetsdkversion="17" /> <uses-permission android:name="android.permission.internet"/> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="info.androidhive.slidingmenu.mainactivity" android:label="@string/app_name" > <intent-filter> <action an

c# - Why is Task<T> not co-variant? -

class resultbase {} class result : resultbase {} task<resultbase> getresult() { return task.fromresult(new result()); } the compiler tells me cannot implicitly convert task<result> task<resultbase> . can explain why is? have expected co-variance enable me write code in way. according someone may in know ... the justification advantage of covariance outweighed disadvantage of clutter (i.e. have make decision whether use task or itask in every single place in code). it sounds me there not compelling motivation either way. itask<out t> require lot of new overloads, quite bit under hood (i cannot attest how actual base class implemented or how special compared naive implementation) way more in form of these linq -like extension methods. somebody else made point - time better spent making class es covariant , contravariant. don't know how hard be, sounds better use of time me. on other hand, mentioned cool have real yield

WPF inspector Tool that doesn't require .net 3.5 -

i looking wpf diagnostic tool snoop or wpf inspector doesn't require .net 3.5, because unable install .net 3.5 on device. great if knows simular tool runs actual .net version or knows how run snoop actual .net version. there no tool better xamarin inspector, https://developer.xamarin.com/guides/cross-platform/inspector/

Is there a good way (or module) to modify or append data into xml file in Android? -

the situation this, had create xml file in xmlpullparser way: <?xml version='1.0' encoding='utf-8' standalone='yes'?> <users> <user id="1"> <name>abc</name> <password>abc</password> </user> <user id="2"> <name>def</name> <password>def</password> </user> </users> and now, want modify or append data xml file, except create new xml file (or clean original data , import new data), there way based on original file?

while processing recurring payment in paypal ,it is getting the following error -

this recipient not accept payments denominated in usdec-00d98475nv4904518. please contact seller , ask him update payment receiving preferences accept currency. how solve error.please advice thanks in advance. seems it's not on end. seems recipient hasn't set "hes" account accept currency. another option, allow user choose currency in "hes" receives payment.

jupyter irkernel - Filter records from table in R -

Image
i have dataset movies. head(movies) how fetch rows movieid "0000008"? have tried: t1 = subset(movies, "movieid" == "0000008") t2 <- movies[ which(movies["movieid"]=="0000008"), ] head(t1) head(t2) both return empty datasets, wrong can see row id "0000008". edit: have tried removing "" movieid, throws error: error in subset.matrix(movies, movieid == "0000008"): object 'movieid' not found edit: movie data obtained as: url = "https://raw.githubusercontent.com/sidooms/movietweetings/master/latest/movies.dat" movietext = readlines( remote.file(url) ) # hack!!! movies = matrix( sapply( movietext, function(x) unlist(strsplit(sub(" [(]([0-9]+)[)]", "::\\1",x),"::"))[1:4] ), nrow=length(movietext), ncol=4, byrow=true ) colnames(movies) = c("movieid", "movietitle", "year", "genres&qu

sql server - SQL Joining different tables structure (MSSQL) -

i have different tables , want join information. in case have product, sales , product definition table. product table: productid | name 1 | product 1 2 | product 2 3 | product 3 product definitions table: defid | productid | column 1 | column 2 | .... 001 | 1 | text | text 002 | 1 | text | text 003 | 3 | text | text 004 | 2 | text | text 005 | 3 | text | text sales table: salesid | productid | sales 01 | 1 | 13 02 | 1 | 12 03 | 2 | 1 04 | 2 | 4 05 | 3 | 2 i want replace information (e.g. product definition -> sales) not existing -1. , create query view: defid | productid | salesid | sales | column 1 | column 2 | .... 001 | 1 | -1 | -1 | text | text 002 | 1 | -1 | -1 | text | text

python - How to get the request body bytes in Flask? -

the request's content-type application/json , want request body bytes. flask auto convert data json . how request body? you can non-form-related data calling request.get_data() can parsed form data accessing request.form , request.files . however, order in access these 2 change returned get_data . if call first, contain full request body, including raw form data. if call second, typically empty, , form populated. if want consistent behavior, call request.get_data(parse_form_data=true) . you can body parsed json using request.get_json() , not happen automatically question suggests. see docs on dealing request data more information.

php - MySQL statement seems to have an error. I get mysqli_num_rows() and mysqli_fetch_array() errors -

i've been working on password reset form. sql statement seems returning nothing. i've removed sections of code simplify it, can't seem pasted mysqli_num_rows() . think there wrong mysqli_query() statement on line proceeding it. i've try using mysql_num_rows , mysql_query alternative. <?php if(isset($_post["u"])) { // connect database include_once("includes/connect.php"); // gather posted data local variables , sanitize $u = preg_replace('#[^a-z0-9_]#i', '', $_post['u']); $e = mysql_real_escape_string($connect, $_post['e']); $username = $_post['username']; $email = $_post['email']; $query = mysqli_query($connect, "select username, email users username='$username'"); $numrows = mysqli_num_rows($query); if($numrows > 0) { while($row = mysqli_fetch_array($query, mysqli_assoc)){ $db_u = $row["username"];

Node.js emit not working on specific socket.on -

Image
i'm trying send news client. on connect, works great, reason on broadcast2 wont response client sided, know same piece of code, , broadcast2 's console.log working. q: how can make sure broadcast2 emit work? this works: socket.on('message', function (data) { console.log('message gotten'); socket.emit('news', { message: 'xxxx' }); }); this wont work: socket.on('broadcast2', function (data) { console.log("broadcast revieced"); socket.emit('news', { message: 'xxxx' }); }); this node.js response: total code in node.js socket.on('message', function (data) { console.log('message gotten'); }); socket.on('another-message', function (data) { socket.emit('not-news', { hello: 'world' }); }); socket.on('broadcast2', function (data) { console.log("broadcast revieced"); socket.emit('news', { message: 'xxxx' }); }

.net - Evidence to not use SELECT * -

my chief architect @ work genius , i've learned him, doesn't agree not using select * in our application queries. his reason doesn't matter when you're pulling 10 rows, end pulling 100+ columns show 4 user. he's open discussion great , that's why i'm looking online resources display hard evidence on sql query times or along lines present him. and, i'm looking way track statistics in app without using cpu (we use .net 4.0 framework). help how putting table several columns varbinary(max) containing few large files...and execute query remotely..

javascript - addEventListener vs onclick -

what's difference between addeventlistener , onclick ? var h = document.getelementbyid("a"); h.onclick = dothing1; h.addeventlistener("click", dothing2); the code above resides in separate .js file, , both work perfectly. both correct, none of them "best" per se, , there may reason developer chose use both approaches. event listeners (addeventlistener , ie's attachevent) earlier versions of internet explorer implement javascript differently pretty every other browser. versions less 9, use attachevent [ doc ] method, this: element.attachevent('onclick', function() { /* stuff here*/ }); in other browsers (including ie 9 , above), use addeventlistener [ doc ], this: element.addeventlistener('click', function() { /* stuff here*/ }, false); using approach ( dom level 2 events ), can attach theoretically unlimited number of events single element. practical limitation client-side memory , other performance c

ios - Maybe get name of ObjectType in NSArray? -

Image
i have custom class below: @interface testobject : nsobject @property (nonatomic, retain) nsarray<obja *> *obja; @property (nonatomic, retain) nsstring *status; @property (nonatomic, retain) nsstring *keyword; @property (nonatomic, retain) objb *objb; @end i want objecttype's name of property obja (which objarea ), return nsarray. had name of class of other property include objb . how can in runtime ? have function list property , class of them extend(category) nsobject this. - (nsarray *)propertylist { class currentclass = [self class]; nsmutablearray *propertylist = [[nsmutablearray alloc] init]; { unsigned int outcount, i; objc_property_t *properties = class_copypropertylist(currentclass, &outcount); (i = 0; < outcount; i++) { objc_property_t property = properties[i]; nsstring *propertyname = [nsstring stringwithformat:@"%s", property_getname(property)]; [property

system.reactive - The type arguments cannot be inferred from the query RX -

consider in test sl app (trying learn rx): var input = (from _ in observable.fromeventpattern(txt, "textchanged") select txt.text) .throttle(timespan.fromseconds(.05)).distinctuntilchanged(); var svc = new dictservicesoapclient(); var res = term in input words in svc.matchindictasync("wn", term, "prefix") select words; the "from" in "from words in svc...." shows error message: "the type arguments cannot inferred query. try..." i don't trying say. how resolve this? the compiler not know type of observable 'fromeventpattern' return since method uses reflection event. need out telling type of object returned event: observable.fromeventpattern<textchangedeventargs>(txt, "textchanged")

How to remove specific page from word document in Aspose Java? -

how remove specific page word document in aspose java ? my requirement is, have 1 word document need first page ? so either can remove pages except first 1 or can create new document read first page document , write new document. you can achieve requirements using "pagesplitter" example project. can find pagesplitter code in aspose.words java examples repository @ github . please use following code example extract first page word document. //load document document doc = new document(mydir + "in.docx"); // create , attach collector document before page layout built. layoutcollector layoutcollector = new layoutcollector(doc); // split nodes in document separate pages. documentpagesplitter splitter = new documentpagesplitter(layoutcollector); //get first page of document document newdoc = splitter.getdocumentofpage(1); newdoc.save(mydir + "out.docx"); i work aspose developer evangelist.

Reorder the elements in an array using php -

i have following array , changeable time time. array ( [for sale] => sale [sold] => sold [to let] => let [let] => let [under offer] => under offer [exchanged] => exchanged [withdrawn] => withdrawn [acquired] => acquired ) no matter what's initial sequence when page loads should array ( [for sale] => sale [under offer] => under offer [exchanged] => exchanged [withdrawn] => withdrawn [acquired] => acquired [sold] => sold [to let] => let [let] => let ) basically these 3 elements should stay @ bottom of array. [sold] => sold [to let] => let [let] => let any highly appreciated. in advance. here i've used in_array() match key given keys 'sold','to let','let' , unset key $input array , push key value array. <?php $input = array( 'for sale' => 'f

variadic functions - Unused arguments error in R studio -

i error when try run line of code: nnetpred.model <- nnetpred(x, y, step_size = 0.4,reg = 0.0002, h=50, niteration = 6000) the error message is: error in nnetpred(x, y, step_size = 0.4, reg = 2e-04, h = 50, niteration = 6000) : unused arguments (step_size = 0.4, reg = 2e-04, h = 50, niteration = 6000) my code below: nnetpred <- function(x, y, para = list()){ w <- para[[1]] b <- para[[2]] w2 <- para[[3]] b2 <- para[[4]] n <- nrow(x) hidden_layer <- pmax(0, x%*% w + matrix(rep(b,n), nrow = n, byrow = t)) hidden_layer <- matrix(hidden_layer, nrow = n) scores <- hidden_layer%*%w2 + matrix(rep(b2,n), nrow = n, byrow = t) predicted_class <- apply(scores, 1, which.max) return(predicted_class) } nnetpred.model <- nnetpred(x, y, step_size = 0.4,reg = 0.0002, h=50, niteration = 6000) it looks trying use variable arguments. in r, means ellipsis ( ... ). how define top of nnetpred use variable arguments: nnet