Posts

Showing posts from March, 2011

Java Socket Server with JavaScript Client -

i put java socket server , client can send messages each other, want use javascript client, but... here happens when i'm hosting java server , load javascript client. javascript: var connection = new websocket('ws://127.0.0.1:9005'); connection.onopen = function () { connection.send('ping'); }; this prints in chrome console: websocket connection 'ws://127.0.0.1:9005/' failed: error during websocket handshake: invalid status line websocket error [object event] what i'm trying send "ping" java server, instead sends stuff disconnects... this prints in java server console: bread server running... new connection from: 127.0.0.1:51948 127.0.0.1:51948: / http/1.1 127.0.0.1:51948: host: 127.0.0.1:9005 127.0.0.1:51948: connection: upgrade 127.0.0.1:51948: pragma: no-cache 127.0.0.1:51948: cache-control: no-cache 127.0.0.1:51948: upgrade: websocket 127.0.0.1:51948: origin: http://markstuff.net 127.0.0.1

c# - How do I compare two hashes using SHA256Managed? -

i can hash user-entered password, i'm unable find out how compare stored hash , new hash user-entered password. this hashing code: public static string calculatehash(string cleartextpassword, string salt) { //convert salted password byte array byte[] saltedhashbytes = encoding.utf8.getbytes(cleartextpassword + salt); //use hash algorithm calulate hash hashalgorithm algorithm = new sha256managed(); byte[] hash = algorithm.computehash(saltedhashbytes); //return hash base64 encoded string compared , stored return convert.tobase64string(hash); } how compare 2 hashes validate password? first, should store salt hashed value. next, when user trying authenticate login , password can use next scenario: retrieve user data database login (for example, getuser(login) ). user class should contains login, hashed password , salt. if there no user login, fail authentication. else execute calculatehash() password , salt user class retrieved

javaScript closures. Undefined value as input stops script. Sometimes -

playing javascript closures end question cannot reach explain. (function() { console.log("inside closure"); //does not work }(foo)); it not work because foo undefined. referenceerror but if prior set var foo = undefined; works (tested on chrome , ff). it not same undefined set undefined? example in jsfiddle in javascript, 'undefined' 1 of primitive data types. represents type of object. var = undefined; var b; console.log((typeof(a))); console.log((typeof(b))); the output undefined both cases. if don't declare variable @ , try access it, error thrown following. tried access c not declared @ all. uncaught referenceerror: c not defined(…)

php - Parse a variable as if it were a string literal -

i have string in variable don't control. $foo = 'hey\nman'; (notice single quotes, it's literal \n not new line character) now have foo parsed if inside double quotes instead of single. convert literal escape characters corresponding ascii characters. of /r, /n, /b, /t, etc. i have access $foo can't change code assigns it's value it. option regex can ugly many number of different characters possible. how neatly php handles , wondering if can leverage it. you can use eval: $foo = 'hey\nman'; eval ('$b = "' . $foo . '";'); var_dump($b);

php - Wrong login opens a session too -

Image
i have written login php based in sqlite: <?php $db = new pdo('sqlite:data.db'); session_start(); if (isset($_session['timeout'])) { if ($_session['timeout'] + 4 < time()) { session_destroy(); } } else { $_session['pass'] = ""; $_session['timeout'] = time(); } if (isset($_post['pass'])) { $_session['pass'] = $_post['pass']; } if (!empty($_session['pass'])) { $result = $db->query("select password,user users"); foreach ($result $row) { if (password_verify($_session['pass'], $row['password'])) { echo "welcome! you're logged in " . $row['user'] . "! <a href='index.php?logout=true'>logout</a>"; if (isset($_get['logout'])) { unset($_session['pass']); header('location: index.php');

php - Increase static class variable in a constructor -

hi i've got following simple problem: i'd increase static class variable each time instance of object created. i've tried this: class task { static $tid = 0; function __construct() { $this->tid++; } } this returns following error message: notice: undefined property: task::$tid in ... on line ... how correctly? thx in advance :) edit: sorry, clear approach cant work, cause static keyword indicates property not bound instance, -> doesnt work. how correctly? $tid++ doesnt work. error: undefined variable. as per php manual : static properties cannot accessed through object using arrow operator ->. other php static variable, static properties may initialized using literal or constant before php 5.6; expressions not allowed. there way. must use self keyword: class task { static $tid = 0; function __construct() { self::$tid++; } } new task(); new task(); echo task::$tid; w

python - Select radio button with Selenium -

i'm trying select radio button 'government & military' on this page using selenium. the code below tries 2 different methods, neither working: from selenium import webdriver browser = webdriver.chrome('/users/joe/python/chromedriver') browser.find_element_by_xpath('//*[@id="propertygov"]').click() browser.find_elements_by_xpath('.//*[@id="propertygov"]')[0].click() edit: here full code. initial interaction date form keeping me selecting radio select: from selenium import webdriver browser = webdriver.chrome('/users/joe/python/chromedriver') browser.get("http://www.marriott.com/search/default.mi") browser.find_element_by_id('editsearch-location').send_keys('atlanta, ga') browser.find_element_by_xpath('//*[@id="hotel-fromdate"]').click() browser.find_element_by_xpath('//*[@id="hotel-fromdate_table"]/tbody/tr[2]/td[2]/div').click() browser.fi

c - fopen() seems not work when I create a daemon process -

here main source code: int main(int argc, char *argv[]) { [...] if (become_daemon(0) == -1) { exit(exit_failure); } while (main_loop == loop_continue) { [...] if (log_data(date_temp, data_processed) < 0) { [...] } else { [...] } sleep(measure_rate); } [...] } here functions definitions: int become_daemon(int flags) { int maxfd, fd; switch (fork()) { case -1: return -1; case 0: break; default: exit(exit_success); } if (setsid() == -1) return -1; switch (fork()) { case -1: return -1; case 0: break; default: exit(exit_success); } if (!(flags & bd_no_mask0)) umask(0); if (!(flags & bd_no_chdir)) chdir("/"); if (!(flags & bd_no_close_file)) { maxfd = sysconf(_sc_open_max); if (maxfd == -1)

Meteor packages for ranking/voting/scoring -

do know if there package ranking options other ideorecall:referral or barbatus:stars-rating ? i'd each post of site gets score depending on visitors rating. thanks, barbatus more adequate that. if don't want pre-made package, check out page 234 of "discover meteor" book, can purchase online @ website discovermeteor.com. voting chapter gives detailed outline of how "roll own" voting system stores votes , voter data well. easy implement , customize

c# - Passing a control as a generic parameter type and inheriting from it -

i have number of custom controls extend existing windows forms controls 1 or more interfaces designed myself. implementation of these interfaces virtually identical within each custom control, have repeating code such following: public class customtextbox : textbox, isomeinterface { // implementations of interface members ... } public class custombutton : button, isomeinterface { // implementations of interface members ... } ideally able similar following: public abstract class basecustomcontrol<c> : c, isomeinterface c : control { // implementations of interface members } public class customtextbox : basecustomcontrol<textbox> { // implementations of interface members ... } public class custombutton : basecustomcontrol<button> { // implementations of interface members ... } this way, identical implementations removed , consolidated single base class reduce repeating code. unfortunately, isn't possible; there

java - Trying to create a random number generator with user input for parameters -

whenever attempt this, weird numbers. if input 10, 1.012....... , if input 8 64359... import java.util.scanner; import java.util.random; class proyecto{ public static void main(string[]args){ scanner input = new scanner(system.in); random numb = new random(); int numbe; int number; numbe = input.nextint(); numbe = numb.nextint(); system.out.println(numb.nextint()); } } here rewrite class. import java.util.random; class proyecto{ public static void main(string[]args){ random numb = new random(); if(args.length>0){ system.out.println(numb.nextint(integer.parseint(args[0].tostring())); } } }

Same Referer URL opens for two different browser tabs with different URLs PHP -

flow: - user visits page www.mysite.com/somepage/1 - user clicks on log out button or times out , logs out *user log out detected redirect home page save referer url *redirect /login?ref=$_server['http_referer'] (actual code test if set) - user sees login page , relogs - user redirected refere url saved in $_get['ref'] the aboe flow works perfect first browser tab , if user has multiple tabs open $_get['ref'] gets set same url set first tab. example: example: tab 1 : /somepage/hello/world tab 2: /another/page/1 when user logs out tab 1 gets redirected to: /login?ref=http://site.com/somepage/hello/world (correct) if user refreshes page on tab 2 gets redirected to: /login?ref=http://site.com/somepage/hello/world not correct, should redirect to: /login?ref=http://site.com/another/page/1 don't redirect anywhere. handle re-login process on same url user on. keep url of every tab , browser window intact.

javascript - How to display d3 elements on a gridster box? -

i trying create area chart using d3 , using array: var jsonresobj = { initial_hours: [ 1800, 1700, 1030, 1130, 950, 1249, 1225, 1821, 1250, 1505, 38, 130, 1520, 1600, 1330, 1930, 1806, 1535 ] }; the code axis , chart here: var margin = {top: 20, right: 20, bottom: 40, left: 50}, width = 350 - margin.left - margin.right, height = 400 - margin.top - margin.bottom, days = jsonresobj.initial_hours.length; var x = d3.scale.linear() .domain([0, days]) .range([0, width]); var y = d3.scale.linear() .domain([0, d3.max(jsonresobj.initial_hours)]) .range([height, 0]); var xaxis = d3.svg.axis() .scale(x) .orient("bottom"); var yaxis = d3.svg.axis() .scale(y) .orient("left"); var area = d3.svg.area() .x(function(d) { return x(days); }) .y0(height) .y1(function(d) { return y(jsonresobj.initial_hours

VBA macro that copy files from multiple subfolders -

i have vba copying images 1 folder based on image names. can check macro in work in attached. code is: option explicit sub copyfiles() dim irow integer ' row counter. dim ssourcepath string dim sdestinationpath string dim sfiletype string dim bcontinue boolean bcontinue = true irow = 2 ' source , destination folder path. ssourcepath = "c:\users\nhatc_000\desktop\01010101\" sdestinationpath = "c:\users\nhatc_000\desktop\02020202\" sfiletype = ".jpg" ' try other file types ".pdf". ' loop through column "a" pick files. while bcontinue if len(range("a" & cstr(irow)).value) = 0 ' nothing if column blank. msgbox "images have been moved. thank you!" ' done. bcontinue = false else ' check if files exists. if len(dir(ssourcepath & range("a&qu

ruby on rails - How to get the highest value from a child association -

i have order model has_many items. app/models/order.rb class order < activerecord::base has_many :items before_save :set_status enum item_status: [:one, :two, :three] private def set_status self.items.each |i| self.item_status = i.item_status if i.item_staus > self.item_status end end end both models have same "item_status" enum , attribute. i think comparison not working because not comparing actual int value rather enum string value. how can fix this? you should use maximum perform query in database, using stored integer value rather activerecord -wrapped records you're performing comparisons agains symbols: def set_status self.item_status = self.items.maximum(:item_status) end

oracle - Regex to find 9 to 11 digit integer occuring anywhere closest to a keyword -

in simple term, looking if there string, has keyword ztfn00 , regex shall able return closest 9 11 digit number left or right side of string. i want in regexp_replace function of oracle. below of sample strings: the following error occurred in sap update_bp service part of combine: (error:653, r11:186:number 867278489 exists id type ztfn00) expected result: 867278489 the following error occurred in sap update_bp service part of combine (error:653, r11:186:number ztfn00 identification number 123456778 exist) expected result: 123456778 i not find way regular expressions, if want task without pl/sql, can following. it's little bit tricky, combining many calls regexp functions evaluate, each occurrence of digit string, distance keyword , pick nearest one. with test(string, keyword) ( select '(error:653, r11:186: 999999999 number 0000000000 exists id type ztfn00 hjhk 11111111111 kjh k222222222)', 'ztfn00' dual) select numberstring (

vb.net - Using Microsoft.VisualBasic.Logging.FileLogTraceListener with .NET v 1.0 -

i have application in .net 1.0 logs using system.diagnostics.textwritertracelistener below service.exe.config <?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <legacyunhandledexceptionpolicy enabled="1" /> </runtime> <system.diagnostics> <trace autoflush="false" indentsize="4"> <listeners> <add name="mylistener" type="system.diagnostics.textwritertracelistener" initializedata="service.log" /> </listeners> </trace> </system.diagnostics> </configuration> this configuration creating huge log file , not rolling file, after research found below configuration using microsoft.visualbasic.logging.filelogtracelistener rollover log file daily <?xml version="1.0" encoding="utf-8" ?

c++ - Getting clang-tidy to fix header files -

i'm in process of moving project compiling gcc clang, , have bunch of warnings gcc didn't generate ( -winconsistent-missing-override ). clang-tidy works fixing these errors in *.cpp files, doesn't touch hpp files because compile command wasn't found in database (as expect). i'm using ninja build project , ninja -t compdb cc cxx > .build/compile_commands.json generate compilation database. i've tried running: clang-tidy-3.6 -p .build/ \ $(find src/ -name *.cpp) \ $(find src/ -name *.hpp) \ --checks=misc-use-override --fix to fix errors. refuses touch header files complaining: skipping .../src/header/file.hpp. compile command not found. i got working specifying --header-filter=src/ option. interestingly fixes ended being applied several times causing output this: void f() override override override override override; i worked around running clang-tidy on each source file separately. note <build-path>

javascript - How to correctly iterate through getElementsByClassName -

i javascript beginner. i initing web page via window.onload , have find bunch of elements class name ( slide ) , redistribute them different nodes based on logic. have function distribute(element) takes element input , distribution. want (as outlined example here or here ): var slides = getelementsbyclassname("slide"); for(var = 0; < slides.length; i++) { distribute(slides[i]); } however not magic me, because getelementsbyclassname not return array, nodelist , is... ...this speculation... ...being changed inside function distribute (the dom tree being changed inside function, , cloning of nodes happen). for-each loop structure not either. the variable slides act's un-deterministicaly, through every iteration changes it's length , order of elements wildly. what correct way iterate through nodelist in case? thinking filling temporary array, not sure how that... edit: important fact forgot mention there might 1 slide inside another, chang

java - What is isInEditMode() and if(isInEditMode()) return; -

private void init() { if (isineditmode()) return; paint.setstyle(paint.style.fill); paint.setcolor(getresources().getcolor(r.color.control_highlight_color)); paint.setantialias(true); setwillnotdraw(true); setdrawingcacheenabled(true); setclickable(true); } i ran above code while trying understand how ripple effect created. 1) question isineditmode() . have taken @ developer site , explanation little confusing me. 2) 1 if(isineditmode()) return; code strikes me odd. thought if statements check follow format if(){return;}. however, way code above formatted makes me confuse , know why so. 3) plus, if return value nothing why not not specifies in first place? as have no answers #2 , #3, there is: if have single instruction in if , can omit curly braces. plus java doesn't work indentation braces , semi-colons. can put single instruction on same line if , won't make differences,

typescript - How do I fixed my selection of extensions in sublime text? -

Image
this question has answer here: set default syntax different filetype in sublime text 2 4 answers i development in typescript. used sublime text code. had downloaded plugin in sublime text , can hint or auto-complete me. when open typescript, sublime text default use built-in extension. the first typescript download. second 1 built-in in sublime text. expect can avoid lead second 1 sublime text , it's default use first one. how set sumbline text? you need change config file on sublime, i've not tried setting same issue i've configured theme using same use default. can refer link on sublime settings

perl - newlines when displayed in Windows -

open out, ">output.txt"; print out "hello\nworld"; when run above perl code in unix system , transfer output.txt windows , open in notepad shows as: helloworld what need newlines displaying in windows? text file line endings platform-specific. if you're creating file intended windows platform should use open out, '>:crlf', 'output.txt' or die $!; then can just print out "hello\nworld!\n"; as normal the :crlf perlio layer default perl executables built windows, don't need add code create files intended platform. portable software can check host system examining built-in variable $^o

how to do LDA in R -

my task apply lda on dataset of amazon reviews , 50 topics i have extracted review text in vector , trying apply lda i have created dtm matrix <- create_matrix(dat, language="english", removestopwords=true, stemwords=false, stripwhitespace=true, tolower=true) <<documenttermmatrix (documents: 100000, terms: 174632)>> non-/sparse entries: 4096244/17459103756 sparsity : 100% maximal term length: 218 weighting : term frequency (tf) but when try following error: lda <- lda(matrix, 30) error in lda(matrix, 30) : each row of input matrix needs contain @ least 1 non-zero entry searched solutions , used slam matrix1 <- rollup(matrix, 2, na.rm=true, fun = sum) still getting same error i new can me or suggest me reference study this.it helpful there no empty rows in original matrix , contains 1 column contain reviews i have been assigned kind of similar task , learning , doing , have developed , shar

caching - chrome cache persisting old site -

going live new site today ran strange issue on chrome: we changed dns point new server new site, , chrome seemed have cached old index.html file, none of srcs or includes.. rendered text old index.html generated 404s on css , imgs.. , displayed ugly mess. i hacked workaround: locating js file old index file looking injected new js file redirected call "index.html" instead of "/" , resolved it, ugly temporary flash of hideous mess cached index file. everything googled told me how flush cache, i'm not concerned how browser reads site, i'm concerned how others browsers read site. tried putting no-cache tag in no avail.. read later chrome ignores tag... anyone encounter before , have better solution?? update: in case else stumbles similar situation. looks old site had cache setting in web.config. nitin suggesting logs. examining network traffic in dev tools see cached retrieve, , more importantly cache control response header led me start exam

elasticsearch - Modifying values displayed in tooltip in Kibana Visualization -

problem statement:- in bar chart visualization, if have set y axis count. x-axis set @timestamp & split bars set top 5 terms of field. when hover mouse shows me 3 values in tooltip:- count, timestamp & top 5 field name. however wish display top 5 field name in tooltip while hovering & want remove x-axis value (@timestamp) & y-axis value (count).

c# - Fastest way to repeatedly download html contents of a page -

what fastest way of repeatedly downloading , scanning html contents of page twitter? need check if username available many times second, , faster better. i'm making 10 threads downloads , checks webclient , downloadstring, , it's giving me speed of 5 - 7 checks second. faster, there way this? making more threads not work, don't suggest it. thanks in advance. use twitter api or broader web page dumping try wget .

javascript - Creating a dynamic updating form, sourcing from MYSQL DB -

i'm trying create form has couple drop downs. first 1 populated 'customer name' drawn mysql database. once selected, drop down menu below populates available 'customer sites' associated 'customer name' database (over multiple rows in table). so i've been trying through php & js - know little js i'm cannibalizing script found online. i'll strip down code i'm calling mysql database , need dynamically populate js. far i'ved tried including trying push mysql info php array , call in js encounters problem of show 1 site, not associated company name. after days of looking online , trying macgyver together, i've given in , decided ask help. summarized version of mysql table 'customersites' sitecompany | sitename abc customer        | site1 123 customer          | site1 123 customer          | site2 abc customer        | site2 php $sql = "select sitename, sitecompany customersites order sitecompany&q

javascript - Plot multiple scales on a single axis -

Image
i'm trying plot data on webpage. have 4+ series common xaxis scaling on yaxis should unique each series. something below picture (you can see multiple scales on both y , y2 axis) i've been testing out jqplot supports y , y2 axis cannot see way have more 1 scale on each axis possible? if not there package can use can this? i have discovered jqplot supports more 2 yaxis each axis after first axis displayed on right hand side of plot i've found no simple way modify behaviour. below picture plot able create using 4 yaxis scales . something below javascript in plot statement it. axes: { xaxis: { show: true, renderer: $.jqplot.linearaxisrenderer, drawmajorgridlines: true, min: 0, max: 21, numberticks: 7, }, yaxis: {

wso2 - Dashboard on WSO2DAS -

i've created gadget on wso2das, graph of can seen independently. when i'm trying insert dashboard i'm unable see it. you can see dashboard in image inserted gadget not visible. setting , zoom in icons of visible. edit following file: (das_folder)/repository/deployment/server/jaggeryapps/portal/extensions/components/gadget/index.js replace resolvegadgeturl function code below: var resolvegadgeturl = function (uri) { uri = resolveuri(uri); if (uri.match(/^https?:\/\//i)) { return uri; } uri = uri.replace(/^(..\/)*/i, ''); if (window.location.protocol === 'https:') { return 'https://localhost:' + server.httpsport + context + '/' + uri; } return 'http://localhost:' + server.httpport + context + '/' + uri; };

ios - How to lock the orientation of a specific View Controller to Portrait mode? -

i hope well! i working on swift 2 app using xcode ios 9! , whole app rotate on both directions expect particular view controller want locked portrait when user rotates. tried hours , looked lot online , nothing worked. help? update: tried 2 methods below doesn't work ios 9 :( please help best, anas objective c : nsnumber *orientationvalue = [nsnumber numberwithint:uiinterfaceorientationportrait]; [[uidevice currentdevice] setvalue:orientationvalue forkey:@"orientation"]; swift : let orientationvalue = uiinterfaceorientation.portrait.rawvalue uidevice.currentdevice().setvalue(orientationvalue, forkey: "orientation")

html - JavaScript window.location function not working in localhost folder -

in htdocs directory of xampp have created list directory , place simple index.html file in it. the file contain <!doctype html> <html> <head> <script> function redirect() { alert("file:///d:/xampp/htdocs/"); window.location="file:///d:/xampp/htdocs/"; } </script> </head> <body onload="redirect();"> </body> </html> when navigate localhost/list/ showing blank page, , when have open directly browser it's working fine. is there restriction url "file:///d:/xampp/htdocs/". i want see file structure file:// url. you can try one: <script> function redirect() { alert("../xampp/htdocs/"); window.location="../xampp/htdocs/"; } </script>

java - I want to use spring annotation @webservlet and call this servlet from a jsp page action form. But i got the error. Here it is: -

here servlet page here servlet , mapping pattern and @webservlet("/logincontrol") public class sessioncontroller extends httpservlet { private static final long serialversionuid = 1l; public sessioncontroller() { super(); } @requestmapping(value="/logincontrol") protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { request.getsession().setattribute("name",request.getparameter("password")); response.getwriter().println("hello world!"); } } and here jsp page , gave action url same given in @webservlet getting error. [org.springframework.web.servlet.pagenotfound] (default task-4) no mapping found http request uri [/myspring/logincontrol] in dispatcherservlet name 'mvcconfiguration' <form name="loginform" action="logincontrol"> <table> <tr> <td>user:</td>

sharding - Can I run MongoDB config servers on replica and shard server? -

i need setup 3x3 mongodb 3.2 cluster (3 shards, 6 replicas) , keep number of servers small possible. can run config servers on replica , shard servers (i thought running 9 config server (1 config shard , 8 replica shard))? , idea or there problems when 1 or other server goes down? so questions mongodb shards , config servers on same server? , should run mongodb config , mongos on same servers? mention running config server on shards not idea still true replicas when using 9 config server? you can run config server & mongos on same server.i don't think 9 config server required according me 3 config server enough.

html5 - How to code the styles for the portrait only in the kindle fire device? -

how code styles portrait in kindle fire device? please advise. @media screen , (max-width: 800px) , (orientation : portrait) , (min-resolution: 1.5dppx),(-webkit-min-device-pixel-ratio: 1.5){ /* portrait: kindle fire hd 7 */ } refer this more device related media queries.

how to transfer file to azure blob storage in chunks without writing to file using python -

Image
i need transfer files google cloud storage azure blob storage. google gives code snippet download files byte variable so: # payload data req = client.objects().get_media( bucket=bucket_name, object=object_name, generation=generation) # optional # bytesio object may replaced io.base instance. fh = io.bytesio() downloader = mediaiobasedownload(fh, req, chunksize=1024*1024) done = false while not done: status, done = downloader.next_chunk() if status: print 'download %d%%.' % int(status.progress() * 100) print 'download complete!' print fh.getvalue() i able modify store file changing fh object type so: fh = open(object_name, 'wb') then can upload azure blob storage using blob_service.put_block_blob_from_path . i want avoid writing local file on machine doing transfer. i gather google's snippet loads data io.bytesio() object chunk @ time. reckon should use write blob storage chunk @ time. i exp

java - Validate DMN rule not overlap while adding new rule to DMN table -

i using camunda dmn in application(in angular, java, spring). i want validate if rule not overlapping while adding new rule dmn table. for example following dmn table, | x | y | o/p | | <9 | >50 | "abc" | | <20 | >100 | "xyz" | consider user dumb :d , , can create rules above. now if i/p's above dmn x = 10 , y = 99 satisfy both rules. if use unique hit policy, wont show me error @ time of add new rule rather show me while evaluation of dmn table. , dont want :( how avoid overlapping of rules while creating of rule self using either camunda dmn js api or camunda dmn java api ? this not possible require knowledge possible input combinations. infer overlapping value range of rules can quite hard.

c++ - How do I compile PortAudio on Windows in Visual Studio Community 2015? -

Image
if attempt build portaudio using .sln file included in latest download, these errors. what interesting have set preprocessor flag pa_use_asio 0, shown here. if delete asio directory (/src/hostapi/asio), no longer errors related asio files instead receive error related ksguid.lib . googling around says pa_wdmks_no_ksguid_lib preprocessor flag should stop ( source ) doesn't seem work. if it's ignoring preprocessor flags entirely. alternatively, if there better library works portaudio, i'd happy hear (i'm trying real time dsp). first problem, linker problem: you can change output filename on project -> properties -> linker -> general (1. point on linker, dont use english version of vs) change outputname in first column portaudio_x86 portaudio second problem: you need define full pathname of ksguid.lib file. file should here: c:\program files (x86)\microsoft sdks\windows\v7.1a\lib\x64\ksguid.lib . or x86 application in folde

ArrayList is not initializing properly in java -

i using arraylist in application. declared list<product> productlist = new arraylist<product>(); globally products not adding list because productlist showing null instead of empty array list. below code: map<string, list<product>> productlistmap = productsuggestbox.getvaluemap(); list<product> queriedproductlist = productlistmap.get("productlist"); long productid = long.valueof(productsuggestboxvalue); (product product : queriedproductlist) { if (product.getid() == productid) { productlist.add(product); break; } } here attempt piece structure of code fragments provided: public class salesinvoicewidget extends composite { list<product> productlist = new arraylist<product>(); // ... private void somemethod() { map<string, list<product>> productlistmap = productsuggestbox.getvaluemap(); list<product> queriedproductlist =

how to get all the images from a folder with extension .jpg using xslt -

for example,i have folder name, test under n number of images stored .jpg extension log files. need top .jpg images not log files using xslt. possible.? in saxon 9.7 xslt 3.0 support can sequence of uris file name ending e.g. uri-collection('directory-name?select=*.jpg') . not sure want when "get images", suggestion allow file uris of images, e.g. file:/root/directory-name/file1.jpg .

java - Google drive getMimeType returning only null values -

i trying download files drive using version 3 of google drive api in java. need mimetype of files identify content type. when tried calling file.getmimetype i getting null value. drive service=getdriveservice(); filelist result = service.files().list() .setpagesize(100) .setfields("nextpagetoken, files(id, name)") .execute(); list<file> files = result.getfiles(); if (files == null || files.size() == 0) { system.out.println("no files found."); } else { system.out.println("files:"); (file file : files) { system.out.printf("%s (%s)(%s)\n", file.getname(),file.getid(),file.getmimetype()); } } i tried calling other methods getfullfileextension returning null values. could please tell me did mistake? , how solve mimetype , other values. i haven't played v3 yet, code setfields("nextpagetok

php - yii2 error not in log -

i'm getting yii2 error (#8) internal server error occurred. but can not found in logs. neither in .access .error files apache vhost nor in apache logs this happens on remote server , can't reproduce locally. there other way see error aside changing error_reporting on remote server? make sure have specified log target in configuration , log component loaded during bootstrapping. example: return [ 'bootstrap' => ['log'], 'components' => [ 'log' => [ 'targets' => [ [ 'class' => 'yii\log\filetarget', 'levels' => ['error', 'warning'], ], ], ], ], ]; also, check exportinterval , flushinterval setting. from documentation : log messages maintained in array logger object. limit memory consumption array, logger flush recorded message

c# - ConfigureAwait(false) in WebAPI controller -

should sonarlint fire s3216 in asp.net web api controller? seems rule desktop applications, in asp.net context totally different, there's no danger of deadlocks. or missing something? @victorgrigoriu, checking if output kind of compilation unit dll or not, , report issues in dlls. right report on cases when in dll still need switch original context. in general it's hard thing figure out, add check top level web app assemblies. need come way or disable rule default not generate false positives. i've created ticket track problem: https://jira.sonarsource.com/browse/slvs-790 . other options until come permanent solution: can disable rule locally on given project if feel it's annoyance. that, you'll need edit project's ruleset file through "references/analyzers/open active rule set"

html - html5 "required" attribute for mixed radio/text -

i'm designing form has, among others, following elements: <div> <div class="radio-list"> <label><input type="radio" name="ftp_directory" id="ftpdir_public_html" value="public_html"> <strong>public_html</strong> directory</label> <label><input type="radio" name="ftp_directory" id="ftpdir_blank" value="."> <strong>root</strong> directory </label> <label><input type="radio" id="ftpdir_custom" value=""> other directory (please specify)</label> </div> <input name="ftp_directory" class="form-control" type="text" disabled="disabled" aria-disabled="true"> </div> i enable latter <input> text element when check 3rd radio (via jquery) , fine. what want set required a

apache - Rewrite directory to another to stop 404 with htaccess -

a decision made rename directory on our website. have number of old url's indexed google return 404 errors. i try , create rewrite .htaccess resolve problem. directory renamed job jobs so example like: https://myurl.com/job/sales-manager-jobs-in-havant to like: https://myurl.com/jobs/sales-manager-jobs-in-havant i have rewriting in place creates these seo friendly urls single-joblisting.php?id=1 this sits in jobs directory , looks this: options -multiviews rewriteengine on rewritebase /jobs/ rewritecond %{request_filename} !-d rewriterule ^([\w-]+)/?$ single-joblisting.php?id=$1 [l,qsa] i had ask above rewrite working. issue? you can use following redirect: redirectmatch 301 ^/job/(.+)$ /jobs/$1 this permanently redirect /job/foobar to /jobs/foobar

Import project from eclipse to android studio getting error -

i new android studio, import project in android studio run in eclipse. few of error resolved not solved yet. here error - error:execution failed task ':app:transformresourceswithmergejavaresfordebug'. com.android.build.api.transform.transformexception: com.android.builder.packaging.duplicatefileexception: duplicate files copied in apk meta-inf/license.txt file1: /home/user86/downloads/iah/app/libs/httpmime-4.2.3.jar file2: /home/user86/downloads/iah/app/libs/httpclient-4.2.3.jar file3: /home/user86/downloads/iah/app/libs/httpcore-4.2.2.jar and here build.gradle file code. apply plugin: 'com.android.application' android { compilesdkversion 23 buildtoolsversion "23.0.2" defaultconfig { applicationid "com.packagename" minsdkversion 14 targetsdkversion 23 } buildtypes { release { minifyenabled true proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-pro

javascript - iOS Firefox XMLHttpRequest wrong response -

i have function send xmlhttprequest retrieve json backend. xhttp.onreadystatechange = function() { if(xhttp.readystate == 4 && xhttp.status == 200) { applicationutil.showloader(false); if(handler != null) { alert(xhttp.responsetext); if(xhttp.responsetext != "" && this.getresponseheader('content-type') == "application/json") { handler(json.parse(xhttp.responsetext), false); } else { handler("", true); } } } } xhttp.open("get", "../../csp/healthshare/hsanalytics/custom.amy.rest.session.cls?cacheusername="+ username +"&cachepassword="+ password, true); xhttp.send(null); now, function works 100% on browser on device, accept ios firefox. have tried going jquery route, same results: $.ajax({ url: "../../csp/healthshare/hsanal

c# - How to accesss controller ActionBindingContext in rc2 vnext? -

in rc1 , previous builds, controller had bindingcontext property, actionbindingcontext object. this doesnt seem available in rc2? ideas how access it? i using rc2-16357 my nuget feeds are <?xml version="1.0" encoding="utf-8"?> <configuration> <packagesources> <add key="aspnet-contrib" value="https://www.myget.org/f/aspnet-contrib/api/v3/index.json" /> <add key="aspnetvnext" value="https://www.myget.org/f/aspnetvnext/api/v3/index.json" /> <add key="azuread nightly" value="https://www.myget.org/f/azureadwebstacknightly/api/v3/index.json" /> <add key="nuget" value="https://api.nuget.org/v3/index.json" /> <add key="dotnetcore" value="https://www.myget.org/f/dotnet-core/api/v3/index.json" /> <add key="xunit" value="https://www.myget.org/f/xunit

android - Custom Linear layout with round corner -

i tried draw custom linear layout, problem faced not getting round corner linear layout public class roundlinearlayout extends linearlayout { private float radius; private path path = new path(); private rectf rect = new rectf(); public roundlinearlayout(context context) { super(context); radius = 20; // setwillnotdraw(false); } public roundlinearlayout(context context, attributeset attrs) { super(context, attrs); // init(context); } public roundlinearlayout(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); // init(context); } @override protected void ondraw(canvas canvas) { path.reset(); rect.set(0, 0, canvas.getwidth(), canvas.getheight()); path.addroundrect(rect, radius, radius, path.direction.ccw); // add 1px border red here ? path.close(); canvas.clippath(path); } } i donno went wrong.. please me sort out. i suggest use simple cardview use compile dependency compile &#

Need some help on an MySQL query -

i stuck on query. my problem in syntax. can't seem find correct way match records in "like" clause , exclude records not match "like" clause. i using case statement because need format output according conditions. sample of mysql code using posted below. i have included image showing how desire output formatted. the image of desired output found below. mysql output select distinct s.salesid, ss.contact case contact when contact '%manuel%' works when contact not '%manue%' no end manuel? salespeople s left join studios ss on (s.salesid = ss.salesid) ss.contact = 'manuel austin' or ss.contact not null; you have lot of syntax problems in query. you can use query: select s.salesid, case when ss.contact '%manuel%' 'working manuel' else 'not working manuel' end manuel salespeople s left join studios ss on (s.salesid = ss.salesid) group s.salesid, case when ss.contact '%manuel%' '

java - How can I make this String counter code more efficient? -

here code. method counter counts number of times each alphabet occurs in string. public class hard{ public static void counter (string s) { (int n = 0; n < s.length() ; n++) { int count = 0 ,bool = 1; if (n > 0) { (int l = n-1 ; l >= 0 ; l--) { if (s.charat(n) == s.charat(l)) {bool = 0; } } } (int f = 0; f < s.length() ; f++ ) { if (bool == 0) { break ; } if (s.charat(n) == s.charat(f)) {count++;} } if (count > 0 ) { system.out.println(s.charat(n)+" appears "+count+" times."); } } } public static void main (string[] args) { counter("bbaddadxzxwfgb$.fgfdf"); } } assuming you're using java , assuming , counted same letter. public static int[] counter (string s) { int [] countarr = new int[26]; for(int i=0; i<s.length(); i++) { char chara

osx - Dialog like Xcode in OS X -

Image
i want show dialog text input sheet below. i try nsalert don't want show app icon in dialog. nsalert *alert = [[nsalert alloc] init]; [alert setmessagetext:kapptitle]; [alert setinformativetext:kmsgsetdevicename]; [alert addbuttonwithtitle:kbuttonok]; [alert addbuttonwithtitle:kbuttoncancel]; nsstring *devicename = @""; nstextfield *input = [[nstextfield alloc] initwithframe:nsmakerect(0, 0, 300, 24)]; [input setstringvalue:devicename]; [alert setaccessoryview:input]; [alert beginsheetmodalforwindow:self.view.window completionhandler:^(nsinteger button) { }]; you can use http://www.knowstack.com/nsalert-cocoa-objective-c/ link create custom alert sheet in osx. -(void)showcustomsheet { { if (!_customsheet) //check mycustomsheet instance variable make sure custom sheet not exist. [nsbundle loadnibnamed: @"customsheet" owner: self]; [nsapp beginsheet: self.customsheet modalforwindow: self.window modaldelegate: self didendselector:

filter - IcCube - Treefilter without scrollbar and with only limited number of elements -

Image
we try use treefilter in iccube show categories subcategories. discovered 2 problems, don't know, how fix: we have 15 categories on level 1, first 11 of them show. there space underneath, doesn't seem cut due rendering: we not able activate vertical scrollbar, when unfold tree, there parts cannot see anymore. hotizontal scrollbar there, once tree big (image 2) can't used anymore well. did wrong , there options didn't see, or our problems due bugs in widget? point 1) try increase max member count property on query wizard tab of widget (this number members managed, not level 1 items) point 2) try adding {"cssstyle":"overflow:auto"} in content css property of box tab of widget.

access element from javascript function to jquery function -

var id=0;// globel var elem=0;// globel $.fn.myfunction = function(element){ var sid = element.getattribute('href'); elem=element; id=sid; }; $(document).ready(function(){ $.fn.myfunction(); alert(id); alert(elem); }); <a href="#div-1" id="link-id-1" onclick="$.fn.myfunction(this);">link 1</a><br> <a href="#div-2" id="link-id-2" onclick="$.fn.myfunction(this);">link 2</a><br> <div id="div-1" class="hideall">aaaaaaaaaaaaaaaaa</div><br> <div id="div-2" class="hideall">bbbbbbbbbbbbbbbbbb</div> this code not working want alert id attributes "link-id-1" or "link-id-2" , href attributes "#id-1" or "#id-2" javascript function (myfunction()) jquery function there basic error in code. calling $.fn.myfunction on $(

python - Override the authToken views in Django Rest -

i using token based authentication in django , need add user object in addition token being returned. how override class view ? need add class , make changes ? found in rest_framework package , don't want modify library . from rest_framework import parsers, renderers rest_framework.authtoken.models import token rest_framework.authtoken.serializers import authtokenserializer rest_framework.response import response rest_framework.views import apiview class obtainauthtoken(apiview): throttle_classes = () permission_classes = () parser_classes = (parsers.formparser, parsers.multipartparser, parsers.jsonparser,) renderer_classes = (renderers.jsonrenderer,) serializer_class = authtokenserializer print "dasdsa" def post(self, request): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=true) user = serializer.validated_data['user'] token, created = token.objects.