Posts

Showing posts from May, 2015

Copy Paste in Bash on Ubuntu on Windows -

how execute copy paste operation windows 10 bash on ubuntu on windows environment? i tried following: ctrl + shift + v right click paste any suggestions? another solution enable "quickedit mode" , can paste right-clicking in terminal. to enable quickedit mode, right-click on toolbar (or click on icon in upper left corner), select properties, , in the options tab, click checkbox next quickedit mode. with mode enabled, can copy text in terminal clicking , dragging. once selection made, can press enter or right-click copy.

java - JUnit Test Cases for Config -

i have javaconfig file looks this: @configuration public class serviceconfig { @autowired foobean somebean; @bean @scope(value="session", proxymode = scopedproxymode.target_class) public fooservice fooservice() { return new fooserviceimpl(somebean, foob()); } private foo foob() { return new foob(); } } and have created junit test file based on this stack answer : @runwith(springjunit4classrunner.class) @contextconfiguration(classes = serviceconfig.class) public class serviceconfigtest { } but have couple questions: should test config files 1 junit test file? have 4 config files in total including serviceconfig file, in contextconfiguration should list them out or have junit test each 1 indivually? what supposed test here? tried reading spring guide i'm not understand behavior should test here....just if gets autowired successfully? should test config files 1 junit test file? have 4 confi

javascript - socket.io 404 cant connect with socket.io server -

i have webrtc / socket.io / nodejs running on server, works fine when go https://domain.com:8080 test video conference. but want script run in webserver /public_html/ but dont know why not connecting 8080 server. "socket.io.js https://domain.com/socket.io/?eio=3&transport=polling&t=lpgzs2k 404 (not found)" my server (server.js) // load required modules var https = require("https"); // http server core module var express = require("express"); // web framework external module var servestatic = require('serve-static'); // serve static files var socketio = require("socket.io"); // web socket external module var easyrtc = require("../"); const fs = require('fs'); // easyrtc external module const options = { key: fs.readfilesync('key.pem'), cert: fs.readfilesync('cert.pem') }; // set process name process.title = "node-easyrtc"

matlab - Why gpu slower than cpu? -

i have gpu >> d = gpudevice d = cudadevice properties: name: 'geforce 800m' index: 1 computecapability: '2.1' supportsdouble: 1 driverversion: 6 toolkitversion: 5 maxthreadsperblock: 1024 maxshmemperblock: 49152 maxthreadblocksize: [1024 1024 64] maxgridsize: [65535 65535 65535] simdwidth: 32 totalmemory: 2.1475e+09 freememory: 1.9886e+09 multiprocessorcount: 1 clockratekhz: 1475000 computemode: 'default' gpuoverlapstransfers: 1 kernelexecutiontimeout: 1 canmaphostmemory: 1 devicesupported: 1 deviceselected: 1` i try use gpu in neuralnetwork train, gpu slower cpu. if try use gpuarray, gpu faster cpu, haven't speed acceleration in neural network training. example >> a1 = rand(1000); b1 = rand(1000); tic; c1 = a1 * b1; toc; elapsed time 0.044095 seconds. >&

Perl- searching for values in one file which could be present in another -

i have file following list of products mentioned : dl750-12d1 dl750-12d2 dl750-12d3 dl750-12d4 dl750-12d5 dl750-12d6 dl750-12d9 dl750-12d11 i have file contains list of json objects follows: { "type": "dl750-12d5", "productlevelsimcheck": false, "hwcompatibilitycheck": true, "fwversioncheck": true, "configcheck": true, "createdat": "2016-07-23t04:00:00.000z", "active": true, "imeirequired": true, "hwcompatibility": "01 01 01 01 01 00 00 00", "fwversion": "d6.57", "config": "tmc02", "generation": "gen 2", "modifiedby": "chanakyav", "updatedat": "2016-07-28t17:42:48.249z", "id": "5794182ba6832e7056349c76" } how 1 search if list of products listed

python - How does asyncio's event loop know when an awaitable resource is ready? -

i'm learning python asyncio asynchronous programing. know event loop watch on future objects until ready , resumes appropriate coroutines continue execution in point await keyword occurred. this understandable when use asyncio.sleep because sleeping function knows how many time take , know event loop what happens relies on networking ( example) waiting time unknown? . how event loop know when resource ready or how many time take gather data source? how event loop know when resource ready or how many time take gather data source? the default event loop (based on selectoreventloop ) uses selector module keep track of resources monitor , notified when new data ready. baseselector.select where magic happens .

javascript - MEAN Stack App Structure -

i used express-generator npm create boilerplate mean stack app , worked didn't understand purpose of few files. for example: the package.json contained following code: "script":{"start": "node ./bin/www"} the app contained folder called bin contained file called www contained code below: #!/usr/bin/env node /** * module dependencies. */ var app = require('../app'); var debug = require('debug')('myapp:server'); var http = require('http'); var port = normalizeport(process.env.port || '3000'); app.set('port', port); var server = http.createserver(app); server.listen(port); server.on('error', onerror); server.on('listening', onlistening); function normalizeport(val) { var port = parseint(val, 10); if (isnan(port)) { // named pipe return val; } if (port >= 0) { // port number return port; }

ios - JSon and Ambiguos use of subscript -

i'm developing ios application , latest updates go t error : ambiguous use of subscript for code : let json: anyobject = try nsjsonserialization.jsonobjectwithdata(data!, options: nsjsonreadingoptions.mutablecontainers) return (json[0]) as! nsdictionary is there solution? thank you. since annotate json anyobject compiler not able infer type if it's dictionary (key subscription) or array (index subscription). that's ambiguity. the solution cast object proper type let json = try nsjsonserialization.jsonobjectwithdata(data!, options: []) as! [[string:anyobject]] return json[0] ps: use swift native collection types. foundation nsarray , nsdictionary don't contain type information , option .mutablecontainers not needed in of cases.

html - Bootstrap data-spy not firing off -

i'm working on profile website myself , have 'decent' concept , running. however seems if navbar's data-spy either isn't firing off or if there wrong html / css. this pen html / css. body (relevant data-spy reference): <body data-spy="scroll" data-target="#navbar" data-offset="50"> this how i've set navbar: <nav id="navbar" class="collapse navbar-collapse"> <div class="navbar-header"> <button type="button" data-toggle="collapse" data-target="#navbar-target" class="navbar-toggle"> <span class="icon-bar"> </span> <span class="icon-bar"> </span> <span class="icon-bar"> </span> </button> </div> <div class="collapse navbar-collapse" id="navbar-target"> <ul class="nav navbar-nav navbar-rig

r - Install package "rio" because of feather -

i try in r install cran-packages "rio" receive following error: install.packages("rio", dependencies = true) installing package ‘c:/software/rpackages’ (as ‘lib’ unspecified) installing dependency ‘feather’ there binary version available source version later: binary source needs_compilation rio 0.4.0 0.4.8 false package available in source form, , may need compilation of c/c++/fortran: ‘feather’ these not installed installing source package ‘rio’ trying url 'https://cran.rstudio.com/src/contrib/rio_0.4.8.tar.gz' content type 'application/x-gzip' length 40366 bytes (39 kb) downloaded 39 kb error: dependency 'feather' not available package 'rio' * removing 'c:/software/rpackages/rio' warning in install.packages : running command '"c:/progra~1/r/r-32~1.4re/bin/x64/r" cmd install -l "c:\software\rpackages" c:\users\bjrnau~1\appdata\local\temp\rtmp6rf71b/downloaded_pack

java - Spring Boot Jackson mappings are not working -

i using fasterxml jackson json serialization. have written date serializer public class dateobjectserializer extends jsonserializer<date> { public static final string date_format = "dd.mm.yyyy"; @override public void serialize(date date, jsongenerator jgen, serializerprovider provider) throws ioexception, jsonprocessingexception { system.out.println("from dateobjectserializer"); simpledateformat dateformat = new simpledateformat(date_format); string formatteddate = dateformat.format(date); jgen.writestring(formatteddate); } } but not being invoked. other jackson serializers working fine. so added following configuration in application.yaml spring: jackson: serialization-inclusion: non_null date-format: dd.mm.yyyy but din't work. so have added code in springbootconfiguration class. @override public void configuremessageconverters(list<httpmessageconverter<?>> converters

haskell - MaybeT/Maybe and IO: Failsafe reading of information -

Image
i trying read information entered user , parse type person , uses type gender . so, use code: data person = person string int gender string data gender = male | female | notspecified deriving read instance show gender show male = "male" show female = "female" show notspecified = "not specified" instance show person show (person n g j) = "person {name: " ++ n ++ ", age: " ++ show ++ ", gender: " ++ show g ++ ", job: " ++ j ++ "}" readpersonmaybet :: maybet io () readpersonmaybet = putstrln "name?:" name <- getline putstrln "age?:" agestr <- getline putstrln "gender?:" genderstr <- getline putstrln "job?:" job <- getline let newperson = person name (read agestr) (read genderstr) job putstrln $ show newperson now make more failsafe - achieve tried use maybet monad. using this, got co

c - Initializing floating point variable with large literal -

#include <stdio.h> int main(void) { double x = 0.12345678901234567890123456789; printf("%0.16f\n", x); return 0; }; in code above i'm initializing x literal large represented ieee 754 double. on pc gcc 4.9.2 works well. literal rounded nearest value fits double. i'm wondering happens behind scene (on compiler level) in case? behaviour depend on platform? legal? when write double x = 0.1; , decimal number have written rounded nearest double . happens when write 0.12345678901234567890123456789 not fundamentally different. the behavior implementation-defined, compilers use nearest representable double in place of constant. c standard specifies has either double above or 1 below.

css - unable to make an image in the corner an responsive -

i using bootstrap make landing page , having trouble alignment , responsiveness. want image in corner of screen when screen gets smaller adjusts well. it's not working me, stays in position. it's vision.png image want move. tried position relative , absolute, no luck <header> <div class="container"> <div class="row"> <div class="col-lg-12"> <img class="img-responsive" src="img/vision.png" alt=""> <div class="intro-text"> <!-- <span class="name">text here</span>--> <!-- <hr class="star-light"> --> <img class="img-responsive" src="img/logo.png" alt=""> <span class="skills">more text here</span> </div>

c# - List of foreign keys in Entity Framework Core using SQLite -

i want implement related pages structure 1 page have list of other pages related it. could't figure out if possible. have structure this: public class page { public int id { get; set; } public string urlname { get; set; } public list<relatedpages> relpages1 { get; set; } } public class relatedpages { public int id { get; set; } public int pageid { get; set; } public page page { get; set; } // list of related page ids public list<int> relpagesid { get; set; } public list<page> relpages { get; set; } } and here onmodelcreating method in dbcontext: protected override void onmodelcreating(modelbuilder modelbuilder) { modelbuilder.entity<relatedpages>() .hasone(x => x.page) .withmany(x => x.relpages1) .hasforeignkey(x => x.pageid); } if trying recursive selection such ef load records in turn same table don't thi

android - Add a "Remember me" checkbox -

i have checkbox button remember user id , password. can please guide me in right direction how started? i built app, here's basic code , explanation: basically key here sharedpreferences. you'll setup sharedpreferences object , store username , password after user has entered them. then, when run application again, preferences have data stored , repopulate login fields. loginactivity.java package com.realsimpleapps.logintesting; import android.app.activity; import android.content.context; import android.content.intent; import android.content.sharedpreferences; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.view.inputmethod.inputmethodmanager; import android.widget.button; import android.widget.checkbox; import android.widget.edittext; public class loginactivity extends activity implements onclicklistener { private string username,password; private button ok; private edittext editte

oracle - Endeca 6: phrasing isn't triggered for phrases with special characters -

the special characters , . + - these characters had become searchable because of other needs. according endeca guides, because searchable, can used in phrases ie "apple + orange". the problem doesn't seem work, phrasing isn't happening , terms treated normal search(while phrase has been manually tested, using quotes, in reference application confirm existance of results). did tries 11.2 version check if older bug didn't work either. thanks

jquery - Function on php file -

i have code got here (function() { var quotes = $(".quotes"); var quoteindex = -1; function shownextquote() { ++quoteindex; quotes.eq(quoteindex % quotes.length) .fadein(2000) .delay(2000) .fadeout(2000, shownextquote); } shownextquote(); })(); i want know how put in index php file because it's not working, know i'm working on joomla template , class quote on 1 of modules. thanks $(function() { var quotes = $(".quotes"); var quoteindex = -1; function shownextquote() { ++quoteindex; quotes.eq(quoteindex % quotes.length) .fadein(2000) .delay(2000) .fadeout(2000, shownextquote); } shownextquote(); })();

c# Serial port losing trailing character -

Image
i have modbus interface in project. have 2 serial ports on pc, 1 on board , 1 usb serial. if use on board serial port miss last character of return string, if use usb serial port whole return string. //onboard-------- tx: 01 03 02 00 00 12 c4 7f rx: 01 03 24 00 00 00 64 00 00 00 0c 00 00 00 00 06 fa 02 d0 d9 54 00 00 00 00 00 04 00 0c 00 00 00 0c 00 00 00 00 00 00 c6 //usb serial-------------- tx: 01 03 02 00 00 12 c4 7f rx: 01 03 24 00 00 00 64 00 00 00 0c 00 00 00 00 06 fa 02 d0 d9 54 00 00 00 00 00 04 00 0c 00 00 00 0c 00 00 00 00 00 00 c6 e9 if using datareceivedhandler event: private void datareceivedhandler(object sender, serialdatareceivedeventargs e) { int rxcnt = 0; serialport sp = (serialport)sender; (rxcnt = 0; rxcnt < _serialport.bytestoread; rxcnt++) { rx_buffer[rx_buffer_len++] = (byte)_serialport.readbyte(); } } same code running on 2 different ports different results, ideas? regards richard something foun

apache poi - java read part of large xlsx file -

what fastest , less memory intensive way read portion of large xlsx file? currently have code: fileinputstream fis = null; fis = new fileinputstream("d:/verylargefile.xlsx"); xssfworkbook workbook = new xssfworkbook(fis); xssfsheet sheet = workbook.getsheetat(0); int r = sheet.getphysicalnumberofrows(); int c = sheet.getrow(1).getlastcellnum(); (int row = 1; rows < r;row++){ (int cell = 1; cell < c;cell++){ int cellvalue = (int)sheet.getrow(row).getcell(cell).getnumericcellvalue() //do simple math op cell or several cells } } so need large number of simple math operations (for example average of every 5 cells in every row or simillar) , fast, small part of large xlsx file @ once. code above, getting heap space error 10mb xlsx file , 1gb ram dedicated java vm (-xms1000m). thank you

android - recyclerview, on click Highlight and make others not highlighted -

i have recyclerview of credit cards, if click on 1 want change background resource of 1 , make other ones default, reason have been fighting 5 hours , cant right. here failing class public class checkoutcardrecycler extends recyclerview.adapter<checkoutcardrecycler.cardviewholder>{ private list<card> checkoutcard; private int screenwidth; private int selected; public checkoutcardrecycler(activity activity, list<card> checkoutcard){ display display = activity.getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); this.screenwidth = size.x; this.checkoutcard = checkoutcard; selected=-1; } public static class cardviewholder extends recyclerview.viewholder { cardview card; linearlayout row; static textview etcardnumber; static textview etname; static textview etdate; static linearlayout credit