Posts

Showing posts from February, 2015

r - How to extract average ROC curve predictions using ROCR? -

Image
the rocr library in r offer ability plot average roc curve (right rocr reference manual ): library(rocr) library(rocr) data(rocr.xval) # plot roc curves several cross-validation runs (dotted # in grey), overlaid vertical average curve , boxplots # showing vertical spread around average. data(rocr.xval) pred <- prediction(rocr.xval$predictions, rocr.xval$labels) perf <- performance(pred,"tpr","fpr") plot(perf,col="grey82",lty=3) plot(perf,lwd=3,avg="vertical",spread.estimate="boxplot",add=true) lovely. unfortunately, there's seemingly no ability obtain average roc curve object/dataframe/etc. further statistical testing (say, proc ). did research (albeit perhaps after fact), , found post: global variables in r i looked through rocr's code reveals following lines passing result plot: performance_plots.r , (starting @ line 451) ## compute average curve perf.avg <- perf.sampled perf.avg@x.values <-

ios - master detail app crashes instantly when using push segue -

first of all, if is, somehow, dup post, feel free point me correct 1 because have not found after hours of searching. i using masterdetail viewcontroller in app, first week or of development, had no additional viewvontrollers or segues other default. wrote main code, , master , detail viewcontroller working perfectly. added vc push segue detail view, app crashes instantly. error : ***terminating app due uncaught exception 'nsinvalidargumentexception', reason '-[uinavigationcontroller setplayer:]: unrecognized selector sent instance ...' , bunch of hex. in appdelegate.m, if comment out line: rightviewcontroller.delegate = rightviewcontroller then app start , push segue work, now, obviously, if select cell in masterview, crash giving error: ***terminating app due uncaught exception 'nsinvalidargumentexception', reason '-[uinavigationcontroller selectedplayer:]: unrecognized selector sent instance ...' , bunch of hex. here of code think

c++ - CGAL Qt linker error -

i have problem compile project cgal , qt in visualstudio 2013. try demo app of polyhedron in cgal demos , after try move scene own qt project. errors like: error lnk2001: unresolved external symbol "public: static struct qmetaobject const cgal::three::viewer_interface::staticmetaobject" (?staticmetaobject@viewer_interface@three@cgal@@2uqmetaobject@@b) ...\scene_polyhedron_item.obj error lnk2001: unresolved external symbol "public: static class qcolor const cgal::three::scene_item::defaultcolor" (?defaultcolor@scene_item@three@cgal@@2vqcolor@@b) ...\scene_polyhedron_item.obj qt: 5.5 cgal: 4.8.beta-1 visualstudio: 2013 x64 linker input : c:\qt\5.5\msvc2013_64\lib\qt5core.lib c:\qt\5.5\msvc2013_64\lib\qt5gui.lib c:\qt\5.5\msvc2013_64\lib\qt5opengl.lib c:\qt\5.5\msvc2013_64\lib\qt5openglextensions.lib c:\qt\5.5\msvc2013_64\lib\qt5widgets.lib c:\qt\5.5\msvc2013_64\lib\qt5svg.lib c:\qt\5.5\msvc2013_64\lib\qt5xml.lib cgal_qt5-vc120-m

objective c - Why does address of self change when execution is in method didMoveToView? -

i have mac osx objective c project has me confused. xcode version 7.3, deployment target 10.11. project, built using ib, nothing more display animated sine wave, , sprite. i'd control speed of wave, , simplicity slow, medium, , fast, selected using radio matrix. there 4 source code files: //appdelegate.h #import <cocoa/cocoa.h> @interface appdelegate : nsobject <nsapplicationdelegate> @property (weak) iboutlet nsmatrix *radioref; @end //appdelegate.m #import "appdelegate.h" #import "sinewave.h" @interface appdelegate () @property (weak) iboutlet nswindow *window; @property (weak) iboutlet skview *skview; @end @implementation appdelegate - (void)applicationdidfinishlaunching:(nsnotification *)anotification { // insert code here initialize application [self.radioref selectcellwithtag:1]; skscene *scene; cgsize size = cgsizemake(360, 216); scene = [sinewave scenewithsize:size]; scene.scalemode = skscene

ios - Disabling Custom Keyboards for Specific Text Fields -

i trying disable user using own keyboards in 1 of text fields. when doing research, found out needed following code disable custom keyboards: func application(application: uiapplication, shouldallowextensionpointidentifier extensionpointidentifier: string) -> bool { if extensionpointidentifier == uiapplicationkeyboardextensionpointidentifier { return false } return true } however, not disable keyboards of text fields. how can apply text field only? thanks!

java - Setting text to multiple TextFields with Asynctasks crashes app -

what want achieve following: in view, have 4 textviews should show amount of items in connected databases. done using simple php script. the problem have correct values database, when try set values textviews, app crashes. i have tried if using many asynctasks problem, when decide comment out line inside settextfortextview() function, works charm , expected values printed log. being said, dont think using multiple asynctasks @ same time problem here, have no idea is. something might worth mentioning when comment out following bit this, app doesn't crash... shoesamount = (textview) findviewbyid(r.id.menutvshoesamount); databasetask taska = new databasetask(shoesamount); taska.execute("getamount", "shoes"); // tshirtsamounts = (textview) findviewbyid(r.id.menutvtshirtsamount); // databasetask taskb = new databasetask(tshirtsamounts); // taskb.execute("getamount", "tshirts"); // //

java - How can I stop scanning a file once array is full? -

i working on java project has method reads file, converts file elements objects, , adds them array. maximum of thirty objects can added array. file assigned has 100 objects in it. whenever try read file, error: java.lang.arrayindexoutofboundsexception: 30 i know error means, don't know how stop scanning file once array limit has been reached. this i've tried far, doesn't seem work: string skip; if(count == max){ skip = scanfile.nextline(); } it better close scanner once have input max: final int max = 30; int count = 0; while(count <= max){ string line = scanner.nextline(); //process line , add array myarray[count++] = //whatever } //close scanner scanner.close(); also remember arrays 0 based index.

ios - Update pkpass file remotely without an app -

i built website store , added coupons it. added link download pkpass file coupon, clients save coupons apple wallet app. have option update card remotely after customers save device (like change coupon text) read it, says can update card if customer saved app , not web. correct? there no way push update coupon if don't have app installed on user's device? there way around it? you need have passkit web service pass register when it's added wallet: https://developer.apple.com/library/ios/documentation/passkit/reference/passkit_webservice/webservice.html updating pass explained in wallet developer guide: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/passkit_pg/updating.html#//apple_ref/doc/uid/tp40012195-ch5-sw1

parallel processing - OpenCL Kernel Error -11 -

i'm new opencl , i'm trying parallelise edge detection program.i'm trying write kernel edge detection function. original function: void edgedetection(float *out, float *in, int w, int h) { int r,c; (r = 0; r < h-2; r++) { (c = 0; c < w-2; c++) { float g; float* pout = &out[r*w + c]; float gx = 0.0; float gy = 0.0; int fr,fc; /* run 2d-convolution filter */ (fr = 0; fr < 3; fr++) { (fc = 0; fc < 3; fc++) { float p = in[(r+fr)*w + (c+fc)]; /* x-directional edges */ gx += p * f[fr*3 + fc]; /* y-directional edges */ gy += p * f[fc*3 + fr]; } } /* edges, pythagoral sum */ g = sqrtf(gx*gx + gy*gy); *pout = g; } } } my opencl kernel: __kernel void edgedetection(__gl

java - MediaRecorder throws exception when setting audio source (android developing) -

i trying build simple app record voice command , send amazon alexa, purpose following tutorial record voice command. following code snippet causes me trouble: import android.app.activity; import android.media.mediaplayer; import android.media.mediarecorder; import android.os.bundle; import android.os.environment; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.button; import android.widget.toast; import java.io.ioexception; public class mainactivity extends activity { button play,stop,record; private mediarecorder myaudiorecorder; private string outputfile = null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); play=(button)findviewbyid(r.id.button3); stop=(button)findviewbyid(r.id.button2); record=(button)findviewbyid(r.id.button); stop.setenabled(false); play.setenabled(false); outpu

assembly - My mips code won't print out the max and min -

my mips code compiles , runs problem doesn't output want to. code supposed find max , min of array of 8 integers. can please take thanks. .data x: .word 1, 2, 3, 4, 5, 6, 7, 8 max: .asciiz "max: " min: .asciiz "min: " space: .asciiz " " .text .globl main main: la $t0, x lw $s0, 0($t0) #sets max first value in array lw $s1, 0($t0) #sets min first value in array addi $t4, $0, 0 #sets counter 0 li $t1, 0 #index array lw $t2, x($t1) lw $t3, x($t1) loop: bge $t0, 8, endloop bgt $t2, $s0, setmax blt $t3, $s1, setmin addi $t1, $t1, 4 addi $t0, $t0, 1 j loop setmax: move $s0, $t2 j loop setmin: move $s1, $t3 j loop endloop: li $v0 4 la $a0 max syscall li $v0 1 la $a0 ($s0) syscall li $v0 4 la $a0 space syscall li $v0 4 la $a0 min syscall li $v0 1 la $a0 ($s1) syscall li $v0 10 syscall the code pri

c - What is the correct behavior of strtol? -

i'm creating wrapper function around strtol() int16_t , , ran across problem: how handle input such 0x ? is, valid digit 0 , followed non-digit x , or invalid because nothing follows 0x ? tl;dr results: windows rejects 0x described in latter case, debian sees digit 0 , followed non-digit character x , explained in former case. implementations tested 1 windows visual c++ 2015 (henceforth msvc) mingw-w64 gcc (5.2.0) debian for further comparison purposes, included sscanf() format specification of " %li" , supposed act strtol() base==0 . surprisingly, ended 2 different results. code: #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { const char *foo = " 0x"; char *remainder; long n; int base = 0; n = strtol(foo, &remainder, base); printf("strtol(): "); if (*remainder == 'x') printf("ok\n"); e

mysql - How often does a character occur in the first position vs the second position of a string? -

i trying answer question: how character occur in first position versus second position of string? using sql query on mysql. however syntax error. the code: select onechar, ascii(onechar) asciival, count(*) cnt, sum(case when pos = 1 1 else 0 end) pos_1, sum(case when pos = 2 1 else 0 end) pos_2 ( (select substring(`city`, 1, 1) onechar, 1 pos `orders` len(`city` >= 1 ) union (select substring(`city`, 2, 1) onechar, 2 pos `orders` len(`city` >= 2) ) group onechar order onechar the error: you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'group onechar order onechar limit 0, 30' @ line 1 tried several ways without success. anyone give me light on problem? the parenthesis incorrect , query missing alias derived table. also, because mysql evaluates booleans 1 or 0 can simplify sum stat

objective c - View-based NSTableView selection? -

Image
i wrote view-based tableview, this: and draw selection nstablerowview, code this: - (void)drawrect:(nsrect)dirtyrect { [[nscolor clearcolor] setfill]; if (self.isclicked) { [[[nscolor blackcolor] colorwithalphacomponent:0.08] setfill]; } nsrect rowviewrect = nsmakerect(0, 0, 274, 72); nsbezierpath *path = [nsbezierpath bezierpathwithrect:rowviewrect]; [path fill]; } but finally, found tablerowview not on tableview, selectedcolor not cover image , button, more background color, need selected tablerowview cover view, this: the selected color cover image , button. have googled, not found ideas. help~ so bit tricky. strategy have overlay colored view alpha less 1 in nstablecellview , add , remove based on cell's selection. first , need nsview can set background color: nsview_background.h @interface nsview_background : nsview @property (nonatomic, strong) nscolor *background; @end nsview_background.m #import "nsview_background.h&qu

knn in R: 'train' and 'class' have different lengths -

i trying build knn model in r, have cleaned data , got rid off outlier , normalized numeri values. however, when try run comes : "error in knn(train = x_train, test = x_test, cl = x_train_target, k = 57) : 'train' , 'class' have different lengths". any or comments appreciated. thank you! #eliminating na's nrow(d0[!complete.cases(d0),]) #which gave me 35 rows na's d0 <- na.omit(d0) nrow(d0[!complete.cases(d0),]) #dealing outliiers d0 <- subset(d0, night.mins > 0) d0 <-subset(d0, night.mins <350) #normalization churn <- d0$churn. d0$area.code <- null #excluding d0$state <- null d0$churn. <- null d0$phone <- null d0$vmail.plan <-null d0$int.l.plan <- null x_1 <- d0 normalizer<- function(x) { return( (x-min(x))/(max(x)-min(x)) ) } x_1 <- as.data.frame(lapply(x[,c(1:15)], normalizer)) x_1$churn. <- churn set.seed(9850)#mixer y <- runif(nrow(x)) x_1 <- x_1[order(y),]#mi

python - How to select certain columns from a csv file in pyspark based on the list of index of columns and then determine their distinct lengths -

i have code in pyspark in pass index value of columns list . want select columns csv file these corresponding indexes: def ml_test(input_col_index): sc = sparkcontext(master='local', appname='test') inputdata = sc.textfile('hdfs://localhost:/dir1').zipwithindex().filter(lambda (line, rownum): rownum >= 0).map(lambda (line, rownum): line) if __name__ == '__main__': input_col_index = sys.argv[1] # example - ['1','2','3','4'] ml_test(input_col_index) now if have static or hardcoded set of columns want select above csv file, can here indexes of desired columns being passed parameter. have calculate distinct length of each of selected columns know can done colmn_1 = input_data.map(lambda x: x[0]).distinct().collect() how do set of columns not pre-known , determined based on index list passed @ runtime? note: have calculate distinct length of columns because have pass length parameter pys

Java can not connect to Server Socket -

i have multi threaded server socket running on 1 computer running follows: static void createserver() throws ioexception { //use ip other user system.out.println(inetaddress.getlocalhost()); // establish server socket try { serversocket s = new serversocket(8888); while (true) { socket incoming = s.accept(); runnable r = new threadedechohandler(incoming, map); thread t = new thread(r); t.start(); } } catch (ioexception e) { e.printstacktrace(); } } } then computer try connect server(using ip first computer 192.168.162.1) follows: public void registercmnd(scanner keys) throws ioexception { inetaddress ip = inetaddress.getbyname("first computer ip"); try (socket s = new socket(ip, 8888)) { ..... ..... } } i getting java.net.connectexception. exception in thread "main" java.net.connectexception: connection timed out: conne

javascript - how to change textbox value from ng repeat -

i make own autocomplete in html , use ng-repeat show suggestion. code: <div content-for="title"> <span>add friend</span> </div> <div class="scrollable"> <div class="scrollable-content"> <div class="list-group"> <div class="list-group-item"> <form class="form-inline" role="form"> <div class="form-group"> <label class="sr-only" for="exampleinputemail2">email</label> <input type="text" class="form-control" data-ng-model="add.email" id="exampleinputemail2" placeholder="email" auto-complete autocomplete="off"/> <div href="#" ng-repeat="x in cobas | filter:add.email"> <div class="media-body" ng-if=

jersey 2.0 - jersey2 unable to return response object -

i'm using dropwizard , jersey2 rest client , javax.ws.rs.badrequestexception: http 400 bad request however, when turn on logging see debug [2016-04-25 05:17:10,196] org.apache.http.wire: http-outgoing-0 << "{"apiversion":"v1","timestamp":"april 24, 2016, 10:17 pm","error":{"asierrorcode":"12002","message":"a message","moreinfo":"http:\/\/bar.foo.net"}}" info [2016-04-25 05:17:10,197] unknown.jul.logger: 1 * client response received on thread main 1 < 400 1 < access-control-allow-headers: accept, content-type, authorization 1 < access-control-allow-methods: get, post, put, delete 1 < access-control-allow-origin: * 1 < allow: options,get,post,put,delete 1 < cache-control: no-cache, no-store, must-revalidate 1 < connection: close 1 < content-length: 265 1 < content-type: application/json 1 < date: mon, 25 apr 2016 05:17:

Ionic/Cordova: How to debug JavaScript codes that require "cordova.js" library in a web-browser -

i developing app androind using ionic framework. app uses cordova medila plugin , use need include: <script src="cordova.js"></script> in html code. required able run code on android, there not cordova.js in www directory , ionic finds in 1 of subfolders when wants build android. i need debug code , want run javascript line line in chrome, becuase chrome cannot find cordova.js , gives error (like "gap_init:2"). i tried find copy of cordova.js in sub-folder of app belongs android platform , copy www\js folder when tried run html code got strange errors during loading of html file. my question is: possible debug these applications in chrome? if how? if not, there ides or tools can used debug? try link chorme inspect, used debug android apps https://developers.google.com/web/tools/chrome-devtools/debug/remote-debugging/remote-debugging?hl=en

swift func: i can't understand underscore as a parameter name that can compile -

how use underscore parameter func test(currentname name: string, _: int) { print("aa\(name) abc"); //how use _ parameter? } test(currentname:"aa", 3) _ means when call test function, don't have write text before second parameter test(currentname:"aa", 3) if declare function this: func test(currentname name: string, secondparameter: int) { print("aa\(name) abc"); //how use _ parameter? } then when call test function, must call this: test(currentname:"aa", secondparameter: 3)

javascript - AngularJs Datatables not able to iterate columns on html using ng-repeat -

hi working on angularjs datatables , trying iterate columns , rows using ng-repeat not working. checked document not able find exact way pass columns , records on html. function customelementctrl(dtoptionsbuilder, dtcolumnbuilder) { var vm = this; vm.dtoptions = dtoptionsbuilder.fromsource('data.json') .withdom('&lt;"custom-element"&gt;pitrfl'); vm.dtcolumns = [ dtcolumnbuilder.newcolumn('id').withtitle('id'), dtcolumnbuilder.newcolumn('firstname').withtitle('first name'), dtcolumnbuilder.newcolumn('lastname').withtitle('last name').notvisible() ]; } here dtcolumns manually created , dtoptions directly assigned json, want assign columns json. , why can't use ng-repeat on html iterate both columns , rows rather <table datatable="" dt-options="showcase.dto

java - Incorrect output after converting to SqlDate -

this question has answer here: convert date string using simpledateformat 5 answers import java.text.parseexception; import java.text.simpledateformat; import java.util.date; public class test { /** * @param args */ public static void main(string[] args) { simpledateformat formatter = new simpledateformat("yyyy-mm-dd"); string dateinstring = "2016-04-23"; try { date date = formatter.parse(dateinstring); java.sql.date sqldate = new java.sql.date(date.gettime()); system.out.println("date: -- "+date); system.out.println("formatterdate : -- "+formatter.format(date)); system.out.println("sqldate : -- "+sqldate); } catch (parseexception e) { e.printstacktrace(); } } } output : date

javascript - how to individual box minimize after append function creation -

i have chat boxes.after box creation.how minimize individual boxes $(document).ready(function(){ $("a").click(function(){ var name = $(this).html(); var user ='<div id="mainchat"><button id="min"> min</button><br>'+name+'</div>'; $("#demo1").append(user); return false; }); }); // minimize individual box $(document).on('click', '#min', function(){ $(this).find("#mainchat").toggle(700);// not working. //$("#mainchat").toggle(700) applied code,first box minimized. }); #mainchat { position :relative; float:left; top:10px; left:50px; margin right:10px; height:250px; width:100px; border:1px solid red; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <a href="#">first</a><br> <a href="#&q

angularjs - Angular ui-grid: bootstrap dropdown in cell -

i have agular ui-grid , dropdowns in cells. why dropdown doesn't show on click? var columndefs1 = [ { name: 'firstname'}, { name: 'lastname'}, { name: 'company'}, { name: 'employed'}, { name: '#', celltemplate: '<div class="dropdown">' + '<button class="btn btn-default dropdown-toggle" type="button" id="dropdownmenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">' + 'dropdown' + '<span class="caret"></span>' + '</button>' + '<ul class="dropdown-menu" aria-labelledby="dropdownmenu1">' + '<li><a href="#">action</a></li>' + '<li><a href="#">another action</a&g

node.js - Why this port number is not acceptable for my localhost server? -

i have hapi.js code below: ` 'use strict'; const hapi = require("hapi"); const server = new hapi.server(); server.connection({ host: 'localhost', port: 2922, }); server.route({ method: 'get', path: '/hello', handler: function (req, res) { res('hello world hapi.js'); } }); server.start((err) => { }); ` problem when run server port number 22291 executes , exit without error, reason for? using linux centos 7 you need check error in start callback: server.start((err) => { if (err) throw err; }); that give details need debug. make sure check errors in callbacks or you'll repeatedly run problem in node.

java - Importing StaggeredGridView library - Parcel.CreateIntArry() not applicable for Parcel.CreateIntArry(int[]) error -

i've been trying import staggeredgridview library in eclipse. works fine except error in staggeredgridview.java . in following method of class private savedstate(parcel in) { super(in); firstid = in.readlong(); position = in.readint(); in.createintarray(topoffsets); //error here in.readtypedlist(mapping, colmap.creator); } eclipse shows error the method createintarray() in type parcel not applicable arguments (int[]) any suggestions how rid of error? the error showing because parcel class not define createintarray(int[]) method takes parameter. there 2 options: createintarray() (without parameter) readintarray(int[]) based on commit that's causing compile error , used readintarray(int[]) . i'm not sure why changed in first place, seems related staggeredgridview not being restored properly. time being, may want change how before, , keep eye out new commits git repo.

managementeventwatcher - How do I get newly inserted USB drive letter in c#? -

i wrote c# program find newly inserted usb drive , drive letter. when run program got insertion event , couldn't drive letter. can suggest me idea this? code static void main(string[] args) { managementeventwatcher mwe_creation; //object creation 'managementeventwatcher' class used listen temporary system event notofications based on specific query. wqleventquery q_creation = new wqleventquery(); //represents wmi(windows management instrumentation) event query in wql format more information goto www.en.wikipedia.org/wiki/wql q_creation.eventclassname = "__instancecreationevent";// sets eventclass query q_creation.withininterval = new timespan(0, 0, 2); // setting time interval event check(here, 2 seconds) q_creation.condition = @"targetinstance isa 'win32_diskdrivetodiskpartition'"; //sets kind of event notified mwe_creation = new managementeventwatcher(q_creation); //initializing new instance mwe_creation

android - Set Vector Drawable in ImageView cause app crash in old SDK -

i used vector drawable in image src this: <imageview android:id="@+id/issold" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_vertical" android:visibility="gone" app:srccompat="@drawable/ic_soldout_24px" tools:ignore="missingprefix"/> i added these manifest: defaultconfig { vectordrawables.usesupportlibrary=true } and used compile 'com.android.support:appcompat-v7:23.2.1' but app crashes in old sdk message of error inflating class imageview use android.support.v7.widget.appcompatimageview instead of imageview: <android.support.v7.widget.appcompatimageview android:id="@+id/issold" android:layout_width="match_parent" android:layout_height="match_parent"

datatable - How to remove complete row from a data table when it is a duplicate row in c# -

i have data table has duplicate row follow. | | | | | | |cid | usrnme | pname | prate | cabin | |-----------------------------------------------------------| |c11 | demo1@gmail.com | sample1 | 2000 | b2 | ******* |c14 | demo2@live.com | sample2 | 5000 | b3 | |c15 | demo3@yahoo.com | sample3 | 8000 | b2 | |c11 | demo1@gmail.com | sample1 | 2000 | b2 | ******* |c18 | demo4@gmail.com | sample4 | 3000 | l1 | |c11 | demo5@gmail.com | sample5 | 7400 | b4 | &&&&&&& ============================================================ note : there different data same id ,see &&&&&&& row how 1 row above duplicate 2 rows.i have tried this this code used. public datatable removeduplicaterows(datatable dtable,string colname) { colname = "cabin"; hashtable h

vba - Update Access database through Excel sheet -

i trying update table in access through code shows error message "user define type not define". how solve problem? enter code here sub updateclick() dim conn adodb.connection dim myrecordset adodb.recordset dim strconn string dim s string set s = "c:\users\pc2\documents\database2.accdb" strconn = "provider=microsoft.jet.oledb.4.0 data source=s" set strconn = new adodb.connection set myrecordset = new adodb.recordset myrecordset .open "select * personinformation", strconn, adopenkeyset, adlockoptimistic .fields("id").value = worksheets("sheet1").range("a2").value .fields("fname").value = worksheets("sheet1").range("b2").value .fields("lname").value = worksheets("sheet1").range("c2").value .fields("address").value = worksheets("sheet1").range("d2").value .fields(&

Images not served in production via image_tag in Rails 4 -

i deployed app production , noticed images not served image_tag, served if use asset_path. have images under app/assets/images. on production precompile them in public/assets , have names such 'image_name-fk3r23039423-0e9232.png'. when @ html code generated see image_tag's src /images/logo while asset_path generates this: /assets/login-bg1-01eead5b47afcb7e0a951a3668ec3921e8df3f4507f70599f1b84d5efc971855.jpg so correct. interested why can not serve images using image_tag 'image-name'? here production.rb config.serve_static_files = true config.assets.compile = false config.assets.digest = true i resolved adding extension file. i.e did this: <%= image_tag 'logo.png'%> # added .png i don't know why didn't worked without extension in development. suppose logo image served application assets, not public.

node.js - run shell script on client remotly from server -

i have 1 server , multiple clients. server wants run shell script on each device wants to. absolutely it's not possible via simple socket because may have thousands of devices. server , devices should connected via socket. after lot of search found out solution might nat-t. still don't know how use or if there solution. please me should on clients , server. if don't know clients address , port upfront, need connect server clients. 1000s of devices no problem. run in socket limit around 65000 open ports (check ulimit ). build object stream between client , server , execute script based on object client receives. set interval on clients , let them check simple http(s) every n secs if there them? see example here: node stream docs or here: node http docs

javascript - Asynchronous POST shows Unexpected token n -

i posting data via jquery $.ajax() call so: var data = {}; data.name = $("#name").val(); data.email = $("#email").val(); data.message = $("#message").val(); $.ajax({ type: "post", url: "http://myhost/contact/sendemail", data: data, contenttype: "application/json", datatype: "json", success: function (data) { console.log("success"); } }); which getting routed contactroutes.js : contactrouter.route("/sendemail").post(contactcontroller.sendemail); to controller supposed pull body of request make api call , send email message. sendemail: var sendemail = function(req, res) { var payload = { to: req.body.email, from: "noreply@test.com", subject: req.body.name, text: req.body.message }; ...omitted brevity }; the error continue receive syntaxerror: unexpected token n in body-parser module. ha

redirect - Own page keeps redirecting to other site. How to solve? -

my website's homepage keeps redirecting other website, odd because didn't make happen. checked index.html , clean. can be? site redirected site, of course don't want happen. i hope can me out. ps: don't believe hacked, because referred site. i using wordpress btw. alright. how odd might , might sound, google's adsense banners causing redirection. had set " show banners of site " via adsense if there no ads... removed ad sidebar , not redirecting anymore. damn it.

Parsing JSON-file with Python in Django -

i have query fetch json-file , want show data in table in html. error: typeerror: string indices must integers in line: 'status': item['status'],. problem outer brackets, because missing in json or what? views.py code json_obj = urllib2.urlopen(url) data = json.load(json_obj) results = [] item in data: results.append({ 'status': item['status'], 'device': item['device'], }) return render(request, 'index/index.html', {'objects_list': results}) json-file: { “version": “3.62”, "treesize": 2, "": [ { “status”: “up”, "device": “somedevicename1”, } { “status”: “up”, "device": “somedevicename2”, }] } i don't know whether accidentally copied json content wrong or not should is: >>> item in data[""]: ... results.append({ ...

PHP PayPal REST API: display item descriptions if applicable -

i have below create payment paypal script, wanted of items variations able set setdescription(); if any, currently items show same description (variations) below script: foreach($_session['products'] $key => $cart_itm) { $keys = array_keys($cart_itm); $matches = preg_grep('~^p_alt\-variation\-\d+~i', $keys); //show variations if if(count($matches) > 1) { foreach($matches $matched_key) { $variations[] = $cart_itm[$matched_key]; } } $subtotal = $cart_itm['p_price'] * $cart_itm['p_qty']; $item[$key] = new item(); $item[$key]->setname($cart_itm['p_name']) ->setcurrency(paypal_currency) ->setquantity($cart_itm['p_qty']) ->setdescription(implode(' / ', $variations)) ->setprice($cart_itm['p_price']); $items[] = $item[$key]; $customdata[] = $cart_itm['p_id'].':'.$cart

python - How to use conditional operator or_ in sqlalchemy with conditional if? -

existing code snippet: if sup_usr_only: query_ob = query_ob.filter( or_( and_( department.id.in_(login_user.department_ids), # logic ok - checked. model.visibility == visible_dept ), and_( model.visibility == visible_company, model.company_id == login_user.company_id )) ) else: query_ob = query_ob.filter( or_( and_( department.id.in_(login_user.department_ids), # logic ok - checked. model.visibility == visible_dept ), model.visibility == visible_global, and_( model.visibility == visible_company, model.company_id == login_user.company_id )) ) if there way can minimize code snippet in line if check or other optimization? want make below (which syntactically wrong): query_ob = query_ob.filter( or_(

php - Fixing errors in sql statement -

Image
i have 3 tables of queried first table (users) result: $string_users='19,20,21,22,25,26,27,28,29,30,31,32,33,34'; and want filter through 2 other tables friends , freinds_request , remove ids in numbers cud later poor understanding returns error: warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\cebs\include\functions.php on line 825 i tried run query sql command - phpmyadmin see wrong: select id users id not in (select user_one,user_two friends (user_one='18' , user_two in('19,20,21,22,25,26,27,28,29,30,31,32,33,34')) or (user_one in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') , user_two='18')) , id not in( select to_user,from_user friend_reqest (to_user='18' , from_user in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') or (to_user in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') , from_user='18')) )

layout - ScrollView issue Android -

<horizontalscrollview android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:scrollbars="none"> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleline="true" android:text="" android:layout_gravity="right" android:gravity="right|center_vertical" android:textcolor="#666666" android:textsize="30sp" /> </horizontalscrollview> hi, want text inside textview scrollable when fills space available. text inserted right, beginning of text disappears on left. when becames scrollable can scroll amount of space equal space of text that's not displayed scrolls right side, textview empty , can't reach i've typed before. suggestions? sorry poor english. wish it's clear enough... (the sc

linux - Debian - How to analyse memory/disk usage issue -

for internal usage, have 1 little server powered debian apache+mysql running. last saaturday, had issue detected employees, server doesn't respond. i able log in in ssh , see memory full, , munin logs hard disk have uncommon read usage. i restarted apache & mysql , gone normal activity. i don't know today reason of issue. process have saturated hard disk... any idea can found usefull information ? thank ! best regards memory usage in kb or mb: free or free -m disk usage in human readable values: df -h a list of files , folders in or specific directory sorted size: du /folder/path | sort -n

jsf - how to update primeface datatable using poll with updated toggled columns -

i've been working on jsf project(using primefaces 5.2). i've datatable gets updated using poll in every 10 seconds.i have column toggler. working fine problem when poll updates datatable again adds columns table.is there way restrict datatable show selected toggled columns after poll update. here xhtml code <h:form rendered="#{bean.value!=null}" > <p:datatable id="tab" var="var" value="#{bean.value}" > <f:facet name="header"> header datatable <p:commandbutton style="float:right" id="toggler" type="button" value="columns" icon="ui-icon-calculator" /> <p:columntoggler datasource="tab" trigger="toggler" /> </f:facet> <p:column> <f:facet name="header"&g