Posts

Showing posts from April, 2015

java - Send file contents between classes using file & object streams without using String in this process -

i doing project in java in eclipse ga 3.4.2 . have upload file , encrypt file content in 1 class , send encrypted file contents other class. occur have copied encrypted contents string object , send other class , store database. here, have encounterred problem when encrypted content stored in string object, object not able recognize of encrypted characters in content, 'm able recognize syso stmts. so, in process of download, when retrieve content database , try decrypt it, doesn't matche original file content. so, please give solution without using string object in process , whether filecontents transferred without using string object format between classes? you can use base64 encode/decoding (which involves byte[] ). quick search find question answers. base64 encoding in java

javascript - Famo.us ScrollContainer not scrolling -

define(function(require, exports, module){ var view = require('src/core/view'); var surface = require('src/core/surface'); var scrollcontainer = require('src/views/scrollcontainer'); function listview(){ view.apply(this, arguments); _createcontent.call(this); } listview.prototype = object.create(view.prototype); listview.prototype.constructor = listview; listview.default_options = { data: [] } function _createcontent(){ var sc = new scrollcontainer(); var sequence = []; sc.sequencefrom(sequence); (var = 0; < this.options.data.length; i++) { var surface = new surface({ content: this.options.data[i].name, size: [undefined, 40], properties: { borderbottom: '1px solid #000', padding: '10px 15px' } }); sequence.push(surface); }; this.add(sc); } module.exports = listview; }); as

youtube - android stream real time video to streaming server -

i trying develop half duplex chat application 1 android device capture video cam , send real time video stream server. thereafter, android device capturing same video stream streaming server , rendering video on screen. i did using webrtc api, vitamio api , wowza streaming server. but, method resulting in poor video quality @ receiver's end poor video quality , huge latency on fast working lan. device heatup problem comming existance. please tell me other method achieve same. youtube provide facility broadcast real time video stream. there other free service enables sending video stream server android device (as have done in application).

ember.js - Ember-Data store.filter with async relationships -

i working on survey application , using existing api. our models like: app.user = ds.model.extend({ name: ds.attr('string'), participations: ds.hasmany('participation', {async: true}) }); app.participation = ds.model.extend({ user: ds.belongsto('user', {async: true}), survey: ds.belongsto('survey', {async: true}), hascompleted: ds.attr('boolean'), hasaccepted: ds.attr('boolean') }); app.survey = ds.model.extend({ participations: ds.hasmany('participation', {async: true}), title: ds.attr('string'), locked: ds.attr('boolean') }); i return live record array model hook via store.filter filter needs deal both survey's , async participant record current user. how can handle async relation resolution in filter callback function? model: function() { return ember.rsvp.hash({ user: this.store.find('user', 1), surveys: this.store.filter('survey', {}, functio

sql - DB2 restrict analytic function to subselect -

i encountered situation wanted restrict action of analytic function (or olap in db2) subset of present data. here example: with my_table ( select 1 field1, 'a' field2, 1 field3, 'x' field4 dual union select 1 field1, 'a' field2, 2 field3, 'y' field4 dual union select 1 field1, 'b' field2, 3 field3, 'x' field4 dual union select 1 field1, 'a' field2, 4 field3, 'z' field4 dual union select 1 field1, 'b' field2, 5 field3, 'z' field4 dual //... ) select first_value(field4) on (partition field1 order field3) field2_a my_table field2='a' // need 'b', 'c' etc. now cumbersome required values of field2 , afterwards doing join or union, since constraints might more complicated. thus want handle in single select. here trial: //... select case when field2 = 'a' first_value(field4) on (parti

ios - How to pass data from containing app to widget in today view? -

i wrote widget app, , according articles, used "app group" bridge pass data containing app widget app, there not images , words info, frame/layout info in data. the problem found widget view not shown immediately, may existed 1~3 seconds delay. what's worse, widget view showed "unable download" if data included many info(i need show many things in widget). after long attempt, still not found real reason caused issues. guess "app group" may not work well, can me figure out what's wrong work?

javascript - play animation on matching pairs in memory game -

i'm creating memory game web assignment @ uni , stuck on how animation playing on match on top of cards match. @ moment, have been able animation play on click of memory_board div, works once. so question 1 - how animation work every time click on memory_board div.(it works once atm, , have refresh page play again) my code animation work is: .sprite { width:96px; height:96px; position: relative; margin:15px; } .toon{ background: url(explode.png); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script type='text/javascript' src='jquery.animatesprite.js'></script> <script>//sparkle effect: http://www.rigzsoft.co.uk/how-to-implement-animated-sprite-sheets-on-a-web-page/ $(document).ready(function(){ $("#memory_board").click(function animation(){ $(".toon").animatesprite({ columns: 10, totalframes: 50,

android - JNI methods are not calling when application comes foreground -

i using jni in application... when application launches works fine , jni logs getting printed .. once application went background , comes foreground after using other application jni logs not printing , methods not getting called.. can suggest me solution? thanks in advance.. would give more specific info jni design? first thing need check... building jnicode shared library.so check in logs jni_unload getting called when application going in background. second thing need check... check in application going in backgroud ..shared library getting unloaded application. third thing need check... jni code caching jvm , jnienv variable.

php - How to get the price of variable product using variation ID? -

i have variation id of product. there way price of particular variation id. i tried below code. $variation_id = 12312; $price = get_post_meta($variation_id, '_regular_price', true); you code not display correct price if have set sale price product should use _price key that. here code workout you. $variation_id = '12312'; $price = get_post_meta($variation_id, '_price', true); or $variation_id = '12312'; $variable_product = wc_get_product($variation_id); //$regular_price = $variable_product->regular_price; //$sale_price = $variable_product->sale_price; $price = $variable_product->price; please note: you can use of above given method i'll recommend use last one, because if woocommerce change metakey first code snippet not work 2nd 1 work. hope helps!

java - In building chat application, is Web Service better to use than JMS, RMI, or Socket programming? -

in building java chat application, web service better use jms, rmi, or socket programming? my vps has ff: 512mb memory, 1 core processor, 20gb ssd disk , 1tb transfer. my target number of users in same time is, 5-30. i think way handle changes in chatbox using polling. vps can handle load if using web service? if going use other technologies rmi or jms? vps can handle it? if have web frontend chat, using websockets (if want use java on backend, it's supported jetty other http servers) instead of polling more common approach. definitely no jms,rmi or sockets, if client browser, if it's desktop client using based on sockets , custom protocol easiest way go. the number of connections vps handle dependant on many factors, included how performant application be.

ios - IBInspectable and floating point values -

Image
is possible set floating point value in attributes inspector? have property in uiview: @ibinspectable var scale: cgfloat = 0.90 { didset { setneedsdisplay() } } as can see, default value 0.9 , change in attributes inspector, looks that: and able set integer values in there. missing something? you can set it. worked me using comma when entering number instead of period. , commented @alladinian: [t]he decimal separator [might be] locale (region) dependant. here it's 0,5 , not 0.5 : here it's 0,8 , not 0.8 :

ajax - Display code flow on UI in java web application -

i have java web application, developed in spring framework. in that, running job (like moving data 1 database other database). i want track progress of operation, not displaying progress bar, instead of that, want display real time logs, track flow, on ui. i using reverse ajax using dwr seems, excessive use of it, creating outofmemory error. how can achieve it? web.xml code <servlet> <servlet-name>dwr</servlet-name> <servlet-class>org.directwebremoting.spring.dwrspringservlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>activereverseajaxenabled</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr</servle

javascript - How to access object from parent in custom if helper? -

Image
the ../../message.notavailable in ifequal helper doesn't seem work if provide string "hello" compare type works fine , comes inside loop {{#ifequal type ../../message.notavailable}} <li id="{{id}}"><a href="#">{{../../../message.notavailable}}</a> </li> {{/ifequal}} my helper: handlebars.registerhelper('ifequal', function(value1, value2, options) { if(value1 === value2) { return options.fn(this); } return options.inverse(this); }); edit: i have tried removing ../../ variable doesn't seem work. if message.notavailable in parent template scope, use ../message.notavailable . the ../ path segment references parent template scope, not 1 level in context.

c - Accessing 2D array elements using double pointer -

recently had interview in c . interviewer has asked me explain how access particular element in 2d array using double pointer . gave answer *(*(a+i)+j) , a double pointer, i number of rows , j number of columns. later asked me explain using example. confused @ *(a+i) gives value instead of address , adding j gives junk value. can please explain. remember in 1d array a[i] equals *(a+i) . , there no 2d arrays in c, arrays of arrays. so a[i][j] equal *(*(a+i)+j) . if type of a int** , type of (a+i) still int** , need dereference it. type of *(a+i) int* , type of *(*(a+i)+j) int . about interview question, no matter a double pointer, should still use [] notation. alternative cumbersome: int **a = ...; int x = a[i][j];

debugging - Linking Windows Debugger to Project -

i coded big project runs when open in debug or release mode, when open without debugging (ctrl + f5) crashs. searched long time find heap error, didnt find anything. problem need running .exe of programm, wanted ask if there possibility link windows debugger .exe starts it. if doesn't crash right away, maybe helps: you can run executable. open solution in visual studio. make sure it's same build. open debug menu , click attach process. a window open, listing processes running. select executable that's crashing click debug menu again , select exceptions (ctrl-alt-e) make sure checkbox "thrown" checked common language runtime exceptions now crash application.. halt @ line causes it. also environment directives. #if debug #end if. or #if release kind of stuff. tricked me couple of times too.. good luck. hope helps!

"Mobile first" or last from a breakpoint perspective? -

"mobile first" recommended, know. however, understand because of progressive enhancement principle. when build simple site, scaling/re-arranging items fit better , have better legibility on smaller devices, can not start desktop design , work way down mobile? it's near impossible design every possible screen. basic "breakpoint" put has been determine client needs, , expect. presently, clients need site meets basic mobile requirements or @ least has few mobile-friendly pages, if deeper content still in desktop format. there no 1 fixed answer this. however, should conceptualizing how design work in both formats , trying minimize amount of rewriting you'll need 1 other, keeping layouts fluid possible.

.net - I'm trying to access Excel file to export it to SQL database with ASP.NET and VB.NET but getting following error -

the microsoft access database engine cannot open or write file ''. opened exclusively user, or need permission view , write data. i'm trying import excel file asp.net , vb.net update sql server. i'm getting following error. please give me solution. vb.net code. dim strconnection [string] = "projectlist" dim path string = fileuploadexcel.postedfile.filename dim excelconnectionstring string = "provider=microsoft.ace.oledb.12.0;data source=" & path & ";extended properties=excel 12.0;persist security info=false;mode= share deny none;persist security info=false;mode=12" dim excelconnection new oledbconnection(excelconnectionstring) dim cmd new oledbcommand("select [id],[name],[designation] [sheet1$]", excelconnection) excelconnection.open() dim dreader oledbdatareader dreader = cmd.executereader() dim sqlbulk new sqlbulkcopy(strconnection) sqlbulk.destinationtablename = "e

mediawiki api - Filter Wikipedia geosearch per region -

i saw wikipedia api (called mediawiki geodata ) search wiki pages around fixed coordinates. example call is https://it.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=10000&gscoord=37.786971|-122.399677 i saw geodata, in extra parameters , has concept of region , accepting iso 3166-2 region code. how can search elements, filtering per region code? example, if searching around coordinates near border between 2 regions, able filter elements of 1 region? short answer: can't. longer answer: lack 2 features filed in issue tracker you, i.e. populating region parameter in geodata : pages do not specify region geodata in free text (which useless), structured data have in wikidata; adding option filter results region . for now, you'll have client-side: figure out coordinates of each region , filter those; or search region in wikidata statements , fetch corresponding articles in language desired. developer help import country data

eloquent - Querying Laravel Relationship -

i trying 1 query work since morning , not able working have 2 tables photographers , reviews please have @ structure , ask question @ bottom : reviews table : id int(10) unsigned -> primary key review text user_id int(10) unsigned foreign key users table user_name varchar(64) photographer_id int(10) unsigned foreign key photographers table photographers table : id int(10) unsigned -> primary key name text brand text description text photo text logo text featured varchar(255) photographers model : class photographer extends model { public function reviews() { return $this->hasmany('\app\review'); } } reviews model : class review extends model { public function photographers() { return $this->belongsto('\app\photographer'); } } my logic query records $response = photographer::with(['reviews' => function($q) { $q->selectraw('max(id) id, review, user_id, user_name, photographer_id'); }])

java - How to load cordova plugin dynamically into android app -

i use following code dynamically load class android app. (note: loaded) file file = environment.getexternalstoragepublicdirectory(environment.directory_downloads); string fileinput = file.getabsolutepath() + "/file.jar"; file optimizeddexoutputpath = activity.getdir("dex", context.mode_private); string fileoutput = optimizeddexoutputpath.getabsolutepath(); dexclassloader classloader = new dexclassloader(fileinput, fileoutput, null, getclass().getclassloader()); try { class<?> helloclass = classloader.loadclass("helloclass"); toast.maketext(activity, "loaded success: " + helloclass.tostring(), toast.length_short).show(); } catch (classnotfoundexception e) { e.printstacktrace(); } and have following cordova config.xml: <feature name="helloclass"> <param name="android-package" value="helloclass" /> </feature> when called execute method javascript, got following error

function - How to turn a simple text expression into a mathematical expression in R -

right trying solve question concerning establishing function calculate log of moment generating functions in r. required procedure user input random density function f(x) interval of random variable. however, have no idea how let r identify input string of function expression, "x^2-4*x", , turn workable mathematical expression or function. can help? mgf <- function(expr, t, from=null, to=null){ moment <- null (i in 1:length(t)){ moment <- c(moment,integrate(exp(x*t[i])*(expr),lower=from,upper=to)) } return(moment) } this code i'm having. obviously, won't work. want users can input expression, x^2-4*x , value of expr, , turn expr part of function integrate() function can evaluate. you can try: library(functional) mgf = function(stringformula, t, from=null, to=null) { f = function(x, i) exp(x*i)*eval(parse(text=stringformula)) sapply(t, function(u) integrate(curry(f, i=u), lower=from, upper=to)[[1]]) } the point is

asp.net mvc - Changes to cookie domain for outgoing responses ignored for ServiceStack requests -

i have multi-tenant website (e.g. several different sites, each it's own domain, in same project, separated using mvc areas), authentication cookie has domain manually set when user logs in available subdomains (but not various other sites in project, not sso). so user logins x.foo.com, cookie domain set foo.com, works @ y.foo.com , z.foo.com. however, because of other domains being served same project auth cookie domain cannot set in web.config in usual manner, instead set manually when user logins in so: public httpcookie getauthenticationcookie(string username) { var cookiedomain = urlhelper.gettopandsecondleveldomain(); var authenticationcookie = formsauthentication.getauthcookie(username, false); authenticationcookie.domain = cookiedomain; return authenticationcookie; } this works fine, of course can cause problem when cookie automatically refreshed sliding expiration. have http module hooked postrequesthandlerexecute event of our mvc app auth cooki

perl - how to replace , to . in large text file -

i wish use perl , write program looks latitude , longitude values in large tab delimited text file (100000 rows), , replaces , used in lat long values . . file has multiple columns. ie. want change to. 51,2356 51.2356 can show me how done? many thanks, you don't need "program" that, things 1 liners really. if want replace all , (commas) in file . (dots) in entire file (your question doesn't go specifics of original file format) below trick: perl -pi.bak -e 's/,/\./g;' your_file.txt it backup file before running replace your_file.txt.bak .

c - fflush, fsync and sync vs memory layers -

Image
i know there similar questions , gave them couldn't find explicit univocal answer question. investigating online these functions , relationship memory layers. in particular found beautiful article gave me insight memory layers it seems fflush() moves data application kernel filesystem buffer , it's ok, seems agree on point. thing left me puzzled in same article assumed write-back cache saying fsync() "the data saved stable storage layer" , after added "the storage may store data in write-back cache, fsync() still required files opened o_direct in order save data stable storage" reading here , there seems truth fsync() , sync() let data enter storage device if 1 has caching layers moved here, not @ once permanently storage , data may lost if there power failure. unless have filesystem barriers enabled , " sync() / fsync() , other operations cause appropriate cache flush (ata) or synchronize cache (scsi) commands sent device" [fro

Embedding Jetty 9 and customizing Socket Address, Port and ThreadPool? -

i have used jetty 8.1.14 embedded web server in application. trying upgrade version 9.2.10. with jetty 8, possible specify host address , port using setters in "selectchannelconnector" or "sslselectchannelconnector", , threadpool constructor argument in "server" class. now, seems 1 can specify 1 or other in "server" class. there constructor variants address and/or port, or threadpool use. can't find variant 3 arguments. how can specify parameters jetty 9? have tried: string bindaddress = "myvalue"; int port = 12345; server s = new server(new inetsocketaddress(bindadress, port)); and threadpool t = myhighlycustomizedthreadpool(); server s = new server(t); use serverconnector setting listen ports, setting listen host addresses, setting idle timeouts, , setting default protocols. once started, same connector can used determine actual listening port (if using dynamically assigned ports), actual listen hosts (i

table - MySQL error 1093. how to delete from this -

select worked: select * a.id not in ( select id inner join b b (a.`name` = b.`name` , a.`status` = b.`description`)) delete doesn't work: delete pre_log pre_log.id not in ( select id pre_log p inner join sobg_table s (p.`name` = s.`name` , p.`status` = s.`description`) ) error code: 1093. can't specify target table 'pre_log' update in clause 0,001 sec you have specified pre_log table in sub query delete records try might you.. delete l.* pre_log l l.id not in ( select id ( select id pre_log p inner join sobg_table s (p.`name` = s.`name` , p.`status` = s.`description`) ) x )

linux - RHEL + Codeception: invalid mit-magic-cookie-1 keyerror cannot open display :2.0 -

so i'm trying run codeception acceptance tests on linux server (with selenium). enter command: ./codecept run acceptance (with flags such --env firefox-linux) codeception starts, pauses bit , firefox throws error: invalid mit-magic-cookie-1 keyerror: cannot open display: :2.0 i read xauth stuff, have tried deleting , re-creating xauthority, export display etc., still error. a few things note: rhel 6.6, firefox 27 (using older version work selenium) also have hunch might not 'x' problem, in general config? have look, suggestions appreciated. after poking around discovered error in selenium. firstly, versions of selenium , firefox incompatible, changed that, started getting 'no display specified' error. changed selenium build command to: export display=":1" && java -jar selenium-server-standalone-2.44.0.jar this temporary solution, others having issue suggest @ selenium , browser config, @ /etc/hosts , see says, try , e

rust - Read a single line from stdin -

how can read single line stdin in rust? i'm asking equivalent of fgets() in c. let line = ...; println!("you entered: {}", line); note: read how read user input in rust? , asks how read multiple lines, want 1 line. saw how read single string standard input? , i'm not sure if behaves fgets() or sscanf("%s",...) . in how read user input in rust? answer, can see how iterate on lines. use std::io::bufread; let stdin = io::stdin(); line in stdin.lock().lines() { println!("{}", line.unwrap()); } you can manually iterate without for-loop: let stdin = io::stdin(); let mut iterator = stdin.lock().lines(); let line1 = iterator.next().unwrap().unwrap(); let line2 = iterator.next().unwrap().unwrap(); you cannot one-liner want. following gets single line (and same answer in how read single string standard input? ): let stdin = std::io::stdin(); let line1 = stdin.lock().lines().next().unwrap().unwrap(); you can use text_io

scheme - Create lists from lists -

i want write function n arguments create n lists , each contains n-th element every argument, example: (aux '(1 2) '(3 4)) = `((1 3) (2 4)) i wrote such function: (define (aux . args) (if (null? args) '() (cons (map car args) (aux (map cdr args))))) but when try evalute (aux '(1 2) '(3 4)) repl not show output. question should change because don't see syntax errors. chris correct. in event want use rest arguments , use in recursion should consider wrapping in named let or make local helper procedure. (define (zip . args) (let aux ((args args)) (if (ormap null? args) '() (cons (map car args) (aux (map cdr args)))))) i when there arguments don't change. eg. map implementation 1 list don't pass procedure @ each iteration: (define (map1 proc lst) (let aux ((lst lst)) (if (null? lst) '() (cons (proc (car lst)) (aux (c

weed-fs in Linode running master -

i'm using weed-fs 0.7 beta. i'm having issue master server not have free volume servers while have 2 of them. have 2 servers in linode, used 1 of them create master, volume , filer server using command. ./weed server -ip.bind="192.168.139.166" -master.port=9333 -volume.port=8080 -volume.max="7" -dir="./data" -master.dir="./master" -filer=true -filer.dir="./filer" the 3 systems starts properly. when check master server using command: curl "http://{ip-address}:9333/dir/status?pretty=y" this result: { "topology": { "datacenters": null, "free": 0, "max": 0, "layouts": null }, "version": "0.70 beta" } i can add in file volume server directly using this: curl -f file=help.txt http://{ip-address}:8080/3,01637037d6 when attempt add above file, response on console of server: i0512 08:30:06 20079 store.go:346] volume

javascript - fullPage.js scrolling on top of select box element in IE and Firefox -

basically i've encountered problem fullpage.js scrolling when select tag open. this happens in ie (all versions) , firefox in mac. i don't know if issue or if i'm forgetting something. what have tried : adding normalscrollelements select or form . disabling fullpage scroll when user in form or select both of them didn't work. 1st try: codepen : http://codepen.io/anon/pen/dogego snippet: doesn't work here $(document).ready(function () { $('#fullpage').fullpage({ anchors: ["contact-form","contact"], navigation: true, scrolloverflow: true, navigationposition: 'right', navigationtooltips: ["form","meh"], responsive: 991, easingcss3: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)', paddingtop: '110px', normalscrollelements: '#country' }); }); <script src="https