Posts

Showing posts from February, 2015

r - Calculate cumulative standard deviation -

this question has answer here: efficient calculation of matrix cumulative standard deviation in r 2 answers i'm trying calculate standard deviation of values in time series, i'd incrementally advancing 1 day initial date value each time. know there way in r (probably using ddply?) doesn't involve nasty for-loop. help! d<-seq(from=as.date("2013-01-01"), to=as.date("2013-02-01"), by="day") v <-rnorm(32, 10, 5) test.df<-data.frame(the_date=d, value=v) here's way i'm doing now. result <- c() for(i in 2:nrow(test.df)){ result[i-1] <- sd(test.df[1:i,]$value)} use ttr::runsd cumulative=true . library(ttr) x <- xts(test.df[,2],test.df[,1]) runsd(x, n=1, cumulative=true)

c# - How to upgrade from entity framework 4 to EF6? -

Image
i want create entitydatamodel entity framework 6 every time try error: your project references older version of entity framework. i'm using visual studio 2013 , project asp.net 4.5.1 web forms project. web.config file, deleted sections of file in order solve problem in vain. <?xml version="1.0"?> <!-- more information on how configure asp.net application, please visit http://go.microsoft.com/fwlink/?linkid=169433 --> <configuration> <configsections> <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 --> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false"/> </configsections> <!-- description of web.config changes see http://go.microsoft.com/fwlink/?linkid=235367. followin

python - Classification of sparse data -

i struggling best choice classification/prediction problem. let me explain task - have database of keywords abstracts different research papers, have list of journals specified impact factors. want build model article classification based on keywords, result possible impact factor (taken number without further journal description) given keywords. removed unique keyword tags not have statistical significance have keywords repeated 2 , more times in abstract list (6000 keyword total). think dummy coding - each article create binary feature vector 6000 attributes in length - each attribute refers presence of keyword in abstract , classify whole set svm. pretty sure solution not elegant , not correct, have suggestions better deal? there nothing wrong using coding strategy text , support vector machines. for actual objective: support vector regression (svr) may more appropriate beware of journal impact factor. crude. need take temporal aspects account; , many work not pu

Returning an element from a list in java -

can tell me advantages (if there advantage) of using getthelastelement2() instead of getthelastelement() ? mean why necessary create reference obj when easier return result? import java.util.arraylist; import java.util.list; public class test { list list; test(arraylist list){ this.list = list; } public object getthelastelement(){ if (list.isempty()) return null; else return list.get(list.size()-1); } public object getthelastelement2(){ object obj; if (list.isempty()) obj = null; else obj = list.get(list.size()-1); return obj; } } there no difference between these 2 implementations: obj reference optimized away. you slight advantage when debugging code, because can set breakpoint on return statement of getthelastelement2 , , know going hit. in contrast getthelastelement , need 2 breakpoints examine return value. note else

javascript - CSS not loaded in Node Express application -

Image
i have problem node express project. cannot seem have css load browser. here how mu project structure looks like. note: adminview folder views admin section page (cms), contains own css, javascripts, , images on folder. public/ css/ images/ js/ routes/ index.js users.js views/ adminview/ layouts/ layout.hbs index.hbs when access index(.hbs) page, loads css well. know worked because: i have specified layout file on app.js app.engine('hbs', hbs({extname: 'hbs', defaultlayout: 'layout' , layoutsdir: __dirname + '/views/layouts'})); i have specified css,js, , images on layout.hbs file i trying access page user.js route. my question is, how load css file on adminview folder? when inspect on page, tells me trying load css localhost:8000/ users /css/bootstrap.css. how make particular route taking getting css,js, , images folder below? edit: added routing files, index.js var express = require('express');

R data.frame with 0 values -

my pos_tat data frame contains 7 rows last 1 appears when summary because value 0. summary(pos_tat) delayed$position.type delayed$tat jf :1 s20 :1 s40 :1 s60 :1 specials :1 s70 :1 14-19 :0 pos_tat delayed$position.type delayed$tat 1 jf 45.10965 2 s20 44.37831 3 s40 44.18750 4 s60 45.40698 5 specials 43.30079 6 s70 42.44444 that poses problem if want add column count example tells me there's different number of rows 6, 7. i've spent hours looking problem can't find answer. thank you. this possible when there unused levels factor columns in dataset. either convert column character or if need keep factor class, use droplevels or call factor again. df2 <- droplevels(pos_tat) or df2 <- transform(pos_tat, delay

C++ template class inheritance -

#include <iostream> using namespace std; template <class t> class c1 { public: int n; c1(int a) { n=a; } t mat[50][50]; void readmat() { int i,j; for(i=1; i<=n; i++)for(j=1; j<=n; j++)cin>>mat[i][j]; } void showmat() { int i,j; for(i=1; i<=n; i++) { cout<<endl; for(j=1; j<=n; j++)cout<<mat[i][j]<<" "; } } }; template <class t> class c2: public c1<t> { c2(int a): c1(a) {}; }; whenever run it, error: in constructor c2::c2(int)': error: class 'c2' not have field named 'c1' if explain me did wrong, appreciate it. you should add template parameter base class template <class t> class c2: public c1<t> { c2(int a): c1<t>(a) {}; };

java - @GenerationType.IDENTITY failing above 10 -

i'm working in project need store data (among other things, of course). production db mysql tests i'm using hypersql (aka hsqldb). all @enitity classes has corresponding @id field @generatedvalue(strategy = generationtype.identity) let db generate field. working fine until tried load amount of data in hsqldb , got error: java.sql.sqlintegrityconstraintviolationexception: violación del restricción de integridad: violación de índice o clave única; uk_... table: operacion the message "violación del restricción de integridad: violación de índice o clave única" means "integrity constraint violation: primary key or unique index violation" (i don't know if that's message when locale set english, translation that) i set logger trace full picture , realized in table operacion generates id field 10 no problem, in 11th registry gives me message sqlexceptionhelper:139 - not execute statement [n/a] , raises exception. is there w

mongodb - Return sum with modulus GROUP BY -

i need sum of results of query group field. explain example. this results of find() { "_id" : objectid("5749a5fd7aed9ced75b94218"), "groupvalue" : "5", "weight" : 123 } { "_id" : objectid("5749a5fd7aed9ced75b94219"), "groupvalue" : "5", "weight" : 345 } { "_id" : objectid("5749a5fd7aed9ced75b9421a"), "groupvalue" : "2", "weight" : 1 } { "_id" : objectid("5749a5fd7aed9ced75b9421b"), "groupvalue" : "2", "weight" : 2 } { "_id" : objectid("5749a5fd7aed9ced75b9421c"), "groupvalue" : "5", "weight" : 567 } now want results sum calculated weight of groupvalue. for example want (123 + 345 + 567)mod(5) , (1+2)mod(2) solution finded: solved own solution. registered new javascript function: db.system.js.save( { _id : "getmodulus

r - Create DataTable in Shiny -

i have dataframe (df). want users enter phrase in shiny. shiny app takes last 2 words of phrase , filters df according trigrams there. output (a datatable) should displayed in user interface. however, server function not find lasttwo() (and maybe not lastone() ). can tell me why? futhermore, how can extract column x3 in df1 , print in ui? require(dplyr) # data wrangling require(stringi) # string/text processing require(stringr) # extracting words require(shiny) df <- structure(list(term = c("one of the", "a lot of", "thanks the", "to a", "going be", "i want to", "out of the", "the end of", "it a", "as as", "some of the", "be able to", "part of the", "i have a", "i have to", "the rest of", "look

javascript - jQuery Ajax POST example with PHP -

i trying send data form database. here form using: <form name="foo" action="form.php" method="post" id="foo"> <label for="bar">a bar</label> <input id="bar" name="bar" type="text" value="" /> <input type="submit" value="send" /> </form> the typical approach submit form, causes browser redirect. using jquery , ajax , possible capture of form's data , submit php script (in example, form.php )? basic usage of .ajax this: html: <form id="foo"> <label for="bar">a bar</label> <input id="bar" name="bar" type="text" value="" /> <input type="submit" value="send" /> </form> jquery: // variable hold request var request; // bind submit event of our form $("#foo").submit(funct

node.js - compare and diff between jade template and mustache template -

i beginner in java script , familiar client developing in low level. question main diff between jade template engine , mustache template? both of them nodejs server side or use in client side? advantage of each in scope ? if want write small single page app in mean stack structure in case choose of template syntax best ? html 5? jade? mustache? personally, use jade nodejs apps on backend side given integrates node.js , provides light syntax. and use mustachejs when want use templating within html. here more information on jade , mustachejs. https://strongloop.com/strongblog/compare-javascript-templates-jade-mustache-dust/ http://jster.net/blog/templating-javascript-mustache-jade-transparency#.v0mrxzn96rs http://vschart.com/compare/mustache-template-language/vs/jade-template-engin

c++ - How do I correctly use COMMTIMEOUTS with OVERLAPPED IO mode reading from a Serial port -

i trying use overlapped io mode on windows 7/8 x64 emulate non blocking mode ( io_nonblock ) behavior supported linux's open flags. code here part of windows portion of cross platform serial api. i can open comm port in either blocking or non blocking (overlapped) mode using constructor parameters serialcommwnt object. far question goes questions have when comm port opened in overlapped mode (as specified flow control constructor parameter). read method, specify timeout parameter, upon retrieving @ least 1 byte of data serial port, should indicate time remaining of rtimeout parameter when data in serial comm's input buffer (i believe serial driver notifies manual reset event in overlapped structure when receives data). i read many stackoverflow threads on how handle these apis, many of them refer microsoft win32 api. best information can find far http://msdn.microsoft.com/en-us/library/ff802693.aspx api confusing overlapped io (expecially when comes passing poi

android - SeekBar Holo Theme using Support Library -

Image
i using android support library v4 , v7 fragments, swipe-able view pagers, , actionbar! works , graphics nice! however while graphics above nice , consistent in android 2.x , android 4.x, common widgets different between versions. leads colours mismatch inside app otherwise consistent ui - no matter draw in rest of ui, either yellow seekbar or blue seekbar won't match something. i thought whole point of support library consistent ui across platforms, , stop needing 3rd party libraries such actionbarsherlock or holoeverywhere ! i can't seem find whether how google wants seekbar or doing wrong: my seekbar looks quite nice on android 4.x: alas, same seekbar looks dated on android 2.x: i can't seem find whether how google wants seekbar or doing wrong: nope, you're not doing wrong. it's working intended. if want consistency ui elements across different android versions, need use actionbarsherlock , optionally holoeverywhere . anoth

java - Where to use @NamedQueries -

i using @namedqueries not sure best way use it. use above entity class use above dao class create 1 namedqueriesfactory class have centralized named queries entity any other better way. i way put of them in xml file used lot. externalizes queries , gives freedom of sending on xml file dba easier analysis later on.

Python 3 | Threading works weirdly -

i'm learning python 3 , watched tutorial threading: https://www.youtube.com/watch?v=waxk8g1hb_q&index=33&list=pl6gx4cwl9dgacbmi1sh6oamk4jhw91mc_#t=365.299172 i tested example code reason result sort of weird. import threading class messenger(threading.thread): def run(self): _ in range(10): print(threading.currentthread().getname()) m1 = messenger(name="send messages") m2 = messenger(name="receive messages") m1.start() m2.start() i expecting program print out "send messages" , "receive messages" on sort of random order, happened, , i'm not quite sure why: send messagesreceive messages send messagesreceive messages send messagesreceive messages send messagesreceive messages send messagesreceive messages send messagesreceive messages send messagesreceive messages send messagesreceive messages send messagesreceive messages send messagesreceive messages can explain me why results pri

python - Scipy Sparse Matrix built with non-int64 (indptr, indices) for dot -

is ok use uint32 type indptr , indices when manually construct scipy.sparse.csr_matrix? dot method of matrix return correct answer? the following example seems ok... not sure if officially ok. import numpy np import scipy.sparse spsp x = np.random.choice([0,1],size=(1000,1000), replace=true, p=[0.9,0.1]) x = x.astype(np.uint8) x_csr = spsp.csr_matrix(x) x_csr.indptr = x_csr.indptr.astype(np.uint32) x_csr.indices = x_csr.indices.astype(np.uint32) x_csr_selfdot = x_csr.dot(x_csr.t) x_selfdot = x.dot(x.t) print(np.sum(x_selfdot != x_csr_selfdot)) the x_csr.data array of 1. scipy doesn't let me use single number replace whole x_csr.data array. i'm not sure goal is. doing works (sort of) in [237]: x=x_csr.dot(x_csr.t) in [238]: np.allclose(x.a,x.dot(x.t)) out[238]: true that is, multiplication modified x_csr works. but note manipulation of x_csr makes new sparse matrix reverts int32 indices in [240]: x_csr.indptr out[240]: array([ 0, 112, 21

Nginx + php-fpm: Bad gateway only when xdebug server is running -

problem when xdebug server running intellij idea, 502 bad gateway nginx when try loading site trigger breakpoints. if stop xdebug server, site works intended. so, i'm not able run debugger, did work (!). not able pinpoint why stopped working. setup a short explanation of setup (let me know if need expand on this). my php app running in docker container, , linked nginx running in different container using volumes_from in docker compose config. after starting app, can verify using phpinfo(); xdebug module loaded. my xdebug.ini has following content: zend_extension=xdebug.so xdebug.remote_enable=1 xdebug.remote_host=10.0.2.2 xdebug.remote_connect_back=0 xdebug.remote_port=5555 xdebug.idekey=complex xdebug.remote_handler=dbgp xdebug.remote_log=/var/log/xdebug.log xdebug.remote_autostart=1 i got ip address remote_host (where xdebug server running) these steps: docker-machine ssh default route -n | awk '/ug[ \t]/{print $2}' <-- returns 10.0.2.2 to

qunit reports results before execution is finished -

i'm still new qunit. there's snippet <body> <div id=qunit></div> <div id=qunit-fixture> .. <a title=something href=#>foo</a> </div> and corresponding test case contains $( 'a').each( function() { console.debug( this); // } ); however, qunit inserts results in #qunit, including hyperlinks, in turn appear in test case (inside each). obviously, content inserted qunit should outside test's scope. suggestion how avoid this? qunit deals having place html test needs inside qunit-fixture element, instead of: $('a').each(function() { ... }); you do: $('#qunit-fixture a').each(function() { ... }); in test case. this lets isolate tests without depending on other page contents. qunit documentation provides more information this methodology.

ios - How to display only once same push notifications? -

i'm using push notifications on app, , didn't find way display once notifications have same content. possible ? my code : @uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate, uialertviewdelegate, gglinstanceiddelegate, gcmreceiverdelegate { var window: uiwindow? var gcmsenderid: string? var registrationoptions = [string: anyobject]() func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { var configureerror:nserror? gglcontext.sharedinstance().configurewitherror(&configureerror) assert(configureerror == nil, "error configuring google services: \(configureerror)") gcmsenderid = gglcontext.sharedinstance().configuration.gcmsenderid uiapplication.sharedapplication().registerusernotificationsettings(uiusernotificationsettings(fortypes: [.alert, .badge, .sound], categories: [category])) uiapplication.sha

C# MVVM: Edit a SelectedItem of an ObservableCollection with a RelayCommand -

i quiet new programming , learning c# , mvvmc pattern (which think same mvvm pattern). i need code database tool chiliplants university. there should able edit existing item observablecollection. this observablecollection displayed in datagrid, see this: datagrid below datagrid there 3 buttons: add, edit , delete. able programm addbutton, aswell deletebutton. unfortunately don't know how programm editbutton. should open new window, selecteditem should opened this: editwindow until editbutton same thing addbutton. see code here: view: <stackpanel grid.row="1" orientation="horizontal"> <button content="add" margin="5,5,0,5" width="100" command="{binding addcommand}" /> <button content="edit" margin="5,5,0,5" width="100" command="{binding editcommand}" /> <button content="delete" margin="5,5,540,5" widt

How do I figure out which Javascript code is periodically hanging the browser? -

it's not freezing page until refresh, it's every 10 seconds or hanging few seconds while i'm typing or clicking in page (i of course won't notice if i'm not interacting page, , there's no moving graphics). i didn't build page or form, it's heavy javascript , i'm unable edit javascript source code (except in chrome dev tools) i'd know if there's way catch code keeps hanging user interactivity. you can use collect javascript cpu profile in chrome dev tools, press record, click around, stop, , evaluate. details: https://developer.chrome.com/devtools/docs/cpu-profiling if have access source code can use performance api

ios - Programmatically press a keyboard button -

i wondering if there way open ios keyboard , programmatically press button without interacting keyboard itself. yes, there way. there several ways of them undocumented , should not used them in production. generating tap means generating uievent (several of them, actually) , passing uiapplication.sendevent(_:) . unfortunately, uievent inner structure undocumented people have inspected , can google tools synthesize events (e.g. https://github.com/n00neimp0rtant/controlfreak ). note internal structure of uievent , uitouch can change between ios versions (see ios 9 uievent ) you can use internal uiautomation api (see example these generated headers ) generate tap (that's ui tests using in previous releases) again, api not publicly documented , loaded app if app connected xcode. not sure how private framework looks on ios 9.

c# - Select from multiple tables? -

Image
i have 2 tables 1 table's name (memberform) , has columns id,name,mobile example 1,dimitris,69xxxxxxx, , second table (groups) columns name,groupname,memberid example dimitris,dancegroup,1 (memberid same id) want extract richtextbox groupname groups = combobox1 , memberid row groupname exists same memberform.id i'm trying this using (var command = new sqlcommand("select mobile memberform memberform.id=groups.memberid , groups.groupname='" + combobox1.text + "'", con)) // using (var reader = command.executereader()) the raw sql query select m.mobile memberform m join groups g on g.memberid = m.id g.groupname = 'dancegroup' the same can written in sqlcommand using (var command = new sqlcommand("select m.mobile memberform m join groups g on g.memberid = m.id g.groupname = '" + combobox1.text + "'", con)) update: the above approach can possible sql injection attack, explicitly pass para

Undefined offset PHP error 1 -

i'm getting undefined offset error in php function error codes php notice: undefined offset: 1 php notice: undefined offset: -1 function thousandscurrencyformat($num) { $x = round($num); $x_number_format = number_format($x); $x_array = explode(',', $x_number_format); $x_parts = array('k', 'm', 'b', 't'); $x_count_parts = count($x_array) - 1; $x_display = $x; $x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : ''); $x_display .= $x_parts[$x_count_parts - 1]; return $x_display; } these 2 lines have error $x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : ''); $x_display .= $x_parts[$x_count_parts - 1]; how can fix this? appreciate help this happens, riggsfolly alluded to, when trying access array key not exist. when number_format not return thousands , there no comma sign, there single item in array. a s

deployment - Error running Python on OpsWorks with Chef + Berkshelf -

i'm trying python 2.7 working on opsworks instance keep running errors starting up. my opswork stack set chef version 11.10 , berkshelf version 3.2.0. my metadata.rb has following in it: depends "poise-python" depends "apt", ">= 1.8.2" my berksfile set with: source "https://supermarket.chef.io" cookbook 'poise-python' cookbook 'apt' every time launch keep getting following error , i'm not sure how resolve it: halite not compatible no_lazy_load false, please set no_lazy_load true in chef configuration file. i tried adding chef/configuration.rb file set no_lazy_load true doesn't seem working. frankly i'm new opsworks , chef may missing basic. more info the stack i'm taking on referenced python instead of poise-python had switched resolve different error (but, guess, related) when tried run that: this resource written chef 12.5 custom resources, , re

javascript - open jquery-ui dialog based on ajax response -

i'm trying open jquery-ui dialog when response of checklatestnews.php meets condition rec != "0". created test checklatestnews.php file response "1", yet jquery-ui dialog still not open. appreciated. <div id="dialog"> <script type="text/javascript"> $("#dialog").dialog( { bgiframe: true, autoopen: false, height: 100, modal: true } ); </script> <script type="text/javascript"> var check_latestnews; function checkforlatestnewsnow() { var str="chklatestnews=true"; jquery.ajax({ type: "post", url: "checklatestnews.php", data: str, cache: false, success: function(res){ if(res != "0") { $("#dialog").html(response).dialog("open"); } } }); } check_latestnews = setinterval(checkforlatestnewsnow,

lua - Coroutine problems -

so i'm trying make basic gui animation system in roblox, using individual frames , loop put them imagelabel. this function: local playanimation = coroutine.create(function(anim,pos,tank) while true local animbase = sp.animbase:clone() animbase.parent = tank animbase.visible = true animbase.position = pos -- line causes error mentioned below. local frame = 1 = 0, animations[anim]["framenum"] frame = frame + 1 animbase.image = animations[anim]["frames"][frame] newwait(.1) --this right here, wait, interfears yield. if frame >= animations[anim]["framenum"] pos,anim,tank = coroutine.yield() break end end animbase:destroy() end end) there 2 main problems this: every time runs, error: 20:41:01.934 - players.player1.playergui.screengui.gui-main:65: bad argument #3 'position' (udim2 expected, got number) although error doesn't see

Send email from a Google Script with another 'From' address -

my sheet-bound script sending email using mailapp.sendemail. the emails sent 'from' own gmail account. project customer, , need email 'from' on these emails. reading similar questions learn have flexibility in changing name , replyto address, using advanced options of mailapp.sendemail. however, email address still mine , google doesn't offer control on that. i'm not familiar enough of google services , options find best way this. customer have google apps business, don't. can somehow create email-sending function standalone script under account, , somehow call project under account? other ideas? thanks! emails sent account of user executes script. in case email sent triggered function (installable triggers ones able send emails since requires explicit authorization) email sent account of user created trigger (and authorized it). in case, seems easier solution ask customer execute script himself , initiate triggers himself too. if sho

SQL Server : backup failing error -

getting below error while trying configure backup source , destination in different domain. executing query "backup log [project_management] disk = n'\\nee..." failed following error: "cannot open backup device '\\qwerty.xyz.xyzinteractive.com\backup4\teddy\tlogs\project_management_backup_2016_05_28_020039_7840447.trn'. operating system error 1326(the user name or password incorrect.). backup log terminating abnormally.". possible failure reasons: problems query, "resultset" property not set correctly, parameters not set correctly, or connection not established correctly. it recommended backup done local , moved. here link think related topic. using service account has appropriate privileges on both domains? http://www.sqlservercentral.com/forums/topic842263-357-1.aspx

python - Custom user model not working on django admin -

i created app authentication, code models is, from django.contrib.auth.models import abstractbaseuser django.contrib.auth.models import baseusermanager django.db import models class accountmanager(baseusermanager): def create_user(self, email, password=none, **kwargs): if not email: raise valueerror('users must have valid email address.') account = self.model(email=self.normalize_email(email)) account.set_password(password) account.save() return account def create_superuser(self, email, password, **kwargs): account = self.create_user(email, password, **kwargs) account.is_admin = true account.save() return account class account(abstractbaseuser): email = models.emailfield(unique=true) # username = models.charfield(max_length=40, unique=true) first_name = models.charfield(max_length=40, blank=true) last_name = models.charfield(max_length=40, blank=true)

javascript - Fastest Gaussian Blur Not Working -

i not @ javascript , have been trying ivan kuckir's fastest gaussian blur code work no success. when load page, becomes unresponsive have close window somehow. code use follows. doing wrong? <html> <head> <script src="path_to_gaussianblur.js"></script> </head> <body> <img id="sourceimage" src="someimage_200px_x_200px.jpg" /> <canvas id="canvas1" width="200" height="200" style="border: 1px solid blue"></canvas> <canvas id="canvas2" width="200" height="200" style="border: 1px solid red"></canvas> <script> document.getelementbyid("sourceimage").onload = function () { var c1 = document.getelementbyid("canvas1"); var c2 = document.getelementbyid("canvas2"); var ctx1 = c1.getcontext("2d"); var ctx2 = c2.getcontext("2d&

how play and visualize audio streaming between browsers via peerconnection? -

i using webrtc create peerconnection , stream audio between browsers, how can visualize , play audio stream visualizer(for example wave form) both transmitting , receiving? knows example? thanks take @ @cwilso's excellent demos on webaudiodemos.appspot.com , in particular audio recorder (which inputs audio getusermedia web audio, analyses data , draws canvas element) , live input effects (which similar webgl visualisation). @paul-lewis's audio room uses webgl.

css3 - Deduplicate CSS rule in class and media query -

i have css rules duplicates in both .small , media query #a , because want same behaviour when browser width smaller 600px , when button clicked. in real case, rules long, , avoid duplicate them. how deduplicate such css? $('#b').click(function(){ $('#a').addclass('small'); }); #a { background-color: green; } .small { background-color: yellow !important; /* many other rules */ } @media (max-width: 600px) { #a { background-color: yellow !important; /* many other rules */ } } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="a">hello</div> <input id="b" type="button" value="change" /> i don't think there's way in pure css, 1 of things can solve precompilers sass can inject css rules anywhere want variables or mixins example

optimization - Finding multiple roots on an interval with Python -

i'm looking efficient method find roots of function f on interval [a,b]. problem have nice methods scipy.optimize require either f(a) , f(b) have different signs, or provide initial guess x0, know nothing roots before running code. note: function f smooth (at least c1), , doesn't have pathological behaviour [nothing sin(1/x)]. however, requires building matrix a(x) , finding eigenvalues, , therefore time-consuming. expected have between 0 , 10 roots on [a,b], position arbitrary. can't afford missing of them (e.g. can't take 100 initial guesses x0 , hope i'll catch roots). i thinking implementing this: find extrema {m_1, m_2.., m_k} of f scipy.optimize [maybe fmin, don't know method efficient]: search minimum m_1 starting point [initial guess gradient algorithm] search maximum m_2 starting point m_1 + dx [forcing gradient algorithm go forward] search minimum m_3... if 2 consecutive extrema m_i , m_(i+1) have opposite signs, apply brentq on inte

c - Force 32 bits compilation in MSVC 2010 commandline -

is there option specify in msvc 2010 commandline executable force 32-bits compilation? if so, it? thanks advance force help, regards. commandline compiling 32bit needs additional /d "win32" this define win32 . macros int_ptr interpreted differently 64-bit versus 32-bit. example, int_ptr defined follows: #if defined(_win64) typedef __int64 int_ptr, *pint_ptr; //64bit ... #else typedef _w64 int int_ptr, *pint_ptr; //32bit ... #endif in addition, link option 64-bit includes /machine:x64 for 32-bit must changed /machine:x86 in visual studio can create sample project, in project properties shows commandline option c/c++ compile , link.

java - How do run each browserdriver based on enum list value? -

hi using code found in first answer on page: click here i able run , choose browser changing environment used_driver line number of different browsers. i wandering if possible run test runs through each case once before finishing, i.e. has been tested on each of selected browsers once have had go @ using for, , if havnt been successful. please bare me new java , oo. thanks. example test driver.get("calc.php"); driver.findelement(by.name("firstnumber")).sendkeys("2"); thread.sleep(500); driver.findelement(by.name("secondnumber")).sendkeys("2"); thread.sleep(500); driver.findelement(by.name("calculate")).click(); thread.sleep(500); driver.findelement(by.name("save")).click(); thread.sleep(500); i believe asking run single test multiple times, once each browser. there different ways can this...i'll start simplest (but hardest maintain in future, make sure understand

Installing Ruby on Rails from Source - cannot load such file -- openssl -

i on mac, using lion. configuring system ruby on rails development ran issues. instead of using brew or other shortcuts want configure ruby on rails source. so, here did. installed ruby 2.0 downloaded source ruby website compiled running following code: ./configure --prefix=/users/user/applications/ruby2 make make install and made sure $path file updated point /users/user/applications/ruby2/bin so, able call ruby -v or if which ruby point custom compiled version of ruby. installed node.js downloaded source main website compiled running following code: ./configure --prefix=/users/user/applications/nodejs make make install and made sure $path file updated point /users/user/applications/nodejs/bin so, able call node -v or if which node point custom compiled version of ruby. i did same steps openssl , accessible console or if which openssl points /users/user/application/openssl/bin but still when execute gem install rails still following error: