Posts

Showing posts from April, 2012

arguments - Lambda expression gives "invalid tokens" syntax error in Java -

Image
i started learn lambda expression , did this: public class lambdatest { public static void main(string[] args) { int num = returnnumber((num) -> { return 4 }); } public static int returnnumber(int num) { return num; } } but gives me error: "invalid tokens". here image: can please explain me what's wrong? it's test. i have java 1.8 supported in eclipse installation (luna 4.4). there few restrictions on can done in body of lambda, of pretty intuitive—a lambda body can’t “break” or “continue” out of lambda, , if lambda returns value, every code path must return value or throw exception, , on. these same rules standard java method, shouldn’t surprising. reference : http://www.oracle.com/technetwork/articles/java/architect-lambdas-part1-2080972.html the method's body has effect of evaluating lambda body, if expression, or of executing lambda body, if block; if result expected, returned method.

MySQL Select Latest Date - Single Table -

i have table looks , want ids (insp_id) of newest insp_date each loc_id. create table insp ( insp_id int (10), loc_id int (11), insp_type varchar (150), insp_date date , insp_active tinyint (2), insp_created timestamp , insp_modified timestamp ); i tried "in" strategy select latest record in table (datetime field) , others gives me double since 1 loc_id's latest date may non-latest another: select insp_id, loc_id, insp_active, insp_date insp insp_active = 1 , insp_date in(select max(insp_date) insp insp_active = 1 group loc_id) order loc_id asc, insp_date desc; i setup sql fiddle adding various group , max not seem it. feel need join on sub-query or similar not sure @ point. http://sqlfiddle.com/#!2/f95e0/1 thanks, andrew you need retrieve max date each location, , then, max insp_id date query 1 : select insp.loc_id, max(insp.insp_id) insp inner join (select loc_id, max(insp_date) insp_date insp

python - Python_Encoding_error message -

hi able code working following below, changing bunch of variable names seemed work. perhaps using variables recognized encoder _utf-8. help dt =0.1 a=100 n=int(a/dt) kgrow=1; kshrink =0.25 pgrow=kgrow*dt ; pshrink=kshrink*dt length =[] l=0 times =[] t=0 in range(n): t+=dt times.append(t) randgrow=random.random() randshrink=random.random() length.append(l) time=np.array(times) lengths=np.array(length) plt. plot (times,length) plt. xlabel('time') plt.ylabel('length') try open notepad , save ansi encoding. save as.. ansi encoding

java - createSQLQuery with parameter in Hibernate -

i'm trying run this: .. string modeltablename = (model == tablemodeltype.ring) ? "ring_players" : "tourny_players"; list<object[]> results = dbs.createsqlquery("select group_level, count(group_level) :modeltablename game_id=:gameid group group_level") .addscalar("group_level", hibernate.integer) .addscalar("count(group_level)", hibernate.long) .setstring("modeltablename", getmodeltablename()) .setinteger("gameid", getgameid()) .list(); it gives exception: caused by: java.sql.sqlexception: ora-00903: invalid table name if write "ring_players" instead of ":tablemodelname" works! what doing wrong parameter? thank you. according answer, can not inject table name: table name parameter in hql you may have construct as: list<object[]> results = dbs.createsqlquery("select grou

Delete into SQL Server loop -

in case of repetition periods, need delete second occurrence (15 15 minutes), query returns or nothing. declare @datatetemp date declare @horatetemp time declare cursor_i cursor select datate, horate @table open cursor_i fetch next cursor_i @datatetemp, @horatetemp; while @@fetch_status = 0 begin if (select count(*) @table horate = dateadd(minute, -15, @horatetemp)) > 0 --dateadd(minute, -15, @horatetemp) = @horatetemp begin delete @table current of cursor_i end fetch next cursor_i @datatetemp, @horatetemp end close cursor_i; deallocate cursor_i; another: declare @aux time = dateadd(minute, -15, @horatetemp) if (select count(*) @table oito oito.horate = @aux) > 0 would never possible applying as: select [...] cross apply dbo.function(dat, hor) [...]

elixir - Mix compiliation fails when compiling Ecto -

in elixir: when trying compile dependencies ecto, run following error mix , poolboy: >mix compile ** (mix) application poolboy specified non semantic version `cat version`. mix can match requirement ~> 1.2.1 against semantic versions, match against version, please use regex requirement i'm on windows 8.1 here mix deps: note: have use "~> 0.6.0" postgrex or else complain of dependency resolution. (in ecto docs, says use ">= 0.0.0") defp deps [ {:postgrex, "~> 0.6.0"}, {:ecto, "~> 0.2.5"} ] end from compile error message, seems either mix not handling or poolboy isn't , may not on ecto side? anyways, know how fix or have workaround? thanks. this poolboy bug. rebar (erlang build tool) allows users inject custom code in application files , poolboy using feature read version filesystem using specific os commands. works on linux going fail on windows. have opened issue on poolboy issues t

unix - Search a log file for total count of unique ips -

i'm using following format counts of how many times unique ips hit website. search log file total count of unique ips zcat *file* | awk '{print $1}' | sort | uniq -c | sort -n this gives me list of ips , it's occurrence. 1001 109.165.113.xxx 1001 178.137.88.xxx 1001 178.175.13.xxx 1001 81.4.217.xxx 1060 74.122.180.xxx 1103 67.201.52.xxx 1203 81.144.138.xxx 1670 54.240.158.xxx 1697 54.239.137.xxx 2789 39.183.147.xxx 4630 93.158.143.xxx what want find out simple , if can done on single command line. i want count of list. above example. want buffer tell me 11. thought use second awk command count unique occurrence of 2nd output guess cannot use awk twice in single command line. obviously can output above log file , run second awk command count unique occurrence of 2nd field(ips) hoping done in single command. you might want: zcat ... | awk '{cnt[$1]++} end{for (ip in cnt) {unq++; print cnt[ip], ip}; print unq+0}' if have gnu awk ca

Display multiple SQL query results as array with RecordSet Object in Autoit -

i trying read multiple results after sql query adodb object in auoit. $sqlcon = objcreate ("adodb.connection") ; create sql connection $sqlcon.open("driver={sql server};" & $my_pass) ; connect required credentials $rs = objcreate("adodb.recordset") ; creating record set object $rs.open($my_query, $sqlcon) ; executing query $rs.getstring ;this return (for example 4) records in 1 string how read 1 specified record? $rs.recordnumber(0).getstring ?? how number of records returned? $rs.recordcount ?? how place records array 1 one? now found method getrosw() job looking for $arr = $rs.getrows() $records_number = ubound($arr) _arraydisplay($arr)

responsive design - Why is Google Chrome mobile device emulator showing my 320 pixel wide site as it is? -

i've added media queries website pages display @ width of 300 pixels, if "max-width" of user's browser less 480 pixels. my question this: when view pages using google chrome's device emulator - , emulator quite says width apple iphone 6 "375" pixels wide, why 300 pixel wide website display @ narrower width (about 100 pixels)? i'm confused because when view website via standard pc browser , reduce width of browser - fine. when use emulator, though specifies apple iphone 6 has resolution of 375 pixels, why web pages shrink 100 pixels wide? any ideas? have included meta tag <meta name="viewport" content="width=device-width, initial-scale=1.0"> in page header?

html - Why my styles are breaking when I try to apply a clear fix method? -

i'm working on page here skeleton inside of body tag: <div id="site-nav-container"> <nav id="page-navigation"></nav> </div> <header id="site-header"></header> <div class="content-container clearfix"> <section id="blog-post-sum"></section> <aside id="site-sidebar"></aside> </div> <footer id="site-footer"></footer> so here facing: styling purpose had float section "blog-post-sum" id left , float aside id "site-sidebar" right. prevent margin collapse wrapped section , aside tag in div container , gave "clearfix" class use clear-fix method. method used follows: .clearfix:before, .clearfix:after { content: ""; display: table; } .clearfix:after { clear: both; } <!--[if lt ie 8]> /*for ie < 8(trigger haslayout)*/ .clearfix { zoom: 1; } <![endif]

php - Export CSV file from Codeigniter -

i using csv_helper.php file in helpers exporting. grabing results mysql showing results instead of downloading ! here's csv_helper <?php if ( ! defined('basepath')) exit('no direct script access allowed'); if ( ! function_exists('array_to_csv')) { function array_to_csv($array, $download = "") { if ($download != "") { header('content-type: application/csv'); header('content-disposition: attachment; filename="' . $download . '"'); } ob_start(); $f = fopen('php://output', 'w') or show_error("can't open php://output"); $n = 0; foreach ($array $line) { $n++; if ( ! fputcsv($f, $line)) { show_error("can't write line $n: $line"); } } fclose($f) or show_error("can

android - Cannot retrieve products from Google Play store with Fovea purchase plugin -

i'm using fovea.cc purchase plugin android cordova app. plugin initializes, cannot find in-app purchase products - same "product not found" error if product didn't exist or if app not published. i'm looking more troubleshooting steps. here's relevant code, called on app launch: store.register({ id: "com.ineptech.wn.unlockgame", alias: "unlockgame", type: store.non_consumable }); store.ready(function() { console.log("\\o/ store ready \\o/"); // called }); store.when("unlockgame").approved(function (order) { unlockcontent(); order.finish(); }); store.refresh(); var p = store.get("unlockgame"); popup("title = " + p.title); // displays "title = null" and here's code purchase button: store.order("unlockgame"); // results in "the item attempting purchase // not found" error play store here's purchase attempt displays in lo

jquery - How to create tab into a link -

i have following html: <div class="captionbottom"> <a href="mp.aspx" title=""><img src="c.jpg" alt="" /></a> <figcaption>view!</figcaption> </div> the figcaption shown on image when hovered. how can make link href of anchor tag, clicking on figcaption takes user mp.aspx css: figcaption { width: 100%; position: absolute; background: #e55302; background: rgba(229,83,2,0.90); color: #fff; padding: 10px 0; opacity: 0; -webkit-transition: 0.6s ease; -moz-transition: 0.6s ease; -o-transition: 0.6s ease; cursor: pointer; } .captionbottom:hover figcaption { opacity: 1; cursor: pointer; } using jquery: $('figcaption').on('click',function() { var fighref = $(this).prev().attr('href'); window.location.href = fighref; //changed code. });

css3 - How to include files depending on the request.domain -

i need include file "#{request.domain.split(".").first}.css.scss" into custom.css.scss file. i don't know how proceed. goal declare specific variable, , give them different values in each file, loading dynamically different files each different request file one.css.scss $button_primary_color: #xxx; $header_background_color: blue; file two.css.scss $button_primary_color: #zzz; $header_background_color: red; i tried using css3 variables, without success: home[sn="one"] { --button_primary_color: #xxx; } home[sn="two"] { --button_primary_color: #yyy; } (it doesn't behave standard in different browser), , doesn't substitute following statement. div { color: var(--button_primary_color); } i'd have more bootstrap/sass solution. how can accomplish this? i'm still trying figure out best method, 1 thing i've done in past set config.assets.precompile have domain specific css files

Shopify: More than 3 Product Options -

here scenario: most of clients products simple, have 1 kind of complex. sell makeup compact has 4 empty slots. each slot can filled different type of filler. the user has these options choose fill each slot in compact: – filler type: highlight / filler color: linen filler type: highlight / filler color: sunlit filler type: highlight / filler color: wheat – filler type: contour / filler color: walnut filler type: contour / filler color: stone filler type: contour / filler color: shadow – filler type: blush / filler color: pink grapefruit filler type: blush / filler color: dahlia filler type: blush / filler color: ruby – filler type: illuminator / filler color: pearl – so technically user fill how want. this: slot 1: contour - walnut slot 2: illuminator - pearl slot 3: blush - ruby slot 4: contour - stone or even: slot 1: contour - walnut slot 2: contour - walnut slot 3: contour - walnut slot 4: contour - walnut is there way me

mysql - Filter students that have not passed a subject yet -

i have mysql table , has following values: table name 'results' reg.no subjectcode attempt pass/fail 112108 cmis 1113 1 fail 112110 cmis 1114 1 pass 112119 cmis 1114 1 fail 112108 cmis 1113 2 fail 112107 cmis 1113 1 fail 112108 cmis 1113 3 pass students can have several attempts pass subject. student should pass each subjects degree. student pass in first attempt. take more 3 attempt. student can try until he/she pass. still remain fail. want reg.no of students still unable pass subject. eg.: 112119 , 112107 still unable pass subject. unable write query problem. i suggest using aggregation: select `reg.no`, subjectcode, sum(`pass/fail` = 'pass') results group `reg.no`, subjectcode having sum(`pass/fail` = 'pass') = 0; the having clause counts number of results each student , course last column 'pass' . in mysql, booleans treated integers in numeric context,

ios - Unable to query for Users CKRecords -

with query on public database : let pred = nspredicate(format: "family == %@", ref) let query = ckquery(recordtype: "users", predicate: pred) i no results, though have reference association on 2 users records. even if try: let pred = nspredicate(format: "truepredicate") let query = ckquery(recordtype: "users", predicate: pred) which should return users records, nothing. though i’d understand apple might not want latter, case cannot query specific users well? i have scoured documentation, it's little lacking , cannot find conditionals this. users special recordtype, perhaps answer "no cannot query users". thanks. user records explicitly not queryable. must use ckdiscoveruserinfosoperation , ckdiscoverallcontactsoperation , -[ckcontainer discoveruserinfo...] or -[ckcontainer discoverallcontactuserinfoswithcompletionhandler] find user record. if need query on attribute of user you'll need create n

c# - How to populate 3D chart in Winforms Chart -

i create 3d plots using winforms in c#. can find on microsoft site how turn on 3d mode. there no examples of how populate data x,y , z values. examples use datapoints, have x , y. can point me example series of x y , z values? winform charts don't support 'real' 3d plots. 3d surface plots supports extending of multiple data series in depth dimension. or interpretation: y-values of data series function values of functions on x-[data series index] plane. so create data series x-y-values , data series index z-value.

powershell - sqlcmd. How to pass in a variable that includes a colon and a space? -

i've been struggling while now. i'm trying invoke sql script , pass 2 variables using sqlcmd. i'm doing in powershell. here's i've got: $time = '12:00 am' $date = '06/20/2014' $result = sqlcmd -u username -p password -i "c:\path\to\script.sql" -v date=$date -v time=$time this fails following error message: sqlcmd : sqlcmd: 'time=12:00 am': invalid argument. enter -? help. after experimentation, i've discovered problem colon , space in $time. if remove colon , space $time = '1200am' , command executes without error. unfortunately, script i'm executing wants exact format "12:00 am". things i've tried didn't work: $time="12\:00\ am" $time="12\\:00\\ am" $time="12"+":00"+" am" $time="12"+":00" $time="12"+":"+"00" these respond similar invalid argument failures. last few attempts sol

c++ - Valgrind 8 bytes inside a block of 16 free'd -

i'm writing code lab in class, exercise in ood design using circular linked list. means few key functions used aren't accessible me. however, i'm confused because although driver mimics 1 written professor, i'm still getting mchk error in title. here code references { int nnodesfreed{0}; node* n{head}; for(; n!= head || ! nnodesfreed; n = n->next) { delete n; nnodesfreed++; } cout << "# nodes freed: " << nnodesfreed << endl; } i saw in similar question problem i'm trying access memory has been freed. i.e. how can n = n->next if n doesn't exist anymore. tried switching while loop using current , next pointer, made problem worse. code works in professor's version of assignment, in haven't implemented functions need to. the exact error i'm given is: invalid read of size 8 @ 0x400d8a: main (lab04.cpp:28) // references loop address 0x5a02048 8 bytes inside block of size 16 free'd @ 0x4c28

Java: LinkedHashMaps overlaps over themselves -

i want create copy of linked hash map , want remove values (from list) instead of first entry. here got: linkedhashmap<string, list<value>> facetsincategoriescopy = new linkedhashmap<>(facetsincategories); if (!facets.equals("something")) { (list<value> value : facetsincategoriescopy.values()) { if (value.size() > 1) { int nbrofelements = value.size(); (int = nbrofelements-1; > 0; i--) { value.remove(i); } } } } after operation turns out facetsincategories modified too. why? , how solve issue? appreciated. i don't have 50 reputation add comment. see answer assigning hashmap hashmap essentially, copy constructor used make new map has references mutable objects i.e. facetsincategories , update when update facetsincategoriescopy map. the solution instead deep copy instead. have added test code below, used string instead of value //test https:

unity3d - ScanActivity.class Alternative in Myo Android API -

i'm looking through myo android sdk sample helloworld application. uses following code connect myo armband. method called after user selects "scan" options menu. private void onscanactionselected() { // launch scanactivity scan myos connect to. intent intent = new intent(this, scanactivity.class); startactivity(intent); } the full example can found here . this requires user choose myo armband through menu. there way bypass , automatically connect specific myo armband? yes, in addition scan activity, can pair nearby myo armband using following 2 methods: hub.attachtoadjacentmyo(); this allows pair myo near (almost touching) android device. hub.attachbymacaddress(); this allows pair specific myo armband, defined armband's mac address.

Meteor.js: Collection.insert works on server but not client -

trying understand crud in meteor & have fundamental problem, when remove auto publish , use explicit pub/sub, collection inserts client update server not client collection. the result while field values obtained properly, insert fails on client side. on server side, record inserted correctly. $ meteor remove autopublish create html form file (it's valid , functions expected), then: file /server/publish.js: meteor.publish('todos'), function() { return todos.find(); } file /lib/collections.js: todos = new mongo.collection('todos'); file /client/subscribe.js: meteor.subscribe('todos'); file /client/todos.js: template.todoslist.helpers({ todoslist: function() { return todos.find(); }, }); template.todonew.events({ 'submit form': function(event) { event.preventdefault(); var therecord = { description: $(event.target).find('[id=description]').val(), pri

git log - How can I track down a user that deleted all my branches in git -

we using git , stash @ firm , looks deleted branches master. can please tell me how track down users did it? also, how restore data (if can restored)? to recover: use git reflog find sha1, use git checkout <sha> . to track down: use git log see commmit logs - http://git-scm.com/docs/git-log

sql server 2008 - What is an efficient way to exclude all results from a sql query? -

surprised haven't seen before, googling doesn't yield insight. i'm working framework going generate sql query, or not. have ability add filtering on query, , case has arisen wish exclude possible results. my initial thought add where 1 = 0 clause of query. is there more optimized or efficient way this? since answer vary between platforms, run on sql server 2008 you correct, best , used way exclude results query: where 1=0

jquery - Unable to load images for RoyalSlider in Angular -

an angular app loads images after user action so: <div class="royalslider rsdefault" royalslider> <img class="rsimg" ng-repeat="i in selectedasset[0].images" ng-src="{{ }}" /> </div> in trying use royalslider jquery plugin , used directive: app.directive('royalslider', function() { var linker = function (scope, element, attrs) { scope.$watch('selectedasset', function(){ element.royalslider({ keyboardnavenabled: true, autoscaleslider: true, autoheight: true }); }); }; return { restrict: 'aec', link: linker } }); the problem above deletes images dom when royalslider instantiated. what missing? you not calling directive right in view. use this: <div class="royalslider rsdefault" royal-slider> <img class="rsimg" ng-repeat="i in s

android - Genymotion devices won't start - The Genymotion Virtual device could not obtain an IP address -

Image
when create genymotion device , try start it, says, "the genymotion virtual device not obtain ip address". realize common problem , have looked every , tried several solutions (such this ) , none of them have worked me. attempted start device via virtual box , screen shot of happened. this open virtual box > click android virtual > setting > network > set virtualbox host_only ethernet adapter. than go network , sharing center > open virtualbox connection > properties > ipv4 > set auto dhcp setting note: if have more 1 virtualbox host in virtual box setting try delete , leave one or can more info this

php - Assign button image to links from db -

php newbie. echoing out links product pages, following code works fine: <a href="<?php echo $rows[$product_buy];?>"<p>click here details</p></a> but, change text link "click here..." image of button. tried different ways, searched around, still haven't figured out you style link button (by giving class/id make sure not links targeted) or can put img tag between a tag. <a href="<?=$rows[$product_buy];?>"><img src="path_to_img" alt=""></a>

android - What's Pending in AdMob Mediation -

i created android app , integrated admob, inmobi , mmedia sdks in it, , used admob mediation serve ads app. when go admob mediatio page , open adunit, says "pending" both inmobi , mmedia. question is: 1) what's "pending"? 2) mmedia , inmobi ads serve app? 3) should else app? other suggestions, grateful thanks in advance regards 1) what's "pending"? essentially have register each app admob, inmobi , mmedia. these companies verify each app before can use sdks. process takes couple of days. that's why says "pending". double check have followed instructions correctly. if you've added faulty url app can stuck in pending stage. 2) mmedia , inmobi ads serve app? yes! 3) should else app? i'm assuming app live on app store. if yes, should ready start serving ads on app once verified. i work @ inmobi if have other questions, let me know :)

php - Can i display blog titles from my blog on another external website using iframe, HTML and CSS alone -

i trying display blog posts website https://www.myblog.com on website using iframe. there way in can retrieve blog titles of posts alone https://www.myblog.com , display in box of width 300px , height 300px in second website using iframe or html or css , not using php, python, wordpress plugins, javascript or of kind or not using third party sites rssinclude.com? i if limited iframes, html, , css, create html file titles of blog posts in it. example: <a href="blogpost2" target="_blank">blog post (2)</a><br/> <a href="blogpost1" target="_blank">blog post (1)</a> or unordered list: <ul> <li><a href="blogpost2" target="_blank">blog post (2)</a></li> <li><a href="blogpost1" target="_blank">blog post (1)</a></li> </ul> using html , css iframe alone fetch blog post titles not technically poss

python - Send mixpanel cookies with server side logging? -

have found way pass mixpanel user cookies through on server side logging events? i tried passing them args server-side mixpanel.track, didn't work, e.g. from mixpanel import mixpanel def log_mixpanel(userid,request=none,event=none,args=none): if args == none: args = {} if userid , event: if request: cookie in request.cookies: if cookie.startswith("mp_"): args[cookie]=request.cookies[cookie] mp = mixpanel(settings.mixpanel_project_token) mp.track(userid,event,args) i try hacking mixpanel python library copy request headers over, i'm wondering if there's friendlier way. i'm hoping populate many of same fields possible match javascript library's logging, including device. requires copying useragent & other request headers on mixpanel somehow well.

python - pygame I can move my character but not greatly -

i making game pygame, when change direction, stop , have press arrow key again. doesn't seem big problem, annoying easily. this code (it's written in game's loop, not problem): if event.type == pygame.keydown: if event.key == k_left: coordsx = coordsx - 0.1 elif event.key == k_right: coordsx = coordsx + 0.1 elif event.key == k_up: coordsy = coordsy - 0.1 elif event.key == k_down: coordsy = coordsy + 0.1 elif event.key == k_left , event.key == k_up: coordsx = coordsx - 0.1 coordsy = coordsy - 0.1 elif event.key == k_left , event.key == k_down: coordsx = coordsx - 0.1 coordsy = coordsy + 0.1 elif event.key == k_right , event.key == k_up: coordsx = coordsx + 0.1 coordsy = coordsy - 0.1 elif event.key == k_right , event.key == k_down: coordsx = coordsx + 0.1 coordsy = coordsy + 0.1 for case, don't care when keys pressed or o

sql - Replacing multiple command text variables in OLEDB connection with cell value using VBA -

i still new vba , having bit of difficulty getting work. have connection in excel 2013 linked sql specific script in command text. wanting build vba macro allows me set date range script works on specific cell value. example command text: select [field name] [table name] [datefield] between [datestart] , [dateend] in above scenario, want set [datestart] = "e8" , [dateend] = "e9" how go doing that? of posts have read have said use microsoft query in order set parameters, computer doesn't seem support doing way. you can use replace function since sql query string expression vba: sqlstatement = "select [field name] [table name] [datefield] between [datestart] , [dateend]" datestart = year(range("e8").value) & "-" & month(range("e8").value) & "-" & day(range("e8").value) dateend = year(range("e9").value) & "-" & month(range("e9")

neural network - adding input to doc2vec -

i've started using word2vec , doc2vec methods. amazing! want play around them bit. compared 2 methods saw difference in doc2vec method, there 1 input neural net, docmatrix. want add 1 more input neuralnet (which trained vector somewhere else) , output vector document. easy do? can me understand going on in word2vec code? :)

I can't seem to understand what is creating the next line in this C program -

(homework question) program meant capitalize first letter of each string, need put period behind input. can't seem function capital generates \n reason not aware of. appreciated! need bit, got else. #include <stdio.h> #include <string.h> #include <ctype.h> int capital(char s[]) { int i; for(i=0; i<strlen(s); i++) { if (i==0||(s[i-1]==' '&&s[i]>='a'&&s[i]<='z')) s[i]=toupper(s[i]); } printf("%s.", s); return 0; } int main() { char s[100]; printf("please enter line of text > "); fgets(s, sizeof(s), stdin); capital(s); return 0; } so example want output like please enter line of text > me stackoverflow me stackoverflow. as opposed right now please enter line of text > me stackoverflow me stackoverflow . fgets preserves newline. 7.21.7.2 fgets function #include <stdio.h> char *fgets(char * restrict

graph - Neo4j for an Image database - performance considerations -

i'm looking @ building image database consists of nodes uuid field , other image properties such exif data. i'll search image nodes via uuid field have index. match (img:image {id: "ea191df3-f5e5-4a29-ae93-f850866f90d1"}) return img; are there performance disadvantages doing in neo4j? assuming create uniqueness constraint via create constraint on (image:image) assert image.id unique , proposing makes perfect sense. such constraint not enforces id uniqueness, creates id index automatically. there cost updating index every time add image (or change image id ), unless have many more updates searches, savings when searching image should far exceed cost.

javascript - createtextrange in IE11 -

i need little in creating textrange in ie 11. in previous ie have bit of code var theselection = document.selection.createrange(); --code works on text range because create range returns text range i understand ie11 no longer support selection , have use getselection . new code looks this var theselection = document.getselection().createrange(); --code works on text range because create range returns text range the problem having keep getting error says object not support method or property createrange. have tried this, gives me same error. var theselection = document.getselection().tostring().createrange(); --code works on text range because create range returns text range any ideas? actually, believe have need ... document.selection.createrange() replaced document.getselection() ... there note here ... document.selection replaced window.getselection ...

Using OpenCV TLD from Python -

according release docs opencv 3.0.0, includes implementation of tracking-detection-learning algorithm. there's very basic docs c++ code. i downloaded , compiled 3.0.0-beta, including python wrapper, , seems have succeeded, , although can run python samples, can't find way access , tld functionality through python wrapper. can't find references in code. is included in 3.0.0 release, , if so, how access it? the tld c++ code opencv3.0 in opencv_contrib repo , unfortunately, atm python or java wrapping not ready yet.

meteor - MongoDB: find documents that match the most tags -

in meteor app, have huge collection of documents, each field tags , this: {..., tags: ["a","b","c"], ...}, {..., tags: ["a","b","d"], ...}, {..., tags: ["b","c","e"], ...}, {..., tags: ["x","y","z"], ...}, .... now want query collection on server tags, eg: ["a","d","y"] , results match @ least 1 tag, , resultset sorted number of matching tags . so, in exampleset result should be: {..., tags: ["a","b","d"], ...}, {..., tags: ["a","b","c"], ...}, {..., tags: ["x","y","z"], ...} because first doc has 2 matches, "a" , "d" , , other 2 elements have 1 match, "a" , "y" . currently know can use $in match documents have @ least 1 match, $all documents every tag matches, doesn't cut somehow. use mo

java - Random Generator from String Array -

i'm using java problem. know how randomly take 2 questions out of 3 question string array? lets have 3x5 string array this: string testbank[][] = {{"what color grass?","a. green","b. red","c. pink","a"}, {"whats first month called?","a. december","b. january","c. march","b"}, {"what shape soccer ball?","a. square","b. flat","c. round","c"}}; the first column question, 2nd-4th column answer choices, , 5th column correct answer. i'm trying figure out how randomly 2 questions these 3 , store 2 questions 1 dimensional array of 2 rows in use joptionpane, outputting, in takes questions 1 dimensional array , shows each question separately 1 one in different windows answer choices included. , after answering 2 questions, tells user score based off how many questions he/she missed. i'm relatively new java , appreciated if me

survey - how to deal with replicate weights equal zero in R? -

i have 0 values replicate , sampling weights. therefore, when use svycoxph “survey” package, error message “package invalid weights, must >0”. think 1 way might exclude these observations. wonder if there way keep observations cox proportional hazards model? thanks! julia zero replicate weights normal -- jackknife replicates observations psu being left out; bootstrap replicates psus appeared 0 times in particular resample. 0 sampling weights, on other hand, don't make lot of sense , indicate observations aren't in sample or aren't in sampling frame (personally, i'd code these na ) the coxph() function in survival package can't handle negative or 0 weights, , that's svycoxph() calls. replicate weights, svycoxph() adds small value (1e-10) weights stop problems zeros. however, svycoxph() can't handle 0 sampling weights. want remove these before constructing design object.

javascript - Undefined Variable In document.write -

i keep getting "toggleonlyrelatedposts not defined " in chrome console , script doesn't work. i'm working on script , i've gotten lost after adding many variables. i'm not @ sort of thing , me looks defined, guess it's not. chrome marks error @ document.write here script: <script type="text/javascript"> //<![cdata[ function postgrabber(json) { // magic (var = 0; < json.feed.entry.length; i++) { (var j = 0; j < json.feed.entry[i].link.length; j++) { if (json.feed.entry[i].link[j].rel == 'alternate') { var posturl = json.feed.entry[i].link[j].href; break; } } // thumbnail stuff var orgimgurl = json.feed.entry[i].media$thumbnail.url ? json.feed.entry[i].media$thumbnail.url : 'http://1.bp.blogspot.com/-mxinhrjwpbo/vd6fqbvi74i/aaaaaaaacn8/lsl

python - Numpy.linalg.det() returns incorrect result -

would know why numpy returning "-2.0000000000000004" instead of "-2" >>> m = [[1,2],[3,4]] >>> numpy.linalg.det(m) -2.0000000000000004 i using python 3.4.2 (x64), numpy 1.9.1 , windows 7 x64.

ios - Nothing is displaying in Simulator with viewWillLayoutSubviews -

within gameview controller.swift file, removed viewdidload , put in viewwilllayoutsubviews because using dimensions of device in calculations. however, hello world sklabelnode no longer displayed in simulator. ideas on i'm doing wrong? override func viewwilllayoutsubviews() { super.viewwilllayoutsubviews() let skview = self.view skview if skview.scene != nil{ skview.showsfps = true skview.showsnodecount = true skview.showsphysics = true // create , configure scene let scene = skscene(size: skview.bounds.size) scene.scalemode = skscenescalemode.aspectfill; // present scene skview.presentscene(scene) }

malloc a array in C with loop dynanic array(2D) -

it compiles no errors when try execute when reaches part of code freaks out , stops.(crashes , exe doesn't respond) //creation of array 2 lines_2 x cols_2 size array_2 = (int **)malloc(lines_2 * sizeof(int*)); for( i=0; i< lines_2;i++) { array_2[i] = (int*) malloc(cols_2 * sizeof(int)); } full code trying create program multiplies 2 dynamic arrays. #include <stdio.h> #include <stdlib.h> int checkifmul(int ,int );//intx2 void fill( int **,int ,int );//ar intx2 void arraymuarray( int **, int **, int **,int,int ); int main(){ int i,lines_1,lines_2,cols_1,cols_2,**array_1,**array_2,**array_r1,**array_r2; //input do{ do{ printf("enter lines of first array.\n"); scanf(" %d/n",&lines_1); }while(lines_1 <1); do{ printf("enter columns of first array.\n"); scanf(" %d/n/n",&cols_1); }while(cols_1 >5); do{ printf(&

user interface - Launching and waiting a GUI app to finish with Python -

i need launch gui application, wait application quit, , start other processes. import subprocess res = subprocess.check_output(["/usr/bin/open", "-a", "/applications/mou.app", "p.py"]) print "finished" ... start other processes however, process returns right away without waiting mou.app finish. how can make python process wait? use mac os x. according the open man page , -w flag causes open wait until app exits. therefore try: import subprocess res = subprocess.check_output(["/usr/bin/open", "-a", "-w", "/applications/mou.app", "p.py"]) print "finished"

Selecting ASCII in Java -

sending url post , answer throughout bufferredreader respond coming in ascii. how incoming string can break pieces , use string need? params.put("ssl_result_format", "ascii"); bufferedreader in = new bufferedreader(new inputstreamreader(conn.getinputstream(), "utf-8")); string line; receipt pp = new receipt(); pp.setvisible(true); while ((line = in.readline()) != null) { receipt.recetext.append(line + "\n"); system.out.println(line); this how display: ssl_card_number=50**********3003 ssl_exp_date=1215 ssl_amount=12.00 ssl_invoice_number= ssl_departure_date= ssl_completion_date= ssl_issue_points= ssl_promo_code= ssl_enrollment= ssl_result=0 ssl_result_message=approval ssl_txn_id=051214a15-6e33e984-7c6b-466d-b38c-83f24bdac631 etc...... edit: finished this: properties prop = new properties(); bufferedreader in = new bufferedreader(new inputstreamreader(conn.getinputstream(), "ut

java - Send email when JButton is clicked? -

someone please please thorough , me this, i've been @ forever now. i'm new programming , i've never set server or before. error trying run program. " java.net.connectexception: connection refused: connect " , " javax.mail.messagingexception: not connect smtp host: localhost, port: 25; " here's code : private void jbutton1actionperformed(java.awt.event.actionevent evt) { if (jbutton1.isenabled()); properties sessionproperties = system.getproperties(); string = "bleh@gmail.com"; string = "bleh@gmail.com"; string host = "localhost"; properties properties = system.getproperties(); properties.setproperty("mail.smtp.host", host); session session = session.getdefaultinstance(properties); try{ // create default mimemessage object. mimemessage message = new mimemessage(session); // set from: header field of header. message.setfrom(new internetaddress(from));

javascript - Stating variables in the onClick attribute, and using multiple commands in onClick -

alrighty then. before started, did search this, realize there other threads on topic, none of them answered question well. so trying when tag clicked, creates variable inside of onclick attribute can accessed function used case switch. 1)can variables created in onclick attribute? 2)can multiple commands executed in onclick attribute? : onclick="alert('boo!'); afunction();"? i apologize lack of code, using apple ipad, , don't use tab button or indents, blah blah.. heres tried: [..omitted..] var item = "null"; function executefunction(){ switch(item){ case "item1": document.getelementbyid("div1").style.display='block'; document.getelementbyid("div2").style.display='none'; document.getelementbyid("div3").style.display='none'; document.getelementbyid("div4").style.display='none'; break; case "item1": document.getelementbyid("div1").s

SQL: Delete every ID that's greater than or equal to -

i'm trying make can run sql script makes deletes every account has id greater or equal 3000. this have far: delete column `id` => 3000 suppose want remove employees officenumber 4, use delete statement clause following query: delete employees officecode = 4

c++ - Can't seem to use this function in the Boost library -

i'm working on program uses boost regular expressions library, , i'm running issue while trying call boost::regex_match() function, i'm getting strange error i've never encountered before. here relevant code. boost::regex pattern("regex redacted"); boost::cmatch what; xerces_std_qualifier cout << "enter xml document-building commands" << xerces_std_qualifier endl; while(true) { // take input user. std::string input; xerces_std_qualifier cout << ">> "; xerces_std_qualifier getline(in, input); if(boost::regex_match(input, what, pattern)) { // whatever } } this took out of example code similar program instructor provided assignment. when try compile, error. if helps, i'm using netbeans 8. xmldoc.cpp: in member function ‘void xmldoc::createdoc(std::istream&)’: xmldoc.cpp:164:51: error: no matching function call ‘regex_match(std::string&, boost::cmatch&, boos

c++ - How do I delete an object pointer from a vector without causing a memory error? -

i have vector of object pointers adding , deleting while looping through update objects. can't seem delete objects have "died" vector without causing memory error. i'm not sure i'm doing wrong. listed below update method , it's sub method. void engine::update(string command){ if(getgameover()==false){ for(p=objects.begin();p!=objects.end();p++){ spawnupdate(command); //cout<<"spawn"<<endl; objectupdate(command); //cout<<"object"<<endl; scrollupdate(command); // cout<<"scroll"<<endl; killupdate(command); //cout<<"kill"<<endl; } } } void engine::killupdate(std::string command){ if((*p)->getisdead()==true){delete *p;} } void engine::objectupdate(string command){ (*p)->update(command,getnumobjects(),getobjects()); if(((*p)->gettype() == player)&&((*p)->getposx()>=

Is the container rebuilt at each request in Symfony 2 dev mode -

when creating own service, looks object created each time. service : services: plbcache: class: robusta\plbbundle\cache\lrucache arguments: [10, %timeout%, %enablecache%] class : class lrucache { public function __construct($capacity=10, $timeout=-1, $enabled=true) { echo "creating cache"; // appear @ each request $this->capacity = $capacity; $this->timeout = $timeout; $this->enabled = $enabled; } } obviously, have problem test if objects in cache if cache object rebuilt each time. for have understood, service container of symfony singleton , default gives singletons - thought can configured prototypes or clients sessions. should give me same services objects after each request. i have seen in docs container rebuild in dev environment. did miss something, or code wrong ? how prevent dev mode rebuilding cache object ? container doesn't share instances between requests. each request independ

SQL Server dynamic stored procedure - passing parameter value to like search -

i have users table categories column delimited values. i'm trying pass category , perform search users table in dynamic sql. the category value paramterized. declare @sqlquery nvarchar(4000) declare @paramdef nvarchar(2000) set @paramdef = '@category varchar(100)' set @sqlquery = 'update [u] set [u].[status] = 1 [dbo].[users] [u] [u].[categories] ?? execute sp_executesql @sqlquery ,@paramdef ,@category i want search check %,@category,% did try form query this? declare @sqlquery nvarchar(4000) declare @paramdef nvarchar(2000) set @paramdef = '@category varchar(100)' set @sqlquery = 'update [u] set [u].[status] = 1 [dbo].[users] [u] [u].[categories] '''+ '%' + @category + '%' + '''' execute sp_executesql @sqlquery ,@paramdef ,@category please let me know if helps. ashraf

Adding two strings made of digits recursively in C -

for problem, first take in 2 strings using fgets. need check if string comprised entirely of digits making number. able part recursively, next task if strings numbers, need sum them recursively well. example, output of program may this: first number > 9023905350290349 second number > 90283056923840923840239480239480234 sum 90283056923840923849263385589770583 again, need recursively, thinking march along stream of digits , add them together, not sure how write program recursively. since input in character form, have convert integer, believe can converting individual characters integer ascii value subtracting 48 away it. appreciated. thanks! you're on right track. recursive approach checking if input number looks following, right? notice can go ahead , subtract '0' character without bothering convert 48 yourself. int number_length(char *s, int pos) { int d; if (s[pos] == '\0') { return pos; } d = s[pos] - '0'; if (