Posts

Showing posts from September, 2015

c# - Property will not serialize as XML attribute -

i attempting serialize class xml , have properties serialized attributes of class, rather nested node. using webapi automatically handle serialization of xml. this class: [datacontract (namespace="", name="attributetest")] [serializable] public class attributetestclass { [xmlattribute("property")] [datamember] public int property1 { get; set; } } here output receiving (note property1 not attribute in spite of being decorated [xmlattribute] ): <attributetest xmlns:i="http://www.w3.org/2001/xmlschema-instance"> <property1>123</property1> </attributetest> this output want receive: <attributetest property1="123" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> </attributetest> what missing? i'm not familiar webapi output receive looks it's serialized using datacontractserializer , not xmlserializer need. check if adding following application_

How to draw a function curve in android? -

i have function, y = 50sin(x/50) + 100. want draw curve function, without additional info graph plotters, need wave on screen. x should correspond x parameter of screen , y y parameter of screen. here code of current view. public class sinusoid extends view { paint paint = new paint(); public sinusoid(context context) { super(context); paint.setcolor(color.red); } @override public void ondraw(canvas canvas) { //todo draw line using myfunction } private double myfunction(double x){ return 50 * math.sin(x / 50) + 100; } } now question is, should fill in todo? please help, documentation or example useful. thanks in advance. the idea have this: @override public void ondraw(canvas canvas) { (int x=0; x<canvas.getwidth();x++) { canvas.drawpoint(x,(float) myfunction(x),mpaint); } } but you'll need adjust value of function given canvas height.

java - hadoop writables NotSerializableException with Apache Spark API -

spark java application throws notserializableexception on hadoop writables. public final class myapp { public static void main(string[] args) throws exception { if (args.length < 1) { system.err.println("usage: myapp <file>"); system.exit(1); } sparkconf sparkconf = new sparkconf().setappname("myapp").setmaster("local"); javasparkcontext ctx = new javasparkcontext(sparkconf); configuration conf = new configuration(); javapairrdd<longwritable,text> lines = ctx.newapihadoopfile(args[0], textinputformat.class, longwritable.class, text.class, conf); system.out.println( lines.collect().tostring()); ctx.stop(); } . java.io.notserializableexception: org.apache.hadoop.io.longwritable serialization stack: - object not serializable (class: org.apache.hadoop.io.longwritable, value: 15227295) - field (class: scala.tuple2, name: _1, type: class java.lang.object) - object (class

asp.net - Not able to get nJupiter.DataAccess.Ldap work with our Internal LDAP (Lotus Domino) -

i've tried possible, setup njupiter.dataaccess.ldap membership provider on our intranet based web application built using asp.net 3.5. challenges facing: not able authenticate user using default login webpart (says login attempt not successful. please try again) i tried code , receive comexception : "there no such object on server." var ldapmembershipuser = system.web.security.membership.getuser("username") ldapmembershipuser; if (ldapmembershipuser != null) { var givenname = ldapmembershipuser.attributes["givenname"]; } i have placed web.config , njupiter.dataaccess.ldap.config here: web.config : http://pastebin.com/9xddnhuh njupiter.dataaccess.ldap.config : http://pastebin.com/wssehi98 i have tried possible permutations , combinations different values in xml , not able take forward. please guide. not able connec ldap , authenticate user or search users. just looking @ config unlikely enough since don't know dom

html - Diagonally divs filling complete space of parent div -

i'm trying create div relative height , width, in 3 boxes, being diagonally aligned , fill complete space of relative parent div. it's kinda tough me explain, here's picture on how mean it: http://i.imgur.com/s2ustvu.png besides little space between red lines space should covered diagonal boxes. is possible somehow? i'm grateful every advice or tip can shoot me! following code got far. problem i'm stuck how make diagonal divs fill out complete space around them. <div class="parent"> <div class="box-1">box1</div> <div class="box-2">box2</div> <div class="box-3">box3</div> </div> css: .box-1 { -ms-transform: rotate(-10deg); -webkit-transform: rotate(-10deg); transform: rotate(-10deg); width: 100%; margin: 0px 0px 10px 0px; height: 33.33%; } .box-2 { -ms-transform: rotate(-10deg); -webkit-transform: rotate(-10deg); transform: rotate(-10deg);

PHP: Using the ternary operator for something else than assignments – valid use case? -

unfortunately haven't found official resource on this. is allowed use ternary operator this, shorten , if/else statement: (isset($somevar) ? $this->setmyvar('something') : $this->setmyvar('something else')); in php documentation, ternary operator explained example: $action = (empty($_post['action'])) ? 'standard' : $_post['action']; this makes me believe use case might work, not valid because setter function not return anything. yes, can. php doc : [...] ternary operator expression, , [...] doesn't evaluate variable, result of expression. that quoted, although ternary used assigning values, can use suggested because function call expression appropriate function evaluated (and therefore executed). if setter function return value, not assigned , therefore lost. however, since said setter doesn't return anything, whole ternary operator evaluate nothing , return nothing. that's fine. if more

apache - htaccess 404 Stopped Working -

i had custom 404 error redirect page working fine through htaccess. however, after adding new code htaccess, stopped working. what's causing conflict , how can fix it? edit: i've tried putting errordocument line @ top of page , still doesn't work. htaccess code: rewriteengine on #removes www rewritecond %{http_host} ^www\.(.+)$ [nc] rewriterule . http://%1%{request_uri} [r=301,l] #redirects extensionless php urls rewritecond %{the_request} ^[a-z]{3,9}\ /([^&\ ]+).php rewriterule .* /%1? [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ $1.php [l] #redirect nonexistent files 404 page (not working) errordocument 404 /404.html the problem not putting errordocument in top or in bottom of htaccess. you have infinite loop because of rule (the 1 rewriting php extension). need check if exists before rewriting it, otherwise you'll loop conflict between rule , errordocument . you can replace curr

javascript - Update data in mysql with html form inside jquery dialog -

i need in making page can see data mysql query. every row echoed div unique id . <div class="column" id="<?php echo $row['id']; ?>"> it has same id data in mysql database. every div contains edit button: <a href="edit_column.php?id=<?php echo $row['id'] ?>" class="edit">edit</a> after clicking 'edit', jquery script executed: $('.edit').on('click', function() { var url = this.href; var dialog = $("#dialog"); if ($("#dialog").length == 0) { dialog = $('<div id="dialog" style="display:hidden"></div>').appendto('body'); } dialog.load( url, {}, function(responsetext, textstatus, xmlhttprequest) { dialog.dialog(); } );

java - JDBC implementation: error with regard to parameters -

i working on creating jdbc program show list of grades selected student has in respective classes. however, keep getting error "procedure or function 'getstudenthistory' expects parameter '@studentid', not supplied." here stored procedure in sql server: create proc [dbo].[getstudenthistory] @studentid int select lastname, firstname, year, term, c.prefix + ' ' + cast(c.num char(3)) + ' - ' + sec.letter [course number], units, isnull(g.letter, ' ') grade student s inner join studentinsection sis on s.studentid = sis.studentid inner join section sec on sec.sectionid = sis.sectionid inner join course c on c.courseid = sec.courseid left outer join grade g on g.gradeid = sis.gradeid inner join semester sem on sem.semesterid = sec.semesterid s.studentid = @studentid order units desc here function within main class: @suppresswarnings("resource") public static voi

java - Unit Testing a function that takes ActionEvent as a parameter -

how can test function takes "actionevent" type parameter in java/swing? following function want test: public void actionperformed(actionevent e) { // communicating model class // /** if "add" button has been pressed **/ if (e.getactioncommand() == "add") { string cust_name = view.getaddcustnamefield().gettext(); int ph_num = integer.parseint(view.getaddphonenumfield().gettext()); model.addentry(cust_name, ph_num, "controller"); } /** if "delete" button has been pressed **/ else if (e.getactioncommand() == "delete") { string cust_name = view.getdelcustnamefield().gettext(); model.deleteentry(cust_name, "controller"); } /** if "update" button has been pressed **/ else if (e.getactioncommand() == "update") { string cust_name = view.getupdcustnamefield().gettext();

ASP.NET vNext MVC and Entity Framework issues -

i'm trying create little asp.net vnext webapi + angularjs + entity framework project. obviously, lot changed in ef7 experiencing following issues: i changed project.json following: "dependencies": { "microsoft.aspnet.server.iis": "1.0.0-beta1", "entityframework": "7.0.0-beta1", "entityframework.sqlserver": "7.0.0-beta1", "entityframework.commands": "7.0.0-beta1", "microsoft.aspnet.mvc": "6.0.0-beta1", "microsoft.aspnet.diagnostics": "1.0.0-beta1", "microsoft.framework.configurationmodel.json": "1.0.0-beta1" in datacontext class, trying following: using system; using project1.models; using microsoft.data.entity; namespace project1.dataaccess { public class datacontext { public dbset<website> websites { get; set; } public datacontext() { microso

Java Self-Programmed Singly-Linked-List in Linked-List -

at least me, have tricky exercise university. task program singly-linked-list kind of methods. far easy, challenge store these singly-linked-lists afterwards in linked-list. in following see implementation of singly-linked-list runs smoothly: public class liste { listenelement first; listenelement last; listenelement current; int count; public liste() { first = null; last = null; current = null; count = 0; } // methods... the single-linked list consists of list elements implemented in following: public class listenelement { string content; listenelement next; public listenelement(string content, listenelement next) { this.content = content; this.next = next; } //methods... here problem: linkedlist<liste> zeilen = new linkedlist<>(); liste zeile1 = new liste(); liste zeile2 = new liste(); zeile1.addbehind("hello"); zeile1.addbehind("world"); zeile2.addbehind("hello"); zeile2.addbehind("world"

php - PDO + Angular: how to reconcile DB underscore_case with Angular's camelCase? -

i have angularjs app connects database using php pdo apis. this schematic data flow: db: create table person ( ... first_name, ... ); php api: $stmt = $this->db->prepare("select * person"); $stmt->execute(); $result = $stmt->fetchall(pdo::fetch_assoc); var_dump($result); ... 'first_name' => 'alice', ... angular service: getperson: function (id) { return $http({ method: 'get', url: apiuri + 'get' + '/' + id, }).then(handlesuccess, handleerror); }, angular controller: person.getperson(id).then(function(person) { var name = person.first_name; // throws jslint warning }); the problem sql recommended naming standard underscore_case, while angular's camelcase... i not disable jslint, useful, in other respects... i know avoid warnings with { "camelcase": false } in .jshintrc, i'd prefer not disable camelcase check globally...

Customize Laravel Homestead server settings? -

is possible use laravel homestead , change of settings of server created? for example, perhaps want different version of php,mysql or ubuntu. i looked through homestead source couldn't see these defined. the laravel/homestead virtual machine (hosted on vagrant cloud) built of below pre-installed: php 5.6 hhvm nginx mysql postgres node (with bower, grunt, , gulp) redis memcached beanstalkd laravel envoy blackfire profiler this stop need complex , lengthy provisioning process prior vm being usable. you have few options achieve want: (recommended option) add own bash scripts homesteads after.sh remove / add software required. downside script run on every vagrant up , need check first if package want install installed. add own provisioning homestead vagrant file. if follow route, i'd recommend fork homestead project on github , use fork changes. can in provisioner can in shell of vm. example latest version of php source , configure &&

Oracle database export missing tables -

i've exported instance of oracle 11g database (full) without shutting down find there 400+ tables missing (were not exported). database used application , possibly had users on it. the command used exp system@db1 full=y file="c:\backup.dmp" grants=y rows=y log="c:\backup.log" would not shutting down before exporting make skip these tables? exp not understand deferred segment creation , may not include these tables: select owner, table_name dba_tables segment_created = 'no' order 1, 2; have tried expdp instead? exp deprecated in 10g, although there bugs new tool , workaround use exp . if need use exp may need run command on tables: alter table unexported_table allocate extent;

Android Studio app using Django back-end login authentication? -

i've been working on android app using android studio using django backend. web application in place want make app in android it. the problem running in to, because i'm new app development, login authentication. i've researched on topic here , understand theoretically how should go doing this, have not been successful in logging in app. the problem have this: i csrf token authentication failure. states cookie not set. understand post request return this. i getting success transition in dopost method. i lost in how check if have logged in or not. , solution thought of cookie not being set request, parse cookie string , pass in post request. i'm not sold on being best strategy. bigger problem not being able tell if have logged in or not. how can check that? have read posts on kind of explaining how beginner hard translate code. how check if user authenticated? , appreciated. public class userlogintask extends asynctask<void, void, boolean> { p

shell - Execute python script while open terminal -

i want this: execute python script while open terminal (i using iterm , fish-shell ). the fish-shell new me, read documentation - recommend. title " initialisation files ": http://fishshell.com/docs/current/index.html#initialization so looked call python scripts ~/.config/fish/config.fish so installed fish on macbook , had create config.fish file. in placed: ~/gash.py that executes python program gash.py in home directory. of course #! line has correct , have have execute permissions (as usual). entered fish shell , executed program. thanks that, fish-shell looks quite interesting. love stackoverflow.

cs-cart admin user login always act as vendor profile Issue -

Image
i face 1 issue , not found solution through cs-cart community - when login admin area admin url https://demo.com/admin.php , enter correct authentication infromation , click on login act vendor not admin means after login screen same vendor screen , cant access admin features. after login url same admin url act vendor instead of admin. double check database user settings , correct also. admin user_type 'a' , enabled also. cant trace issue server file side. is ssl issue? contribution please check if have vendor selected already, on top left, right side of admin logo, should have vendors ;)

c - Benchmarking functions -

i've written c code - below - have benchmark of functions. main purpose of benchmark test these functions on avr @ tiny85, on pc (for i'm using atmega168 instead of @ tiny85 - same). this benchmark executes big number of loops each function has test , "void" function receives same parameters of function tested, executes return. @ end of loops of each functions writes label , time expressed in usec. time duration of loops function specified label. i might think if subtract benchmark time of "void" function benchmark time of function tested , divide result number of loops, i've sufficient information duration of function tested. not true because interrupts (even measure time). in case think benchmark able indicate me fastest function. what's opinion? have suggestion about? here output example: void 2110168 norm 2121500 base 2337196 basl 2450964 basw 2333980 ant4 2235236 ant5 2242904 unro 2270484 unrl 2590444 vect 2754188 vesw 2732472 th

ruby - Multiply all even indexed integers by two -

wanting take fixnum of integers , multiply even(indexed) integers two. figured best way first turn fixnum array. lets following number of 16 digits: = 4408041234567901 i know could: a.to_s.split('') which return 'a' array of 'stringed' numbers. cant follow with: a.map!.with_index {|i,n| i.even? n*2} guess i'm kinda stuck on how create method this. question may how turn group of numbers array of fixnums/integers instead of strings. to change array, do a = 4408041234567901 arr = a.to_s.chars.map(&:to_i) # => [4, 4, 0, 8, 0, 4, 1, 2, 3, 4, 5, 6, 7, 9, 0, 1] you can multiply alternate numbers 2 arr = a.to_s.chars.map.with_index {|n,i| i.even? ? n.to_i * 2 : n.to_i } # => [8, 4, 0, 8, 0, 4, 2, 2, 6, 4, 10, 6, 14, 9, 0, 1] improving little bit, can use hash find number multiplied. h = {true => 2, false => 1} a.to_s.each_char.map.with_index {|n,i| n.to_i * h[i.even?]} edit i can explain each step, better if can

c++ - libgcc_s_sjlj-1 missing from compiled file in MinGW C++11 -

i using latest version of mingw on windows 7. have written code in sfml, , when tried compile , execute it, gives me error saying missing libgcc_s_sjlj-1. have checked place out , added -static-libgcc command line, still doesn't work. ideas? here batch file compiles , runs code. @echo off @echo calibrating... g++ -o sfmltest main.cpp -std=c++11 -static-libgcc -lsfml-system -lsfml-window -lsfml-graphics @echo finished! running... .\sfmltest edit: after removing files , starting again scratch, issue still persists. can of help?

ios - String not convertible to [AnyObject] -

Image
i have string declared var searchstring = "" i trying parse query shown below: query?.wherekey("username", containedin: searchstring) what issue? this in xcode 6.3 updated , swift 1.2. the function expects array of anyobjects, supply string. wrap string in array... query?.wherekey("username", containedin: [searchstring])

ios - How to get a button to stay on the right in a cell for all sizes? -

Image
i trying add custom checkbox button ( https://codereview.stackexchange.com/questions/69123/ibdesignable-uicheckbox ) prototype table view cell in storyboard. here album ending starting how looks on 3 iphone sizes , ending picture of interface builder: http://imgur.com/d6ejxel,9npqcna,4gdlnmt,g24fyid#0 how checkbox appear on iphone 6 on 3 sizes? in advance. you should add auto layout constraints. in storyboards, can add auto layout make button stay on right this: i used switch demonstrate. 1) select "button". 2) click icon on bottom circled in red. 3) constrain space between superview (the content view) , "button". you can add different constraints top or left spacing. 4) click "add # constraints"

c# - Entity Framework:Why the collection type of entity class need to be instanced in the default constructor? -

i using visual studio build code first model of northwind database automatically. have questions. i found if entity class has collection, collection instantiated in default constructor. why need that? the icollection<t> instantiated hashset<t> in default constructor. why hashset<t> used? can use list<t> or else? why navigation property @ one side (one many relation) icollection<t> , virtual ? to implement entity class in way mention above, think there must benefits can brought. can tell me why? public partial class orders { public orders() { order_details = new hashset<order_details>(); } public virtual icollection<order_details> order_details { get; set; } } i found if entity class has collection, collection instantiated in default constructor. why need that? you don't. needs instantiated before start adding stuff it. the icollection instantiated hashset in default construc

r - Error in model.frame.default for Predict() - "Factor has new levels" - For a Char Variable -

i have dataset split test/train datasets. following split produced logistic model with: logmodel1 = glm(y ~ . -var1 -var2 -var3, data=train, family=binomial) if use model make predictions on same train set, no error (though of course not-super-useful test of model). used code below predict on test set: predictlog1 <- predict(logmodel1, type="response", newdata=test) but following error: error in model.frame.default(terms, newdata, na.action = na.action, xlev = object$xlevels) : factor mycharvar has new levels observation of mycharvar, another... here's what's got me particularly confused: mycharvar character variable in both train , test sets. i've confirmed str(test$mycharvar) , str(train$mycharvar) my model not use mycharvar part of prediction. i found explanation bullet 2 @ link: "factor has new levels" error variable i'm not using and suggestion there remove character variables altogether train , test sets

python - Numpy sum running length of non-zero values -

looking fast vectorized function returns rolling number of consecutive non-zero values. count should start on @ 0 whenever encountering zero. result should have same shape input array. given array this: x = np.array([2.3, 1.2, 4.1 , 0.0, 0.0, 5.3, 0, 1.2, 3.1]) the function should return this: array([1, 2, 3, 0, 0, 1, 0, 1, 2]) this post lists vectorized approach consists of 2 steps: initialize zeros vector of same size input vector, x , set ones @ places corresponding non-zeros of x . next up, in vector, need put minus of runlengths of each island right after ending/stop positions each "island". intention use cumsum again later on, result in sequential numbers "islands" , zeros elsewhere. here's implementation - import numpy np #append zeros @ start , end of input array, x xa = np.hstack([[0],x,[0]]) # array of ones , zeros, ones nonzeros of x , zeros elsewhere xa1 =(xa!=0)+0 # find consecutive differences on xa1 xadf = np.diff

apache - Accessing WAMP Server From External IP Address -

i'm experimenting setting site on wamp server hold personal information. because isp blocks port 80, i've had change apache's default port 80 25565 (i believe i've left port 80 operable in case, though). of has gone well, able access server typing in "localhost" or "localhost:25565" google chrome. however, when using external ip address, variety of errors, namely "connection timed out". in general queries made in format "xxx.xx.xx.x:25565" or "xxx.xx.xx.x", substituting own external ip. port forwarded (i've checked http://canyouseeme.org several times) , mentioned, site working correctly localhost. i running latest version of wordpress on site , using wordpress homepage index.php (replacing wamp default). attaching segments of httpd-vhosts.conf , httpd.conf modified wamp defaults in case part of issue. in advance. update: able discover still problem port 80. apparently server still trying send final data o

javascript - AngularJS - Problems displaying data between views -

i'm working on simple angular app has 'posts', , 'comments' associated posts. i have 2 views: 'home', , 'posts'. so example: create post through main view try view specific post , comments through 'posts/{id}' i'm having problems trying transfer data between home , posts view. have of views in 'static' directory, , i'm not getting console errors, i'm not sure problem is. app.js angular.module('flappernews', ['ui.router']) // set routing/configuration // ------------------------------ .config(['$stateprovider', '$urlrouterprovider', // set state providers function($stateprovider, $urlrouterprovider) {$stateprovider // home state .state('home', { url: '/home', templateurl: '/static/home.html', controller: 'mainctrl' }) // posts state .state('posts', {

android - Fragment not added to activity when method is called -

i have main activity called chessboard. within chessboard, in oncreate, set fragment activity gameinfofragment. after this, call made query sqlite database, after method in class sqlitedatainterpreter called. here, call made method in gameinfofragment class, imageviews in fragment set in chessboard's oncreate should populated. when attempt start chessboard activity, receive following error: caused by: java.lang.illegalstateexception: fragment gameinfofragment{2ef389d9 id=0x7f09008d infotest} not attached activity the code in chessboard's oncreate following: fragmentmanager manager = this.getfragmentmanager(); fragmenttransaction transaction = manager.begintransaction(); if (chessboard.movecounter % 2 == 0) { transaction.add(com.zlaporta.chessgame.r.id.game_play_screen, gameinfo, "infotest"); } else { transaction.add(com.zlaporta.chessgame.r.id.game_play_black_screen, gameinfo, "infotestblack");

python - Why is scipy.optimize.minimize trying to pass in weird arguments to my objective function? -

i have class helps instantiate statistical model. of data members parameters. trying write method optimizes these parameters. objection function based on negative of likelihood function. likelihood function implemented class method, uses values of class data members in calculation. i know bad style, every time objective function gets called scipy.optimize.minimize() , changes objects data members better ones. less concerned why bad, , more concerned why isn't working. below code full traceback. it seems works partially. runs few seconds on test data, triggers assertion. seems minimize() weird when it's nearing end of optimizations. why try pass in different types of arguments objective function obj_fun() ? in ipython interpreter check object's parameters afterwards, , seems arriving @ expected result. i tried looking through of source of scipy. it's confusing, though. there lot of ambiguous variable naming , function wrapping. can give me color on why happeni

Python - Pandas — How to check which column a DataFrame is grouped by? -

imagine have function outputs grouped dataframe. want find out column dataframe grouped. how can this? edit: here's code: from pandas import dataframe df = dataframe({'a' : [0, 1, 2], 'b' : [1, 6, 5], 'c' : [2, 5, 4] } ) grp = df.groupby('a') the question how determine grp grouped a. below, john-galt gives extremely helpful answer. however, i've found 1 case it's not how apply solution: using custom grouping function. edit 2: never mind, case not thought was. question has been answered. you use grp.grouper.names like, datframe in [47]: df out[47]: b c 0 0 1 2 1 1 6 5 grp grouped object in [48]: grp = df.groupby('a') use grouper.names column names. in [49]: grp.grouper.names out[49]: ['a'] also, grp.grouper object has lot of other useful metadata, may find useful in [50]: grp.grouper. grp.grouper.agg_series grp.grou

c++ - Failed to linking bost_thread on solaris studio -

i'm trying compile , run simple example of boost thread (see code below), when i'm trying run program "segmentation fault (core dumped)". compile dan run program in other environments, on these succeeded (os x, linux), problem in solaris. don't know happening, me figure out problem? command compile it -bash-3.00$ cc -m64 -l/export/home/ulcm/standalone/lib -lboost_thread -pthreads -dc7_q -d_reentrant -i/export/home/ulcm/standalone/include -o main main.cpp cc: warning: option -pthreads passed ld, if ld invoked, ignored otherwise when trying run -bash-3.00$ ./main segmentation fault (core dumped) boost version 1.48.0 mdb output -bash-3.00$ mdb ./main ./core loading modules: [ ld.so.1 libc.so.1 ] > ::status debugging core file of main (64-bit) sgdev0 file: main initial argv: ./main threading model: multi-threaded status: process terminated sigsegv (segmentation fault) > > ::stack libc.so.1`memcpy+0x1880() libcstd.so.1`__1cdstdmbasic_strin

ruby - create method adding 2 values and assigning to to an attribute in rails table -

i trying previous balance of row , add variable add params input value , assign specific column attribute. if rake db:migrate , table empty acctbal nil , bomb out. how attribute 0 first time current_user has deposited funds, such following deposit can build off of it. seen in code below, second "+" when adding 2 values gives me undefined nil error want concatenate both values, how can achieve this? def create #@account = account.new(account_params) # @account.save # respond_with(@account) @previous_balance = account.where('user_id = ?', current_user.id).order(:created_at).last.acctbal @account = account.new(account_params) @account.email = current_user.email @account.user_id = current_user.id @account.acctbal = account_params[:deposit] + @previous_balance respond_to |format| if @account.save format.html { redirect_to accounts_url, notice: 'thank , enjoy.' } format.json { render :show, status: :created, loc

python - How to set time limit on raw_input -

in python, there way to, while waiting user input, count time after, 30 seconds, raw_input() function automatically skipped? the signal.alarm function, on @jer's recommended solution based, unfortunately unix-only. if need cross-platform or windows-specific solution, can base on threading.timer instead, using thread.interrupt_main send keyboardinterrupt main thread timer thread. i.e.: import thread import threading def raw_input_with_timeout(prompt, timeout=30.0): print prompt, timer = threading.timer(timeout, thread.interrupt_main) astring = none try: timer.start() astring = raw_input(prompt) except keyboardinterrupt: pass timer.cancel() return astring this return none whether 30 seconds time out or user explicitly decides hit control-c give on inputting anything, seems ok treat 2 cases in same way (if need distinguish, use timer function of own that, before interrupting main thread, records somewhere

html - Button click doesn't open new window -

i have font awesome icon <i> item inside a href target='_blank' — yet text clickable; clicking on icon opens new tab about:blank , not actual link. <a href="..." class="not-light" target="_blank" style="display: block; "> <i class="fa fa-android"></i> » </a> how make icon clickable well? for example, click lightbulb in footer of http://ambieye.com/ site's footer. the <li> list. list must on outer , text in inner : <li style="display: block; "> <a href="..." class="not-light" target="_blank"> <i class="fa fa-android"></i> » text </a> </li> try it.

node.js - Newer socket.io client not connecting to older socket.io server -

i'm trying newer socket.io client connect server process using older version of socket.io, 0.9.14. i've included small example of both client , server demonstrate this. know easy answer upgrade server newer socket.io version , being done. take time , i'd see if there can make client communicate server without upgrading server. want android client able connect it's exhibiting similar connect issue simple nodejs client sample i've posted here. don't know it's identical seems worthwhile start nodejs client testing. when client connects sees "connect sent", "finished emit", doesn't server response message. server repeatedly shows following message: "info - unhandled socket.io url". repeated until client stopped. if update server's package.json use "1.3.5" socket.io example works fine. client package.json { "name": "clientjs", "version": "0.0.0", &quo