Posts

Showing posts from April, 2013

osx - How to run a Mac application From Java? -

i tried code below run stand-alone utility app created apple script but, no file or directory exists error. i put identical copies (for testing) in project, dist, parent directories but, didn't help. so, questions are: call run app bad (perhaps because it's not windows exe)? how run mac app java? thanks private void jbutton1actionperformed(java.awt.event.actionevent evt) { // todo add handling code here: runtime r=runtime.getruntime(); process p=null; string s="mylineininput.app"; try { p = r.exec(s); } catch (ioexception ex) { logger.getlogger(audioswitcherview.class.getname()).log(level.severe, null, ex); } } a mac app bunde not executable file, it's folder special structure. can opened using open command, passing app bundle path argument: open mylineininput.app . edit: better using desktop.getdesktop().open(new file("mylineininput.app"));

sql - Take away the EXISTS but leave in the switch -

how can modify final script have exclusions switch? not want use exists in final script: select myfield = 'x' #data union select myfield = 'y' union select myfield = 'z' union select myfield = 'j' union select myfield = 'q' union select myfield = null; select myfield = 'j' #exclusions union select myfield = 'q' union select myfield = null; declare @showall tinyint = 1; -->>exceptions "switch" turned on data returned select * #data d @showall = 1 or ( exists ( select d.myfield except select myfield #exclusions ) ); --can simplify , rid of exists still include switch based on @showall ? select * #data d except select myfield #exclusions; select * #data d except select myfield #exclusions @showall <> 1; http://sqlfiddle.com/#!6/d41d8/3125

html - Python scraping pdf from URL -

i want scrape text url " http://www.nycgo.com/venues/thalia-restaurant#menu " text i'm interested in in 'menu' tab on page. tried beautifulsoup text on page, return value following code misses text in menu. html = urllib2.urlopen("http://www.nycgo.com/venues/thalia-restaurant#menu") html=html.read() soup = bs(html) print soup.get_text() it seems content of menu part of html on page when inspect elements menu content. did notice when physically browsing page, takes several seconds menu load. not sure if that's why code above fails menu content. any insight appreciated. while soup.get_text() will return of text html document (webpage) problem here menu embedded in page pdf, beautiful soup cannot access. actual pdf file defined in javascript follows: { name: "menu", show: boolean(1), url: "/assets/files/programs/rw/2016w/thalia-restaurant.pdf" } the simplest way extract use regular expressions. wh...

Need Crypto library for Arduino -

i need use aes encryption , message authentication code mac in code. not find crypto library in arduino standard libraries. found available libraries other links such this: https://github.com/cathedrow/cryptosuite can advise me best implementation know aes , hmac algorithms? markt has created nice port of aes library. https://forum.arduino.cc/index.php?topic=88890.0 some folk have ported rokkit hash: https://forum.arduino.cc/index.php?topic=226686.0 but if search arduino.cc site, find few different implementations , algorithms. there no better implementation, either works or doesn't. need decide whether footprint , memory usage acceptable situation. btw, found these 5-second search of arduino site. seem have missed obvious research locations.

Haskell - Lisp-like symbol functionality -

i wrote lisp function while matched nested lists of symbols against other lists. worked this: (match '(a b c) '(1 2 3)) => ((a 1) (b 2) (c 3)) (match '(a b (c d)) '(1 (2 3) (4 5))) => ((a 1) (b (2 3)) (c 4) (d 5)) i trying achieve similar functionality in haskell. looking allows readable symbols used in indexing results. use integers, lists involved tended bit unreadable that. there easy symbol type in haskell? i have come across data.atom.simple, want less awkward that. i don't have knowledge lisp don't know if setting variables or creating associative array. you - set variables: main data.tree> let (node ((node b []):c:[])) = node 'a' [node 'b' [],node 'c' []] *main data.tree> 'a' *main data.tree> b 'b' *main data.tree> c node {rootlabel = 'c', subforest = []} but i wouldn't recommend it - matching on lists unsafe , far knowledge concerned don't know "s...

apache - Pooling CloseableHttpClient without caching -

i used singletone configuration manage pooled http client public closeablehttpclient getcloseablehttpclient() { poolinghttpclientconnectionmanager cm = new poolinghttpclientconnectionmanager(); cm.setmaxtotal(100); cm.setdefaultmaxperroute(20); requestconfig globalconfig = requestconfig.custom() .setcookiespec(cookiespecs.ignore_cookies) .build(); return httpclients.custom() .setconnectionmanager(cm) .setdefaultrequestconfig(globalconfig) .build(); } the problem uses cookies. can switch off ones? if i'm using client second time same url, has cookiestore nonempty cookie elements.

Python: Find element in the list which has frequency = 2 -

let's have list: input: ids = [123, 456, 123] i need find element frequency 2. output: 123 best way in python? from collections import counter counter = counter(ids) [k k,v in counter.items() if v == 2]

ruby on rails - Using form_for with "becomes" loses child association -

when building out form handles sti, if use becomes transform object parent class, lose ability use nested fields it. i have 2 models class login < activerecord::base belongs_to :user end class user < activerecord::base has_one :login accepts_nested_attributes_for :login end i have few subclasses of user. class consumer < user end class admin < user end class agent < user end initially had problems routing, since rails assume wanted route specific current class rather parent class, used @user.becomes(user) , apparently way handle that. part works fine, causes @user.login disappear. controller class admin::userscontroller < admincontroller load_and_authorize_resource before_filter :authenticate_user! def index render 'index' end def new @user = user.new @user.build_login render 'new' end def create @user = user.new(user_params) if @user.save flash[:notice] = "account confi...

dns - @ Hostname not being overridden by other A record? -

my domain's a records are: host: points to: @ 66.6.44.4 experiments 188.121.46.1 the @ points tumblr blog, , experiments subdomain points hosting. the problem i'm having is, experiments.example.com somehow redirecting ( curl shows it's 301) example.com/experiments/ . i've checked http://whatsmydns.net , confirms hosts point ips. how happening? i've emptied dns cache few times don't think it's that. redirect coming from? thanks. actually not dns problem, webserver issue. your webserver running @ http://experiments.example.com redirects http://example.com/experiments/ . check webserver configuration find redirect directives. dns resolves names ip addresses. not redirect http requests. http protocol. http://experiments.example.com connect server experiments.example.com (ip 192.0.2.46) on port 80 webserver listens, accepts request , redirects http://example.com/experiments/ , broswer follo...

osx - how to manage firewall settings on local rails server -

i'm trying setup basic opentok video connection between 2 osx computers on local rails server. second computer connects local rails server, opentok video component not work/tells me have firewall issue. i'm out of depth on network administration stuff. how investigate possible firewall issue in context? it's not blocking other computers' access somehow interfering connection opentok's servers. details: i first tested code on own computer. booted webrick rails s, went localhost:3000, osx built-in webcam connects, code works. opened separate incognito tab in chrome , loaded localhost again two-way connection. works. great. then tried booting internal ip (rails s -b 192.168.0.100) connect local server different computer. server starts fine, go http://192.168.0.100:3000 , code works (e.g. can login, page loads, etc) web cam video won't load (it's blank black video screen loading icon, if matters). connect http://192.168.0.100:3000 other computer, code...

decimal to hexadecimal converter WITHOUT dec2hex function in excel -

Image
i did hex decimal, need decimal hex. need build formula in excel converts decimal number hexadecimal but: 1. without function "dec2hex()". 2. , without "vba". only in excel table. thanks, hai place decimal value in a1 . in b1 place: =mod(a1,16) and copy down. in a2 place: =(a1-b1)/16 and copy down. in c1 place: =choose(b1+1,0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f") and copy down. in d1 enter: =c1 in d2 enter: =if(a2=0,"",c2 & d1) and copy down. last visible cell in column d answer: it better use excel's built-in function.

ruby on rails - Dropzone.js and form validation -

is possible not break nice rails form validation errors displayed after marking whole form 'dropzone' class? now, when try submit form, nothing changes , page stays @ without providing info user fields doesn't meet requirements. controller renders json response (dropzone using consequence) seems not processed view. thank in advance quick response. my workaround problem: dropzone.options.filedrop = { init: function () { // other triggers not listed // ... this.on("error", function (file, response) { // gets triggered when files have been sent. // redirect user or notify of success. // build unordered list list of errors var _ref, _results, _i, _len; if ($.isplainobject(response)) { // check if response in json format showing standard form errors // remove errors accepted image file.previewelement.classlist.remove("dz-erro...

java - about import statement -

i want know can check how many classes have been loaded class loader. want know, whether import statement in class * mark load many classes in perm area of heap? or when declare reference of specific type following 2 classes loaded? ex. map m = new hashmap(); //only these 2 classes loaded??? what if write import statement like java.util.*; will class loader loads classes under java.util package? there class unloading process in java? if want see classes loaded @ runtime try this: java -verbose:class you should have question is there way classes classloader has loaded?

Why do my eclipse cdt breakpoints get deleted immediately after they are added? -

Image
this has been working fine while, , there lots of eclipse breakpoint bugs, one's not others. i can add breakpoint, shows in breakpoint list make breakpoint, little blue dot checkpoint shows up, checkpoint goes away. here's gdb trace... 355,448 50-break-insert -f xxx 355,448 50^done,bkpt={number="9",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000435f1e"\ ,func="xxx(void const*, unsigned long)",file="xxx.cpp",fullname="xxx.cpp",line="223",thread-groups=["i1"]\ ,times="0",original-location="xxx.cpp:223"} 355,448 (gdb) ... , happens.... 355,601 51-break-delete 9 355,601 51^done 355,601 (gdb) i'm sure it's state bug of config somewhere, , don't care why. have deleted breakpoints , restarted, debugger related cache stuff stored can try , delete it? i'd rather not have rebuild workspace. edit: gdb version gnu gdb (ub...

how to monitor and restart two ruby scripts with God? -

i have been able run single god file single ruby script such: god.watch |w| w.name = "twilio" w.start = "ruby ~/code/site/iron.io/twilio-listen.rb" w.keepalive end but have 2 scripts , want have god watch both of them (twilio-listen.rb , slack-listen.rb) how do that? you should able specify watches both in same god config file. might want add group called listeners if ever needed stop or restart them together. e.g., god.watch |w| w.name = "twilio" w.group = "listeners" w.start = "ruby ~/code/site/iron.io/twilio-listen.rb" w.keepalive end god.watch |w| w.name = "slack" w.group = "listeners" w.start = "ruby ~/code/site/iron.io/slack-listen.rb" w.keepalive end

mongodb - Mongo Auto Balancing Not Working -

i'm running issue 1 of shards @ 100% cpu usage while i'm storing files mongo db (using grid fs). have shutdown writing db , usage drop down 0%. however, auto balancer on , not appear auto balancing anything. have 50% of data on 1 shard 100% cpu usage , virtually others @ 7-8%. any ideas? mongos> version() 3.0.6 auto balancing enabled storage engine: wiredtiger have general architecture: 2 - routers 3 - config server 8 - shards (2 shards per server - 4 servers) no replica sets! https://docs.mongodb.org/v3.0/core/sharded-cluster-architectures-production/ log details router 1 log: 2016-01-15t16:15:21.714-0700 network [conn3925104] end connection [ip]:[port] (63 connections open) 2016-01-15t16:15:23.256-0700 network [lockpinger] socket recv() timeout [ip]:[port] 2016-01-15t16:15:23.256-0700 network [lockpinger] socketexception: remote: [ip]:[port] error: 9001 socket exception [recv_timeout] server [ip]:[port] 2016-01-15t16:15:23.256-0700 network ...

scala - Why doesn't this Python code for powerset work? -

i can't identify blatantly wrong except trying scala-type operations python. def powerset(arr): if len(arr) == 0: return [] elif len(arr) > 1: return powerset(arr[1:])+[arr[0]] i consistently error: return powerset(arr[1:])+[arr[0]] typeerror: unsupported operand type(s) +: 'nonetype' , 'list' if len(arr) == 1 nothing returned ... just change def powerset(arr): if len(arr)>0: return powerset(arr[1:])+[arr[0]] else: return [] here powerset function https://docs.python.org/2/library/itertools.html def powerset(iterable): "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)" s = list(iterable) return chain.from_iterable(combinations(s, r) r in range(len(s)+1)) here powerset implementation uses less magic def powerset(seq): """ returns subsets of set. generator. """ if len...

database - SQL Compact is not showing data in tables -

i have program entering in values sql compact data table. problem data not showing in tables in visual studio, acting there since warning if try add values same primary key. has else had problem? there setting possibly not have set in visual studio? appreciated. in advance!

visual studio - NuGet does not execute scripts when restoring packages -

nuget not execute scripts when restoring packages in project. here's scenario: have project has custom nuget package installed. project has nuget package restore enabled solution. working flawlessly, tested multiple times getting project tfs onto empty folder. i've added init.ps1 , install.ps1 nuget package, , package still fetched , installed properly, scripts not execute unless package installed manually. to exact, if project tfs first time, neither init.ps1, nor install.ps1 executes. however, if close solution , reopen it, init.ps1 executes (as expected), but, of course, install.ps1 still doesn't since package has been restored/installed. both scripts execute when package installed/uninstalled manually (i.e. doesn't run if package "restored"). my internet searched haven't turned references behavior. missing obvious, or normal when packages restored? the package restore feature used not packages checked source control. suc...

Elasticsearch: multi indices one type OR one index multi types -

as the definitive guide -> indexing employee documents said relational db ⇒ databases ⇒ tables ⇒ rows ⇒ columns elasticsearch ⇒ indices ⇒ types ⇒ documents ⇒ fields and the definitive guide -> index aliases , 0 downtime said be prepared: use aliases instead of indices in application. able reindex whenever need to. aliases cheap , should used liberally. the question is, if indices databases , if want rebuild 1 type ( table ) have reindex whole database , reasonable ? (this one index multi types ). or have create many indices project , every index has 1 type, sounds project has dozens databases! i think understand confusion. have 1 index named my_index , 3 types type1 , type2 , type3 . create alias alias1 index. now want change mapping of type1 , need reindex every document of type1 want zero downtime create new index index2 , reindex documents of type1 , if want alias1 refer new index, problem arise , said have reindex o...

terminal - Shell line 7: [14: command not found -

this question has answer here: shell script command not found when comparing string 1 answer i don't know problem fix here code: #!/bin/sh while true hour=$(date '+%h') target=16 echo $hour if [$hour -gt $target]; mail -s "ip" "example@hotmail.com" <<eof global_ip=$(curl -s checkip.dyndns.org | sed -e 's/.*current ip address: //' -e 's/<.*$//') eof echo "sent" fi echo "waiting..." sleep 3600 echo "done waiting" done please help! you have add blanks after [ , before ] : if [ $hour -gt $target ];

Explanation of a number in allocation data in Android studio -

i got data allocation tracker in android studio. fine, except, don't understand particular piece of data. here screenshot . what these numbers come right after method name , colon mean? that line number with-in method allocation happened on.

ios6 - Distributing pilot iOS apps to educational institutions -

i'm looking optimal way distribute prototype/pilot apps k-12 institutions , can't quite seem figure out. it doesn't seem using either regular app store or volume purchase program stores ideal, app work our pilot classrooms teachers have been given login credentials. else not able use app in way, , we'll lowest rating, if app makes past review. the 2 options seem viable-ish are: enterprise distribution: it's technically not meant scenario, i've heard people use successfully. build app , distribute through enterprise distribution flow. problem technically, since we're not affiliated institutions we're piloting in, we'd have have them pay $300/year , add contractor developers them, don't envision happening. approach heard of of developers signing enterprise account , using institutional devices if part of company. custom b2b app: seems 1 use route well, though custom b2b apps still go through apple review process, i'm not clear if pr...

java - Saving Android FaceDetector.Face[] on rotation -

i trying save facedetector.face array on screen rotation, facial detection not have performed again. app seems take longer normal rotation. however, can't store faces array in onsavedinstancestate since isn't serializable. tried extending facedetector.face implementing serializable, doesn't have default constructor. should save object array 1 on rotation, didn't implement? i suggest creating static fragment without ui on activity. once that, can use store data. keep in mind facedetector.face, object holds locations on bitmap , not bitmap itself.

JavaScript sorting using function -

while doing online course came across following code. unable understand logic of method. grateful if can me understand code: var v=[30,2,1,9,15,10,55,20,45,30,25,40,50,35]; var msg = document.getelementbyid("message") msg.innerhtml +="<p><strong>original order:</strong>[" + v + "]<p>"; v.sort(); msg.innerhtml +="<p><strong>after sorting order(string):</strong>[" + v + "]<p>"; v.sort(function(a,b){return a-b;}); msg.innerhtml +="<p><strong>after sorting order(ascending):</strong>[" + v + "]<p>"; v.sort(function(a,b){return b-a;}); msg.innerhtml +="<p><strong>after sorting order(descending):</strong>[" + v + "]<p>"; i need understand function(a,b){return a-b} - how function helping javascript sorting? please note new programming. although others have provided many great links wanted s...

c# - Attach a Context Menu to a GUI.Window -

Image
i have custom window has multiple gui.window 's inside of it. can create context menu main window , works. when try create context menus gui.window doesn't work. when right click on window starts drag around main window. here have list stores window information: // stores list of windows list<storyboardwindow> windows = new list<storyboardwindow>(); then here loop through windows , call drawnodewindow : // draws windows screen void ongui() { (int = 0; < windows.count; i++) { windows[i].window = gui.window(i, windows[i].window, drawnodewindow, windows[i].windowtitle); } } i have method creates genericmenu window, doesn't work when right click on window. // supposed create context menu window void drawnodewindow(int id) { event currentevent = event.current; if (currentevent.type == eventtype.contextclick){ genericmenu menu = new genericmenu(); menu.additem(new guicontent("remove"), false, remove...

How to disable a button only when EditText is numerically empty in android studio? -

i have button works according function when user enters number in edittext. however,when edittext numerically empty,when click on same button, make app stop working. help? please consider "numerically" part because not find answers query? code public void send(view v){ string text = edittext.gettext().tostring(); if (text.matches("")) { mybutton.setenabled(false); return; } } xml <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <edittext android:layout_width="0dp" android:layout_weight="1" android:inputtype="number" android:layout_height="wrap_content" android:hint="enter:" android:id="@+id/edittext" /> <button android:layout_width="wrap_content" android:lay...

ios - UILabel positioning different when text is present vs when text isn't present -

Image
here picture of how want view positioned (i have constraints set in interface builder) below images want , how set in interface builder (pic # 1) the second 1 interface @ runtime. note: once labels textual data during runtime, view expands give labels space (i.e. first picture) my goal eliminate "animated movement". want view/progress bar/everything remain static once has been situated @ runtime , not bouncing , down if data in labels or if isn't. i not want use stack view because ios 7 not supported feature or would. note: it's different colors, same view problem shows stated in question. lazy , don't want explain myself how lazy , why different... you should add height constraint constant, e.g. 20, , relation "greater or equal" each of labels. way autolayout know exact height needed before label text set, , allow labels stretch vertically if text long 1 line

javascript - Google maps api async loading - have tried all the solutions - going insane -

i'm trying desperately finish project http://kenziejoy.github.io/frontend-nanodegree-map/ (that gh-pages branch, master little behind) and while tinkering other things map disappeared...forever. can't find wrong. feel i've tried everything: async, defer, async defer, callback function in html calls function in js file (someone suggested it), initmap inside viewmodel, outside viewmodel, wrapped in self running function. most of errors either, callback isn't function, google isn't defined or in js file isn't defined. i've poured through make sure isn't silly misplaced comma - i'm getting frustrated i've made stupid mistake somewhere. appreciated. @ least can map there , make progress on else. looking @ code in link in app function in main.js not declared googlemap var globally. you must declare var googlemap ; in top of main.js

wordpress - How can I add space between Posted on January 13, 2016 and January 13, 2016 by admin? -

i wan make space between "posted on january 13, 2016january 13, 2016 admin" .how can add space between posted on january 13, 2016 , january 13, 2016 admin? use css add space: .posted-on .published { margin-right: 10px; } p.s. please @ least try before posting question on so. thanks

python - When is --thunder-lock beneficial? -

this long, detailed, , entertaining article describes history , design of --thunder-lock : http://uwsgi-docs.readthedocs.org/en/latest/articles/serializingaccept.html but doesn't me decide when need it! when , isn't --thunder-lock beneficial? well... answer not easy. in general, should use when you're using multiple workers multiple threads. but... there dozens of different operating systems , thunder locking highly dependent on capabilities. there @ least 6 different mechanisms of thunder locking, choosed uwsgi based on operating system capabilities, of them better other. if you're using example linux robust pthread support, you're 99.999999% safe use thunder-lock.

c# - ManagedThreadId return same value for 2 threads -

please consider code: textbox1.text = "enter thread current thread id : " + thread.currentthread.managedthreadid.tostring(); int result = 0; task t = task.factory.startnew(delegate { (int = 0; < 5; i++) { result = result + i; system.threading.thread.sleep(1000); this.invoke((action)(() => textbox1.text += environment.newline + result.tostring() + " current thread id : " + thread.currentthread.managedthreadid.tostring())); } },cancellationtoken.none, taskcreationoptions.none); i got result: enter thread current thread id : 10 0 current thread id : 10 1 current thread id : 10 3 current thread id : 10 6 current thread id : 10 10 current thread id : 10 i ran code on windows form application. why thread.currentthread.managedthreadid return same value ui thread , task thread? code inside of task run in separate thread? thanks when did this...

android - Image Fading in Java -

i facing problem while trying cross fading in android studio. first, have following code cross fading between 2 images. code works fine. public class mainactivity extends appcompatactivity { public void fade(view view) { imageview front = (imageview) findviewbyid(r.id.front); imageview image1 = (imageview) findviewbyid(r.id.image1); front.animate().alpha(0f).setduration(1000); image1.animate().alpha(1f).setduration(1000); image1.bringtofront(); } public void fade1(view view) { imageview front = (imageview) findviewbyid(r.id.front); imageview image1 = (imageview) findviewbyid(r.id.image1); image1.animate().alpha(0f).setduration(2000); front.animate().alpha(1f).setduration(2000); front.bringtofront(); } but, when try same fading using 3 images, code doesn't work. doesn't fade images properly. here code: public void ...

java - why can't it allow "<%@ include file" inside a HttpServletResponse? -

this question has answer here: what effects of disabling scripting in jsp? 2 answers ok, got jsp file & works ok <html> <head><title>account</title></head> <body> <%@ include file="header.jsp" %> </body> </html> now, got servlet public void doget(httpservletrequest req, httpservletresponse resp) throws ioexception { resp.getwriter().println("<html>"+ "<head><title>account</title></head>"+ "<body>"+ "<%@ include file=\"header.jsp\" %>"+ "</body"+ "</html>" } the servlet print out <%@ include file="header.jsp" %> text on page & not un...

Use Facebook Access token via Android on Laravel Backend -

i have android app gets access token facebook sdk , further want send token php-laravel backend , retrieve user details. i made httppost call param accesstoken accesstoken.gettoken() laravel , there retrieve it, token same when try login web interface , token. then made call to $user = socialize::driver('facebook')->getuser($request->token); // manual function added abstractprovider class public function getuser($token){ $state = null; if ($this->usesstate()) { $this->request->getsession()->set('state', $state = str::random(40)); } $user = $this->mapusertoobject($this->getuserbytoken($token)); return $user->settoken($token); } but error in log [2016-01-16 07:30:24] local.error: exception 'guzzlehttp\exception\clientexception' message 'client error: get https://graph.facebook.com/v2.5/me?access_token=&appsecret_proof=/* proof here*/&fields=first_name,last_name,email,gender,veri...

Converting javascript stringified string to java string -

i have app uses parse backend. parse calls web scraper returns string parse , have use stringify on string received because it's not allowed sent on network otherwise. once stringify string how can parse in java have original returned string. instance, how go stringified string in javascript "\"this string\"\r\n\t\t" to string in java "this string" to reiterate, start string (such "this string") have stringify send on network (result "\"this string\"\r\n\t\t"). once return stringified string android app, how can original string ("this string")? try stringescapeutils apache commons string input = "\"this string\"\r\n\t\t"; string output = stringescapeutils.unescapejava(input); system.out.println(output); "this string"

Map and HashMap in Java -

this question has answer here: what difference between hashmap , map objects in java? 12 answers i new java , came across following usage hashmaps : public static hashmap< string, integer > table1; .... table1 = new hashmap< string, integer > (); ..... public map<string, integer> table2 = new hashmap<string, integer>(); my question above statement equivalent ? see map<string, integer> used table2. hashmap< string, integer > table1 , map<string, integer> table2 same programing construct ? can used interchangeably? map interface, implemented in several implementations hashmap. and hashmap complete implementation class. an useful answer here - difference between hashmap , map in java..?

php - simple sql order by position -

okay have been putting off because has been partially working, need it. i want output: id position 1 1 2 2 15 3 16 4 i thought this^ it. getting whole pages table. select * pages order position asc id link_id menu_name position content visible 1 1 new article 1 first picture , article 1 2 1 edit articles 2 delete articles/edit 333 the * in query means you'll select every colomn, use columnames want retrieve. example: select id, position pages order position that's ;)

Verilog : How to assign values to 2 random indexes in a big array? -

i have array made like genvar p; generate (p = 0 ; p < 128 ; p = p + 1) begin assign fft_bin_th1[p] = (array_x[p] > threshold_1)? 1'b1 : 1'b0; end endgenerate the array fft_bin_th1 contain 4 ones @ random locations after statement. after doing operations 2 values of indexes , lets 23 , 42 (they random). these 1s in fft_bin_th1 array. want assign these 2 indexes (23 , 42) value 0 , rest of array fft_bin_th1 should same. how can this? from can understand looking code always@(posedge clk) begin index_1 <= logic_to_get_index1; index_2 <= logic_to_get_index2; fft_bin_th1[index_1] <= 0; fft_bin_th1[index_2] <= 0; end `

where to put a php file in cpanel which would serve my form in html -

i'm using hostgator cpanel , domain. created website using html , in use contact form on submit goes php file , sends me email. it works on amazon webserver don't know put php files in hostgator cpanel. should install php config somewhere , put there? thanks in advance. here php code <?php require 'phpmailer/phpmailerautoload.php'; $name = $_post['inputusername']; $email_address = $_post['inputemail']; $message = $_post['inputcontent']; $mail = new phpmailer; //$mail->smtpdebug = 2; $mail->issmtp(); // set mailer use smtp $mail->host = 'smtp.gmail.com'; // specify main , backup smtp servers $mail->smtpauth = true; // enable smtp authentication $mail->username = 'krishnakumar4315@gmail.com'; // smtp username $mail->password = 'password'; // smtp password $mail->smtpsecure = ...

ios - Assigning different emitters to different nodes that are randomized -

Image
i have basic emitter nodes working in first app. have created constants file references nodes throughout game, , converts them strings. great mini data base. basic whack mole game, except have 12 different characters. gamescene code this called in didmovetoview method: func star(pos: cgpoint) { let emitternode = skemitternode(filenamed: "star.sks") emitternode!.particleposition = pos self.addchild(emitternode!) self.runaction(skaction.waitforduration(2), completion: {emitternode!.removefromparent() }) } this called in touchesdidbegin method: if node.name == "charenemy" { let whackslot = node.parent!.parent as! whackslot if !whackslot.visible { continue } if whackslot.ishit { continue } star(touchlocation) whackslot.hit() ++score } i created own custom class whackslot handle charenemy node , charfriend : let name = barray[int((randomfloat(min: 0.0, max: float(b...

php - $_POST on a While loop? -

my question is: can post using form , inside while loop? have supposed give me check box , titles of songs next it, want able select few check boxes , post them "process.php" code made not posting process.php. if click submit button without checking boxes defaults last result # in database, if check or few boxes says "undifined off-set # 9" last result in database. if make form inside while loop ton of submit buttons per result. not sure im doing wrong! please me!!! this need happen ⎕ song name ⎕ song name 2 submit if click submit on process.php should able use "song_name" please select songs: <br> <form method="post" action="process.php"> <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "song_selection"; // create connection $conn = new mysql...

python - Extract timestamp from large string -

i have large string this: send ok http/1.1 200 ok access-control-allow- l-allow-methods: get,post,delete access-control-allow-headers: x-requested-with, phant-private-key content-type: text/plain x-rate-limit-limit: 300 x-rate-limit-remaining: 297 x-rate-limit-reset: 1452931335.777 date: sat, 16 jan 2016 07:50:17 gmt set-cookie: serverid=; expires=thu, 01-jan-197 0 00:00:01 gmt; path=/ cache-control: private transfer-encoding: chunked it contains strings sat, 16 jan 2016 07:50:17 gmt string may of time. want string out of whole. know basic question how can in python. not string contain substrings date: . use import re datepattern = re.compile("\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} \w{3}") matcher = datepattern.search(string_to_match_against) print(matcher.group(0)) with example string_to_match_against = """ send ok http/1.1 200 ok access-control-allow- l-allow-methods: get,post,delete access-control-allow-headers: x-requested-w...

ios - Unit test for AFNetworking Post request -

i trying write unit test project use afnetworking in.i use following operation request: - (void)testregisterrequest{ afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; [manager post:url parameters:parameters success:^(afhttprequestoperation *operation, id responseobject) { xctassert(result,"register failed!"); } failure:^(afhttprequestoperation *operation, nserror *error) { //failure } as asynchronous never test xctassert line. searched lot couldn't manage find tutorial or example these test cases.please me tutorial link or hint. in advance there couple of things here. you can use expectations async tests: asynchronous testing xcode 6 you can use ohhttpstubs avoid unneeded network traffic , server load: usage examples

angularjs - router.post returns error "undefined is not a function" .Using mongo and express.js -

Image
i'm trying buld app using files link .i found posting code breaks.has express js changed or syntax mistake ? the router.post breaks once reaches maid.registermaid(new maid({... .i'm able make work using .save() explain why callback beaking ? putting code below.. sorry, i'm beginner in m.e.a.n api.js var express = require('express'), router = express.router(), passport = require('passport'); user = require('../models/user.js'); maid = require('../models/maid.js'); router.post('/addmaid', function(req, res) { console.log(req.body, req.body.firstname,req.body.lastname); maid.registermaid(new maid({ firstname: req.body.firstname }), ({lastname: req.body.lastname}), function(err, account) { if (err) { return res.status(500).json({err : err}) } return res.status(200).json({status: 'registration successful!'}); }); }); services.js angular.module('myapp').factory('authservice',...

javascript - SyntaxError: Unexpected token -

i'm using parse.com build companion website 2 apps. i'm using express framework web framework. in code try run 3 parse queries in parallel , put them display information. since i'm quite new @ javascript, promises , express have problem syntax. can spot i'm sure stupid mistake. app.get('/', function (req, res) { var querydining = new parse.query("location").equalto("locationtype", 0).adddescending("updatedat").limit(10).find(); var querymosque = new parse.query("location").equalto("locationtype", 1).adddescending("updatedat").limit(10).find(); var queryshops = new parse.query("location").equalto("locationtype", 2).adddescending("updatedat").limit(10).find(); // wait them complete using parse.promise.when() // result order match order passed when() parse.promise.when(querydining, querymosque, queryshops).then(function (restaurants, mosques, sh...

php - How to load select option from database in zf2 -

i have been following zf2 guide blog have created controller, factory, form, mapper, model, service, view etc in form have select element $this->add(array( 'type' => 'select', 'name' => 'roleid', 'attributes' => array( 'id' => 'roleid', 'options' => array( '1' => 'admin', '2' => 'manager', ), ), 'options' => array( 'label' => 'role', ), )); now in form want load option role database. tried loading option creating simple function, can accessed in element below, not able fetch result. have created controller, factory, form, mapper, model, service , view, can crud operation on role. $this->add(array( 'type' => 'select', 'name' => 'roleid', 'attributes' => array( 'id' => 'roleid',...

How to parse Local JSON (from Asset folder) for building Bible App in android -

i planning build app bible., decided use local json parse data. please share ideas data local json. you can use gson ease process of converting json object java object , can access individual attributes of java class using getters , setters. here small example: gson gson = new gson(); try { bufferedreader br = new bufferedreader( new filereader("c:\\file.json")); //convert json string object dataobject obj = gson.fromjson(br, dataobject.class); system.out.println(obj); } catch (ioexception e) { e.printstacktrace(); }

UDP broadcast and automatic server discovery in python, TCP socket unavailable -

i'm developing reverse shell application in python, , right i'm trying implement autodiscovery feature. should work follows: the server broadcasts ip/port listens connections on, , waits client. if no client tries connect in few seconds, broadcasts again (and repeat till connection). the client tries receive broadcast of server, , connects advertised ip/port. the broadcast works fine, client receives ip/port , connects, after using connected pair of ports (server side): socket.error: [errno 35] resource temporarily unavailable server side test code: sckt = socket.socket(socket.af_inet, socket.sock_stream) sckt.setsockopt(socket.sol_socket, socket.so_reuseaddr, 1) sckt.settimeout(2) sckt.bind(('', 9999)) sckt.listen(5) broadcastsocket = socket.socket(socket.af_inet, socket.sock_dgram) broadcastsocket.setsockopt(socket.sol_socket, socket.so_broadcast, 1) broadcastsocket.setsockopt(socket.sol_socket, socket.so_reuseaddr, 1) while true: broadcastso...

Integrating C++ OpenGL project with another C++ project -

i working project reads data file, performs calculations, , show results on standard output. later wanted give 3d graphical view results, made new opengl project shows data 3d object. now problem is, can not figure out way integrate these 2 independent projects, because main() in opengl project goes in non terminating glutmainloop() loop, , unable figure out put loop in main() of first project ! /**** proj1 ****/ int main() { while(esc key not pressed) { // read data file // processing // show results on standard output } } /**** proj2 ****/ int main() { glutinit(&argc, argv); init(); glutdisplayfunc(display); glutkeyboardfunc(keyboard); glutmousefunc(mouse); glutidlefunc(idle); glutmainloop(); } least mixing of codes between proj1 & proj2 requested. possible like: /**** proj1 ****/ #include <filesfromproj2> int main() { while(esc key not pressed) { // read data file ...

c++ - How to resolve this: invalid conversion from 'const char*' to 'const uint8_t* -

i installed sha library: https://github.com/cathedrow/cryptosuite . want implement hmac256 using arduino ide 1.6.7 installed on win. 10 , controller atmega328. i copied example given in webpage. still new , want test , try. wrote code in arduino ide. #include "sha256.h" void setup() { // put setup code here, run once: uint8_t *hash; //static const char hash[450]={}; //const char *hash; hash={}; sha256.inithmac("hash key",8); // key, , length of key in bytes sha256.print("this message hash"); hash = sha256.resulthmac(); //serial.print(hash,hex); } void loop() { // put main code here, run repeatedly: } i got error: invalid conversion 'const char*' 'const uint8_t* {aka const unsigned char*}' [-fpermissive] i not know why happens. example primitive taken library site. can help? edit: tried change line from: sha256.inithmac((const uint8_t*)"hash key",8); to: sha256.init...

html - IE wrapper div takes original full height of svg image when using max-width -

when use max-width property on svg image, svg's height reduced maintain aspect ratio. if it's wrapped in div, wrapper takes image's original full height. fiddle the problem present in ie, works fine in other browsers. solutions fix this? html <div class="wrapper"> <svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 174 174"><g fill="#715f6a"><path d="m113.72 95.354c-.477.516-1.11.808-1.85.95-.222.047-.443.02-.66.02-.97 0-1.87-.258-2.508-.943-.802.14-1.455.62-1.725 1.62h8.472c-.275-1-.928-1.507-1.73-1.646z"/><path d="m87.28 1.105c-47.535 0-86.07 38.536-86.07 86.072s38.535 86.07 86.07 86.07c47.537 0 86.072-38.534 86.072-86.07 0-47.536-38.535-86.072-86.07-86.072zm9.438 45.412a8.808 8.808 0 0 1 8.81 8.81c0 4.867-3.944 8.813-8.81 8.813-4.867 0-8.81-3.947-8.81-8.813a8.81 8.81 0 0 1 8.81-8.81zm-29.123-.003c4.867 0 8.813 3.944 8.813 8.81a8.814 8.814 0 0 1-8.813 8.813c-4.866 0-8.81-3.94...