Posts

Showing posts from January, 2012

pointers - how to create an array of char arrays in arduino -

i need handle data in matrix. want have this: {{"data11", "data12", "data13"}, {"data21", "data22", "data23"}, {"data31", "data32", "data33"}} i think " char* matrix[3][3]; " trick, haven't gotten expected result. i need following actions: initialize matrix empty (with empty strings or "" ). put data in matrix dynamically. thanks in advance. you should use character arrays, not pointers string modify contents later. #include <string.h> // initialized "" because global variable // please allocate enough memory each elements // (adjust last number [10]if needed) char matrix[3][3][10]; void setup() { // put data in matrix strcpy(matrix[0][0], "data11"); strcpy(matrix[0][1], "data12"); strcpy(matrix[0][2], "data13"); strcpy(matrix[1][0], "data21"); strcpy(matrix[1][1], "data22...

algorithm - Hash Table with Chaining (Table Doubling) -

how fix hash table chaining when items hash same slot (one giant linkedlist)? does hash table chaining uses table doubling? if when time double size of table. expanding on answer nikic's comments: for first question, unfortunately real possibility when implementing chained hash table. assuming have hash function - or, better yet, choosing hash function involves element of randomness - extremely unlikely. unfortunately, bad people use take down web servers. not long ago, attack called "hash dos" developed whereby craft bunch of specialized requests web server cause stored in same slot in chained hash table, led huge performance drops , took websites offline. news, though, many programming language implementations have been updated hash tables aren't vulnerable things this. for second question, answer "it depends." implementations of chained hash tables rehash , grow when load factor gets high (usually, load factors between 1 , 2 common). i...

ssl - Reading information from nmap poodle vulnerability result. Bash script -

i need make bash script give me list of true or false depending on address scanned. right have simple script #!/bin/bash input="/root/file1" input2="/root/file2" paste -d, file{1,2}.txt | while ifs=, read x y; nmap -sv --version-light --script ssl-poodle -p $y $x if something(detects vulnerable) echo "true">>file3.txt else (not vulnerable) echo "false">>fie3.txt done the information nmap returns when vulerable is nmap scan report ip host (0.044s latency). port state service version port/tcp open ssl/http microsoft iis | ssl-poodle: | vulnerable: | ssl poodle information leak | state: vulnerable is there way detect word vulnerable, or best way it? #!/bin/bash input="/root/file1" input2="/root/file2" paste -d, file{1,2}.txt | while ifs=, read x y; nmap_output="$(nmap -sv --version-light --script ssl-poodle -p $y $x)" if [ -n "$(echo "$nmap_output...

Web Audio API Stream: why isn't dataArray changing? -

edit 2: solved. see answer below. edit 1: i changed code little, added gain node, moved function. found if use microphone, work. still doesn't work usb audio input. idea? current code: window.audiocontext = window.audiocontext || window.webkitaudiocontext; window.onload = function(){ var audiocontext = new audiocontext(); var analyser = audiocontext.createanalyser(); var gainnode = audiocontext.creategain(); navigator.mediadevices.getusermedia({ audio:true, video:false }).then(function(stream){ //mediastream var source = audiocontext.createmediastreamsource(stream); source.connect(analyser); analyser.connect(gainnode); gainnode.connect(audiocontext.destination); listen(); }); function listen(){ analyser.fftsize = 256; var bufferlength = analyser.frequencybincount; var dataarray = new uint8array(bufferlength); var index = 0; function write(){ requestanimationframe(listen); analyser.getbytetimedomainda...

ios - UITableView and new methods for tvOS -

i creating test tvos app. have image (outside tableview) , when "focused" not selected, image change... know apple has added couple methods focus. tell me methods use change image when in "focus"? , how use it? use method: - (bool)tableview:(uitableview *)tableview canfocusrowatindexpath:(nsindexpath *)indexpath or use: - (void)tableview:(uitableview *)tableview didupdatefocusincontext:(uitableviewfocusupdatecontext *)context withanimationcoordinator:(uifocusanimationcoordinator *)coordinator please let me know! thank you! if want change image when uitableviewcell item focus, should use second method. - (void)tableview:(uitableview *)tableview didupdatefocusincontext:(uitableviewfocusupdatecontext *)context withanimationcoordinator:(uifocusanimationcoordinator *)coordinator { //you can focused indexpath below nsindexpath *nextindexpath = [context nextfocusedindexpath]; // image data source, assume have images array uiimage *...

java - Maven BasicDataSource Errors on Tomcat 8 -

we started converting large webapp maven, , seemed working great, no matter do, maven doesn't recognize tomcat-dbcp.jar file on tomcat server. in dependencies, have set following: <dependency> <groupid>org.apache.tomcat</groupid> <artifactid>tomcat-dbcp</artifactid> <version>8.0.26</version> <scope>provided</scope> </dependency> but following stacktrace: error: javax.servlet.jsp.jspexception: java.lang.abstractmethoderror: oracle.jdbc.driver.t4cconnection.isvalid(i)z uri: /as/checkreport error message: oracle.jdbc.driver.t4cconnection.isvalid(i)z status code: 500 org.apache.tomcat.dbcp.dbcp2.delegatingconnection.isvalid(delegatingconnection.java:913) org.apache.tomcat.dbcp.dbcp2.poolableconnection.validate(poolableconnection.java:226) org.apache.tomcat.dbcp.dbcp2.poolableconnectionfactory.validateconnection(poolableconnectionfactory.java:302) org.apache.tomcat.dbcp.dbcp2.basicdatasour...

python - sklearn: How to reset a Regressor or classifier object in sknn -

i have defined regressor follows: nn1 = regressor( layers=[ layer("rectifier", units=150), layer("rectifier", units=100), layer("linear")], regularize="l2", # dropout_rate=0.25, learning_rate=0.01, valid_size=0.1, learning_rule="adagrad", verbose=false, weight_decay=0.00030, n_stable=10, f_stable=0.00010, n_iter=200) i using regressor in k-fold cross-validation. in order cross-validation work , not learn previous folds, it's necessary regressor reset after each fold. how can reset regressor object? sklearn.base.clone should achieve you're looking achieve

Activate/Desactivate notifications in an app having different notifications type -

i looking @ different forums , tutorials did not find cover want do. @ moment notifications working fine trying give options user receive them or not. my server sending 3 kind of different notification, messages: you have new message a new user connected a user close you i have option menu giving user option choose notifications wants receive. can select combination wants. the problem have not know how allow app display message 1 , 2, not 3, if user choice. far solution have either showing 1, 2 , 3) or showing nothing. have nothing in middle. did came across , how did solved it? ps: apple push notifications thanks find solution, combine silent notification local notification 1) receive silent notification 2) treatment base on notification 3) send local notification (or not) create desired effect

ios - CLError.DeferredFailed Error (kCLErrorDomain Code=11) Deferred GPS Updates Failing -

i have app periodic location updates map users path. i using deferred updates. if (cllocationmanager.deferredlocationupdatesavailable() == true && _isdeferingupdates == false) { print("doing refresh") _isdeferingupdates = true _locationmanager.allowdeferredlocationupdatesuntiltraveled(c_gps.activity_update_distance, timeout: c_gps.activity_update_time) } else { print("could not refresh") // iphone 4s not have deferring must keep on _locationmanager.startupdatinglocation() } when app open "doing refresh" call every second. my setup: have 2 keys on plist nslocationwheninuseusagedescription && nslocationalwaysusagedescription have background modes turned on, remote notifcations , location updates. have maps setup use bike , pedestrian. have permissions on phone set yes. do know other reason why deferred update failing w...

nlp - How to determine if a sentence is a statement using OpenNLP or any other library? -

i wondering if it's possible determine if sentence question or statement using apache opennlp or other library? if so, i'm looking pointers on how achieve this.

java - How to use a method with a char input and a boolean output? -

thank answers ! 1 more question: how print out boolean value? system.out.println(goodbase) not seem work public class dna { public static void main(string[] args){ abase('a'); } public static boolean abase (char c) { char [] chararray = { 'a', 'g', 'c', 't' }; boolean goodbase; if (c == 'a' || c == 'g' || c == 'c' || c == 't') { return true; } else { return false; } } } thanks ! the code working me if use in right environment. have attached complete functioning sample below: public class main { // create test method public static boolean test(char c) { if (c == 'a' || c == 'g' || c == 'c' || c == 't') { return true; } else { return false; } } public static ...

javascript - Not so simple scrolling -

i don't know how describe have, i'm showing code <div class="room-pos"> <div class="right-content nano-content"> <div id="right-fix"> </div> </div> <div class="left-content "> </div> </div> .room-pos{ position: relative; } .fixed-c{ position:fixed; } .right-content{ background: #fff none repeat scroll 0% 0%; width: 45%; position: absolute; right: 0; top:0; bottom:0; z-index:5; border-left: 1px solid #f2f2f2; } .left-content{ width: 55%; float: left; } $(window).scroll(function() { if ($(this).scrolltop() >= $('#right-fix').height() - $(window).height() + 30) { $('#right-fix').addclass( "fixed-c"); $("#right-fix").css("top", $(window).height() - $('#right-fix').height() ); } else if($(this).scrolltop() < $('#right-fix').hei...

Wrong result of sympy integration -

this expression returns zero, shouldn`t. p = x^6-14x^4+49x^2-36 integrate(1/p, (x, 1/3, 1/2)) used expand on expression, without result. doing wrong or bug? this works: from sympy import * x = symbols('x') p = x**6-14*x**4+49*x**2-36 = integrate(1/expand(p), (x, s.one/3, s.one/2)) i result: in [5]: out[5]: -3*log(3)/80 - log(7)/48 - log(2)/48 - log(8)/240 + log(10)/240 + log(4)/48 + 3*log(5)/80 in [6]: i.n() out[6]: -0.00601350282195297 in alternative, run command isympy -i , run sympy prompt converts python integers sympy integers before input gets evaluated sympy parser. python integer division different between python 2 , python 3, first returns , integer, second returns floating point number. both versions different sympy integer division, returns fractions. use sympy division, need make sure @ least 1 among dividend , divisor sympy objects.

javascript - jquery form validation to prevent submission -

i have been trying use jquery validate form have been running issues.the link below please take look. jiddle link <!doctype html> <html lang="en-ca" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="mystyle3.css"> <meta charset='utf-8'> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="//code.jquery.com/jquery-1.10.1.js"></script> <script type="text/javascript" src="/includes/vendor/js/additional-methods.js"></script> <script src='https://www.google.com/recaptcha/api.js'></script> <link rel="stylesheet" href="//code.jquery.com/ui/1....

javascript - MUP Deploy failures on a project that works on another server -

i'm trying deploy meteor server configured pretty same 1 working fine. i've been going around , around of masterjames on git issues tracker mup not getting anywhere here am. my mup.json is { 19 // server authentication info 18 17 "servers": [ 16 { 15 "host": "10.1.23.2", 14 "username": "root", 13 // "password": "" 12 // or pem file (ssh based authentication) 11 "pem": "/var/root/.ssh/id_dsa" 10 } 9 ], 8 7 // install mongodb in server, not destroy local mongodb on future setup 6 "setupmongo": false, 5 4 // warning: node.js required! skip if have node.js installed on server. 3 "setupnode": true, 2 1 // warning: if nodeversion omitted setup 0.10.36 default. not use v, version number. 0 "nodeversion": "0.10.36", 1 2 // install phantomjs in server 3 ...

node.js - Node .js server with nginx and basic auth -

Image
i'm trying run node.js server behind nginx, basic auth. here minimal config: server { auth_basic "closed website"; auth_basic_user_file /etc/nginx/.htpasswd; location / { proxy_pass http://localhost:3000/; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; } } my first problem when go x.x.x.x, basic auth form re-appears every time (indefinitely) hit enter (whatever set login , password - ones). the server returns plain text res.end("hello world\n"); , can see second before basic auth form appears again. second question, possible block x.x.x.x:3000 (if not, there no point in setting auth on :80). thanks! btw it's first time setup nginx (and spent quite lot of time on already). note: works without basic auth (or auth_basic off; in location). currently website looks that: :) ok bad, got it! apparently passwords in .htpasswd ...

annotations - Failed to inject EJB using OpenEJB in Junit -

i decided use tomee openejb in junit test because ibm's embeddedejbcontainer limited. example, doesn't support mdb. so, added number of dependencies maven pom.xml , got necessary openejb jars test code. in beforeclass method created embeddedcontainer: testejbcontainer = ejbcontainer.createejbcontainer(); and successful. so, thought @ejb annotation injection work. didn't. went on interrogate jndi contexts used openejb. found ejb reference bounded in following sub-contexts like: "java:global/mymodule/myejb!com.company.dept.myejb" , "java:global/mymodule/myejb" so, there. however, @ejb annotation injection failed. so, went on search tomcat annotation implementation ejb annotation method. wasn't able find that. wondering may wrong here. few things can think of: the jar containing @ejb annotation openejb not called. is, other jar implementing javax.ejb.ejb intercepted tomcat's call. the subcontext name wrong. i wanted bind m...

How to model a long race track in netlogo world -

how can create race track resolution 60 units wide , 4000 units long (for 20 agents)? note: during simulation, focus/zoom may agents located along track. racetrack shape example: http://www.offtrackbetting.com/images/racetracks/op/oaklawn_park_tl.gif any useful link or example appreciated! thanks

delphi - How make Form2 never be resized for down? -

i have code puts 2 forms side side , works fine, can see when i'm resizing form1, form2 resized, resized down. so, how make form2 no resize down (since form1 greater form2) when form1 resized? following code used put 2 forms side side: unit unit1; interface uses winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics, vcl.controls, vcl.forms, vcl.dialogs, vcl.stdctrls; type tform1 = class(tform) button1: tbutton; procedure button1click(sender: tobject); procedure formclose(sender: tobject; var action: tcloseaction); // close on close procedure formresize(sender: tobject); // maximized, minimized etc private { private declarations } public { public declarations } procedure wmmoveform(var amessage: twmmove); message wm_move; // lip form2 main on form size changed procedure wmsizemove(var amessage: twmsize); message wm_sizing; // lip form2 main on form move end; var form1: tform1;...

excel - User-Defined Object In Array VBA -

as subject line states, trying store objects of class wrote array. vba giving me frustrating error: 'object variable or block variable not set' i'm pretty sure defining object correctly, , local variables show object of defined type , of it's fields filled in, can't figure out issue is. dim type1(2 250) myclass dim type2(2 250) myclass dim type3(2 250) myclass dim temp_obj myclass dim foo string = 2 250 set temp_obj = new myclass temp_obj .field1 = worksheets("sheet1").rows(i).columns(2).value .field2 = worksheets("sheet1").rows(i).columns(3).value .field3 = worksheets("sheet1").rows(i).columns(4).value .field4 = worksheets("sheet1").rows(i).columns(5).value end foo = worksheets("sheet1").rows(i).columns(1).value if foo = "type1" type1(i) = temp_obj elseif foo = "type2" type2(i) = temp_obj elseif foo = "ty...

java - selenium very similar xpaths? -

i have 2 buttons on page have similar xpaths - the button im trying click - /html/body/div[@id='wrapper']/div[@id='content']/div[@id='contentarea']/div[@id='votecontent']/div[@id='votetext']/div[@id='voteboxes']/div[@id='votenow'][2]/form/input[2] and other button im trying ignore - /html/body/div[@id='wrapper']/div[@id='content']/div[@id='contentarea']/div[@id='votecontent']/div[@id='votetext']/div[@id='voteboxes']/div[@id='votenow'][1]/form/input[2] the difference between 2 the [@id='votenow'][1] and [@id='votenow'][2] but can't figure out how interact 1 has votenow[2], whichever way go it, seems interact first 1 because that's first 1 finds this java using firefox driver, suggestions great :) just find them both , desired 1 index: list<webelement> buttons = driver.findelements(by.xpath("your xpath...

go - How to Decode map golang -

i run code , map that: map[from:0 key:<nil> price:desc title:stack] want value from , price , title please me once have map constructed, can access value of map providing key. syntax is: value := mymap[mykey] the key's type can type can evaluated comparison operator ( >= , == , <= , etc...). example looks using strings keys. here's example: m := map[string]interface{}{ "from": 0, "key": nil, "price": "desc", "title": "task", } // value of price price := m["price"] fmt.println(price) // title title := m["title"] fmt.println(title) // loop through of map's key-value pairs key, value := range m { fmt.println(key, ":", value) } example in go playground

php - Sorting dates with months or days on 0 -

i have sort dates on php, in of them can have '0' on month or day, example: 1951-11-00 1951-12-14 problem dates don't sorted other dates have year, day , month values. first tried using array_multisort: foreach ($objects $key => $part) { $sort[$key] = strtotime($part['object']['date']); } array_multisort($sort, sort_desc, $objects ); it sort ok, first sorts values have 00 on month or day, , sort normal dates, example: 1937-05-00 1937-04-00 1935-11-00 1951-12-16 1951-12-14 as see, order not ok, because dates 1951 should go first, sort algorithm classifying dates in 2 groups, ones have 00, , ones have full numbers. then tried uasort, i'm not getting results. how can sort dates correctly? list put, need show on order (regardless of having month on 00): 1951-12-16 1951-12-14 1937-05-00 1937-04-00 1935-11-00 just sort them strings. in comparable format when compared strings. $dates = ...

Java binary literal usage -

all examples on binary literal like: int a=0b1011 question is, can translate existing variables form? example, from int b=10000011; want int c=0b10000011 . you use integer.parseint(string, int) , like, int b = 10000011; int c = integer.parseint(string.valueof(b), 2); int d = 0b10000011; system.out.println(c == d); and true .

Find the max element and its index in a list - Prolog -

i fresh in prolog. , trying write predicate finds max value , index of list of integers. i.e max_list([2,3,4], max, index) yield max=4 , index=2 thank reply~ apologize! first time ask questions in stackoverflow. write predicate find maximum or minimum of list, don't know how exact position value in list. trying comprehend answers. using clpfd ... :- use_module(library(clpfd)). ..., meta-predicate maplist/2 , , nth0/3 define: zs_maximum_at(zs,max,pos) :- maplist(#>=(max),zs), nth0(pos,zs,max). here's query op gave: ?- zs_maximum_at([2,3,4],m,i). = 2, m = 4. ok! ... how most general query? ?- zs_maximum_at(zs,m,i). zs = [m], = 0, m in inf..sup ; zs = [ m,_b], = 0, m #>= _b ; zs = [_a, m], = 1, m #>= _a ; zs = [ m,_b,_c], = 0, m #>= _b, m #>= _c ; zs = [_a, m,_c], = 1, m #>= _a, m #>= _c ; zs = [_a,_b, m], = 2, m #>= _a, m #>= _b ; zs = [ m,_b,_c,_d], = 0, m #>= _b, m #>= _c, m #>= _d ; zs = [_a, m,...

reactjs - Grasping the theory behind Flux in React -

i've been applying flux-like architecture react app, , wondering if app state meant kept in store(s) rather components. seems there scenarios might have components maintain own state. for instance, below self-aware formelement . couldn't imagine writing flux-like architecture, dispatched store action. how store possibly keep track of different form elements, , parent form? in short: acceptable have some components keep track of own state, while others use dispatch? formelement = react.createclass({ displayname: 'formelement', validations: { email: /^[a-za-z0-9-._+]+@[a-za-z0-9-]+[.a-za-z0-9-]*\.[a-za-z]{2,}$/, password: /.{6,}/ }, proptypes: { id: react.proptypes.string.isrequired, label: react.proptypes.string.isrequired, type: react.proptypes.string, required: react.proptypes.bool }, getdefaultprops() { return { type: 'text', required: false, disabled: false } }, getinitialstate()...

Is it possible to create a sub-menu in a windows batch file? -

i writing batch file output plain text file in format of scripting language application on phone uses automate screen touches. create sub-menu called when specific options in main menu chosen. here current version on batch file. problem having when try create sub-menu action yes not executed, returns main menu. here have far. :menu echo. echo ################################################### echo # select option begin building script # echo ################################################### echo. echo 1 - start echo 2 - search echo 3 - x_coordinates echo 4 - y_coordinates echo 5 - 1 echo 6 - 2 echo 7 - 3 echo 8 - 4 echo 9 - 5 echo 10 - 6 echo 11 - 7 echo 12 - 8 echo 13 - 9 echo 14 - 0 echo 15 - quit echo. set /p m=type 1-15 press enter: if %m%==1 goto start if %m%==2 goto search if %m%==3 goto x_coordinates if %m%==4 goto y_coordinates if %m%==5 goto 1 if %m%==6 goto 2 if %m%==7 goto 3 if %m%==8 goto 4 if %m%==9 goto 5 if %m%==10 goto 6 if %m%==11 goto 7 if %m%==12 goto 8 i...

android - intent to google maps from webview -

i have webview in android, , open html webpage in it. there several link google maps , want intent native apps. have set other link host file intent native apps. have tried several way other failed. idea? public boolean shouldoverrideurlloading(webview view, string url) { // when user clicks hyperlink, load in existing webview if(uri.parse(url).gethost().endswith("googledrive.com")) { return false; } intent intent = new intent(intent.action_view, uri.parse(url)); view.getcontext().startactivity(intent); return true; } androidmanifest.xml <intent-filter> <data android:host="maps.apple.com" android:pathpattern="/.*" android:scheme="http" > </data> <action android:name="android.intent.action.main" /> <category android:na...

Meteor Up Deploy is not working anymore post Meteor 1.2 update -

using command line mup deploy, meteor application no longer deploys digital ocean. error here: x invoking deployment process: failed -----------------------------------stderr----------------------------------- npm warn package.json meteor-dev-bundle@0.0.0 no description npm warn package.json meteor-dev-bundle@0.0.0 no repository field. npm warn package.json meteor-dev-bundle@0.0.0 no readme data % total % received % xferd average speed time time time current dload upload total spent left speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) failed connect localhost port 80: connection refused latest deployment failed! reverted previous version. -----------------------------------stdout----------------------------------- .1.0 node_modules/ansi-styles chalk@0.5.1 node_modules/chalk escape-string-regexp@1.0.3 node_modules/escape-string-regexp supports-color@0.2.0 node_modules/supports...

Non-blocking Timed event in Ruby like JavaScript setTimeout -

i need change property on class few minutes after it initialized. attempted use sleep inside function delayed execution of everything: active = true def deactivate sleep 120 puts 'deactivate' active = false end deactivate puts active what hoping happen true log out first 2 minutes later deactivate log. however, happens deactivate false log out after 2 minutes. in javascript like: var active = true; settimeout(function(){ console.log('deactivate'); active = false; },120000); console.log(active); looks overkill task, can use delayed_job run task @ future time asynchronously. def deactivate puts 'deactivate' active = false end active = true handle_asynchronously :deactivate, :run_at => proc.new { 2.minutes.from_now }

javascript - Getting all my events from api route events with ember-data -

currently i'm trying catch events in database 'events' route, , working, have doubts how works. please, observe names. so, have route, call events route: siteapp.eventsroute = ember.route.extend({ model: function(params) { this.store.findall('event'); } }); here, i'm using eventssssss, s. but model needs without s: siteapp.event = ds.model.extend( description : ds.attr() name : ds.attr() type : ds.attr() ) if try use s , call this.store.findall('events'); throw strange error: error while processing route: events assertion failed: must include 'id' undefined in object passed 'push' error: assertion failed: must include 'id' undefined in object passed 'push' why can't use events in all? framework amazing, documentation poor, , i'm not finding resources understand conventions... thanks. create adapter events model ember g adapter event the convention pl...

bash - How to know if a process is going to get "Permission denied" -

me@ubuntu:~$ cat /proc/10/syscall cat: /proc/10/syscall: permission denied i want know ahead of time if have permission access syscall . i tried this: file=/proc/$n/syscall if [ -r $file ]; cat /proc/$n/syscall else echo "can't read" fi but it's not working. any ideas? thanks.

Xcode build successfully but iOS Simulator didn't run -

Image
i've developed camera app swift language. build processing succeeded in xcode , ios simulator done. but app list in ios simulator didn't include app. , error occurred.what's wrong? two screenshots of project added below: like joel said, try changing scheme running. right next simulator selector, there scheme selector; select it, project instead of framework.

apache - php resume capability or download in chunks -

php $_server not return http_range key , without key how can perform "resume download" or download in chunks? if (isset($_server['http_range'])) { echo "find"; } else{ echo "not find"; } i can't $_server['http_range'] server ....... there no key http_range when print $_server =================================================== <?php // file request, throw error if nothing supplied // hide notices @ini_set('error_reporting', e_all & ~ e_notice); //- turn off compression on server @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 'off'); if(!isset($_request['file']) || empty($_request['file'])) { header("http/1.0 400 bad request"); exit; } // sanitize file request, keep name , extension // also, replaces file location preset 1 ('./myfiles/' in example) ...

c++ - OpenCV minimum upright bounding rect of a RotatedRect -

Image
i'm trying determin minimum bouding rect of rotated rectangle. tried couple of samples this rotatedrect reference or this tutorial ellipses , bounding boxes. nothing satisfactory results. on image bellow, yellow rectangle desired result. example data test: image: width: 1500 height: 843 rotatedrect: center: x: 783.490417 y: 433.673492 size: width: 810.946899 height: 841.796997 angle: 95.4092407 sample code: cv::rotatedrect r(cv::point2f(783.490417, 433.673492), cv::size2f(810.946899, 841.796997), 95.4092407); cv::mat img = mat::zeros(843, 1500, cv_8uc3); cv::rect rect = r.boundingrect(); cv::ellipse(img, r, cv::scalar(0, 0, 255)); // red point2f vertices[4]; r.points(vertices); (int = 0; < 4; i++) line(img, vertices[i], vertices[(i + 1) % 4], scalar(0, 255, 0)); // green rectangle(img, rect, scalar(255, 0, 0)); // blue cv::imshow("result", img); red - rotatedrect min bouding rect...

bash script to read & store xml value -

i have xml file retrieve filepath value , store variable use launch app. here's xml file: <?xml version="1.0"?> <resultset statement="select * dms.gamthr_exp " xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <row> <field name="id">1</field> <field name="filepath">/home/drs/videos/game.of.thrones/game.of.thrones.s01e01.mkv</field> </row> </resultset> i have pieced script not working: #!/bin/bash myvar=$(echo 'cat //row/field[@name="filepath"]/@value' | xmllint --shell /home/drs/dms/gamthr.xml | awk -f'[="]' '{print $(nf-1)}') vlc --fullscreen "$myvar" any getting work appreciated! to select text node of context node, use text() node test: //row/field[@name="filepath"]/text() use --xpath option of xmllint pass xpath: xmllint --xpath '//row/field[@name="filepath...

ruby - Yard and C extension -

i have c ruby extension document rdoc. there both c files , ruby files parsed rdoc. does yard can same , there "easy way", (i mean commonly used way) migrate rdoc yard? as @neil slater said, yard can parse rdoc style documentation 1 exception :call-seq tag rdoc . equivalent @overload yard . (see rdoc, darkfish, , :call-seq: tag ) for me used rake task in order generate rdoc documentation: require "rdoc/task" rdoc_files = filelist["readme.rdoc", "ext/clangc/clangc.c", "ext/clangc/constants.c", "ext/clangc/class_index.c", "ext/clangc/class_translationunit.c", "lib/clangc.rb"] rake::rdoctask.new |rd| rd.main = "readme.rdoc" rd.rdoc_dir = "doc" rd.rdoc_files.include(rdoc_files) end i have launch rake rdoc in order use yard instead, have create rake task this: require "yard" yard_files = filelist["ext/clangc/clangc.c", "ext/clangc...

javascript - How to pass dynamic items and properties to JS constructor function? -

i struggling correct syntax iterating through array pass properties (and number of items) external js constructor function. the syntax constructor is: `swal.withform({ formfields: [ { id: 'x', type:'y', name:'z', value:''}, {etc...} ] })` but let's number of formfields dynamic, , stored in array. how can iterate through inside constructor function? or there way "paste" externally created syntax function? hope question makes sense. do mean want populate formfields array dynamic data? if should it. var myfields = []; myfields.push({ id: 'x1', type:'y', name:'z', value:''}); myfields.push({ id: 'x2', type:'y', name:'z', value:''}); myfields.push({ id: 'x3', type:'y', name:'z', value:''}); swal.withform({ formfields: myfields }) you build array using loop or map function if have array need convert f...

terminal - Bash command to calculate average on each row and each column -

suppose have log file marks.log , content looks this: fname lname net algo jack miller 15 20 john compton 12 20 susan wilson 13 19 i want add new column contains average each person, , new row contains average each course. result has this: fname lname net algo avg jack miller 15 20 17.5 john compton 12 20 16 susan wilson 13 19 16 average 13.3 19.6 - if data in datafile.txt , syntax awk like: awk ' { # if first row if (nr==1) print $0, "avg"; else # print fields, average of fields 3 & 4 print $0,($3+$4)/2; # total field 3 , field 4 t3+=$3; t4+=$4 } # once done... end { # print final line printf "overall average %.1f %.1f -\n", # average of field 3 (nr number of records) t3/(nr-1), # average of field 4 (nr number of records) t4/(nr-1); }' datafile.txt that's long version comments. one-liner looks like: awk '{if (nr==1) p...

xs - Testing for LibreSSL in a Perl build script -

i released net::nscang::client while ago , getting lot of test failures on openbsd. reason nscang protocol uses openssl in preshared-key mode (rfc4279), folks @ libressl (default on openbsd now) have ripped out. however, seem have been hell-bent on doing intransparent way: include files have functions defined, shared library missing corresponding symbols, compilation works fine tests fail. there compatibility package on openbsd called eopenssl, , testing first in makefile.pl (using extutils::pkgconfig ) can make work if compatibility library installed. if isn't, things still fail. i check cpp symbol openssl_no_psk, includes come libressl, fails if linking eopenssl work fine. idea have left try , have test program run part of compilation phase autoconf it. possible extutils::makemaker (or else -- wouldn't mind switching build system if necessary)? it's easy write feature tests devel::checklib . following can used check presence of function your_func (in ...

Upgrading IIS 7 to 8 found exception "The input is not a valid Base-64 string" -

my application running on iis7 when upgraded iis 8, getting exception the input not valid base-64 string as contains non-base 64 character, more 2 padding characters, or illegal character among padding characters. ??

c - Stringify a variable that can be a sequence of characters or a string value -

i have following macros: #define stringify(x) #x #define tostring(x) stringify(x) and use them converting sequence of characters srting. example, if write: puts(tostring(hi)) then hi printed screen (pay attention hi isn't variable, it's sequence of characters). now want modify macros support case x string value or sequence of characters in example above. calrify, if write: puts(tostring(hi)) or if write: puts(tostring("hi")) i same results. possible modifing macros?

php - Remove extension and force trailing slash to non trailing slash at end -

hi have website in using rules make urls seo friendly. here code : options +followsymlinks options -multiviews rewriteengine on rewritecond %{http_user_agent} libwww-perl.* rewriterule .* ? [f,l] rewriterule ^([a-za-z0-9_-\s]+)/([a-za-z0-9_-\s]+)/([0-9]+)/([a-za-z0-9_-\s]+)$ /page1.php?var1=$1&var2=$2&var3=$3&var4=$4 [l,qsa] rewriterule ^([a-za-z0-9_-\s]+)/([a-za-z0-9_-\s]+)/([a-za-z0-9_-\s]+)$ /page2.php?var1=$1&var2=$2&var3=$3 [l] rewriterule ^([a-za-z0-9_-\s]+)/([a-za-z0-9_-\s]+)$ /page2.php?var1=$1&var2=$2 [l,qsa] rewriterule ^([a-za-z0-9_-\s]+)$ /page2.php?var1=$1 [l,qsa] # remove trailing slash rewritecond %{request_filename} !-d rewritecond %{the_request} \s(.+?)/+[?\s] rewriterule ^(.+?)/$ /$1 [r=301,l] rewritecond %{script_filename} !-d rewriterule ^([^\.]+)$ $1.php [nc,l] errordocument 404 /404.php it working fine in cases in cases showing errors. errors getting: 1) suppose have page3.php when go www.example.com/page3.php sho...