Posts

Showing posts from July, 2015

Sphinx query/settings similar to Like '%string%' SQL query -

i want search string in sphinx , documents contains string example: search "bot" , documents contain "xbot", "robot", "botanic", etc basically want search have same effects running select * table column_name '%bot%' how can that? note : tried use min_infix_len seems extends search little bit not fully. if set conf-min-prefix-len = 2 match 'xbot' not "botanic" try using wildcard in extended query syntax , min_infix_len enabled select * myindex match("bot | bot* | *bot*")

javascript - How do you get two divs have the same borderRadius? -

is right way match 2 divs? var div2 = document.getelementsbyclassname("div2"); div2.style.borderradius = "100px" document.getelementbyid("div1").style.borderradius = div2.style.borderradius; just newbie @ javascript. just comment on code, document.getelementsbyclassname() returns htmlcollection, not single dom element. should use document.getelementbyid() or document.queryselector() if you're trying 1 element. and don't want use js add styling, unless styling want use dynamic. case, should use css file , add class: .round-border { border-radius: 100px; } if still want use js add class instead of putting in html, can following: document.getelementbyid("div1").classlist.add('round-border'); document.getelementbyid("div2").classlist.add('round-border'); this assuming gave html elements correct id names. but said, because using static value of 100px , make more sense add class eleme

javascript - Playing animation to a specific time -

i creating backend animating progress bar. // default easing. tweenlite.defaultease = power0.easenone; // timeline. var tl = new timelinelite({ onupdate : function() { console.log(progress.progress); } }); // initial state. var progress = { progress : 0 }; // finalized state. tl.to(progress, 1, { progress : 100 }); // length of animation. tl.totalduration(15); // play. tl.play(); this works expected, there way animate current playhead specific one ? tl.playto(0.5) , afterwards tl.playto(0.2) revert 20%. i aware of seek , progress , optional variable play methods, let me specify starting position, not end position. how achieve such behavior? if understand question correctly, here propose. you can animate progress property of timelinelite . like: tweenlite.to(tl, 1, {progress: .5, ease: linear.easenone}); . also, have seen tweento() , tweenfromto available in timelinemax , know using timelinelite still wondering if aware of th

python - In wxPython Grid, creating event handler for Cell Selection disables moving the GridCursor -

in program i'm writing, user needs able select cell in grid , edit value. program shows value of selected value in hexadecimal (so (0,0) 0x00 , (1,3) 0x19 , etc.) had display updated through binding wx.grd.evt_grid_select_cell event. however, upon doing this, gridcursor no longer move, stay on (0,0). so, added setgridcursor statement handler have move cursor when handler called. however, generated infinite loop, apparently setgridcursor generates evt_grid_select_cell command when called. my question is, how have code executes when new cell selected while still maintaining old cell selection functionality? adding event.skip() @ end of custom handler passes event default handler.

phonegap plugins - 'cordova' is not recognized as an internal or external command -

i trying install cordova 5.1.1 version using node.js, command line interface. cordova got installed on machine, not able use cordova command. when list packages, can able see installed cordova cordova, can not run command create project. system config : os : windows 8, npm version : 1.3.21, cordova version : 5.1. error message c:>cordova 'cordova' not recognized internal or external command, operable program or batch file. need set environment variable. start -> control panel -> system , security -> system -> environment variables or mycomputer -> right click -> properties -> advance system settings -> environment variables under user variables youruser: path: %systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot% \system32\windowspowershell\v1.0\;c:\users\user1\appdata\roaming\npm` temp: %userprofile%\appdata\local\temp simple copy pasting wont work. if still not getting need reset/create

windows - cygwin: can't execute PHP script via PATH -

i have written php script "toalpha" (purpose not relevant question). script in $home/bin. if cwd $home/bin, can execute typing "./toalpha". if type "toalpha", message: not open input file: /c/barry/bin/toalpha some information may relevant: . upgraded desktop winxp win7. . first time have made own userid ordinary user instead of admin. (i tried on xp, ran problems , went having normal userid admin. don't need solution because i'm no longer running xp , besides own fault.) . $home /c/barry did adding following .bashrc created when installed cygwin: mount c: /c home=/c/barry cd . .bashrc . first 2 lines of php script are: #!/c/xampp/php/php <?php . yes, copy of php want use in c:\xampp\php\php.exe . have another, similar script wrote on winxp. starts same 2 lines. worked fine under xp, doesn't work on win7. my best guesses @ source of problem: a difference between xp , win7 i fumbled home directory ch

php - wordpress setup given forbidden error -

installing fresh wordpress-4.2.2 setup on server after fill form of database details next given error of forbidden don't have permission access /wp/wp-admin/install.php on server. additionally, 404 not found error encountered while trying use errordocument handle request. i have check permission of folder , .htaccess same wordpress setup working on local server. is suggestion thanks. i solve issue goes in parent wordpress install plugin of 'all in 1 wp security' effected. thanks.

archlinux emacs can't autoload monaco-fonts -

i install monaco fonts aur in archlinux, , set emacs's fonts monaco, doesn't load monaco fonts when emacs starts, every time should set monaco fonts manually when starting emacs, can 1 give me hint? part of .emacs.d/init.el: (custom-set-faces '(default ((t (:family "monaco" :foundry "unknown" :slant normal :weight normal :height 128 :width normal))))) i find (custom-set-faces ...) doesn't make sense in case, use following code found in https://superuser.com/ , succeed. (set-frame-font "monaco 14" nil t) (add-to-list 'default-frame-alist '(font . "monaco 14"))

xml - Match when text is equals to something xslt -

what i'm trying simple, can't seem working. i have following xml: <analysis> <field> <name>field_1</name> <type>number</type> <tag>number field number one</tag> </field> <field> <name>field_2</name> <type>text</type> <tag>text field number one</tag> </field> <field> <name>field_3</name> <cell>a12</cell> <type>excel</type> <tag>value comes excel file</tag> </field> </analysis> i want xml output this: <table> <thead> <tr> <th>nombre</th> // name in spanish <th>tipo</th> // type in spanish </tr> </thead> <tbody> <tr> <td>number field number one</td>

How to delete 10 records out of 20 records and display the remaining 10 records in an xslt? -

i'm fresher in xslt coding..i'm able delete particular record using remove() operation i'm unable delete 10 records out of 20 records @ time , display remaining 10 records...can please give me example of performing operation..thanks in advance. actually i'm doing project in dataower, i'm giving soap request , want delete 10 records response using xslt code.. here input request... <soapenv:envelope> <soapenv:body> <integrationeventws_getevents_input> <eventcount>10</eventcount> <queuename>opportunity partner</queuename></integrationeventws_getevents_input> </soapenv:body> </soapenv:envelope> here sample response... <soap-env:envelope> <soap-env:body> <catalog> <cd> <title>empire burlesque</title> <artist>bob dylan</artist> <country>usa</country> <company>columbia</company> <pri

java - I cannot replace the counter 0-11 with months of the year -

i want output show months , sales figures don't know replace what. i have tried adding code make months appear , numbers right i'm having no luck. import java.util.scanner; public class assignment2 { public static void main(string[] args) { scanner keyboard = new scanner(system.in); system.out.println("welcome!\n"); system.out.println("month 0 - january"); system.out.println("month 11 - december\n"); system.out.println("monthno(year1)\tsales made\n"); double sales[] = { 60, 54, 62, 67, 54, 67, 51, 50, 62, 55, 49, 70 }; int sum = 0; int average12 = 0; (int counter = 0; counter < sales.length; counter++) { sum += sales[counter]; system.out.println(counter + "\t\t\t\t\t\t" + sales[counter]); } system.out.println("\ntotal year 1 sales " + sum + "\n");

passport.js - Viewing user email and provider used in Passport and Sails.js with EJS -

how see used login provider in page made ejs, passport , sails.js? idea being able see after logging in facebook or twitter. after hours trying, i've found answer. i'm using code generated sails-generate-auth . creates file called authcontroller (in api/controllers folder). in callback function, called other named passport.callback, has line this: req.session.authenticated = true; after line, can put other line: req.session.provider = req.params.provider; by putting line, can access in ejs login provider selected user this <div>logged <%=req.user.email%> (<%=req.session.provider%>)</div>

What happens after the end of character array in c? -

this question has answer here: segmentation fault doesn't come after accessing out-of-bound memory 5 answers what's stored after end of character array? assuming there random garbage did not print after end while looping 10 times. char a[] = "pencil"; int i; (i = 0; < 10; i++) { printf("%c", a[i]); } so character array has size of 7. , loop looped until 10th position 3 more values looped through. did not print or error. what's going on here? accessing beyond end of array in c undefined behavior. program continue running unchanged or crash horrifically depending on stored past end of array. compiler makes no guarantees stored there - useless memory or critical program.

Python: for loops and xrange() -

this question has answer here: scope of python variable in loop 7 answers i learning python , came across 'for loop' let's have program asks 5 numbers. know it's pointless it's example. anyway, if did this, wouldn't restart cycle. mynumbers = [] x in xrange(5): try: mynumbers.append( int(raw_input()) ) except valueerror: mynumbers = [] x = -1 i thought if had reset x -1 make loop go on more, never restarted. still only went 5 times. reason why put -1 there because x count 0 right after that. tried find solutions, there weren't any. thank if try me. xrange() (or range() ) called generator functions, x local variable loop assigns next value in loop to. xrange() returns values in range given in parameters 1 1 , , loop assigns variable x. if change value of x within loop, xrange() has no ide

java using float comparison will return wrong results -

class { public final static float _eps = 1e-7f; public final static double _eps2 = 1e-7; public static boolean compare(float a, float b) { return < b + _eps; } public static boolean compare2(float a, float b) { return < b + _eps2; } public static void main(string [] main) { float = 54.124844f; float b = 54.124844f; system.out.println("compare 1: " + a.compare(a, b) + " comapre 2: " + a.compare2(a, b)); } } i thought both of these 2 comparisons return true, but, a.compare return false. reason in mind because of range , precision difference between float , double type. however, seems number , eps used should within legal range. help. this because 54.124844f + 1e-7f == 54.124844f . float doesn't have enough precision addition yield value different 54.124844f . using math.nextafter(float, double) shows next larger value after 54.124844f 54.124847f . such,

javascript - Wait for function to finish execution -

i have following: function functiona() { var myvar = functionb(); functionc(myvar); } the time, functionb needs answer, depends on user input. may 1s, 10s. functionc called undefined value, because functionb() hasnt't finished yet. tried this: function functiona() { var def = $.deferred(); var myvar = functionb(); def.resolve(); $.when(def).done(function () { functionc(myvar); }); } this doens't work. saw on stackoverflow: javascript function wait until function finish how can transferred problem? recap, execution of functiona needs stop, until functionb() has answered. thanks. you can change functionb return deferred object, can resolve within async handler, this: function functiona() { var deferred = functionb(); $.when(deferred).done(functionc); } function functionb() { var deferred = $.deferred(); // async here... // asynccallback() { // deferred.resolvewith(this, dataretrieved);

angularjs - how parse dynamic data through routing -

i trying achieve list page , detail page using feeds gathered various sourcess using google feed api, <div class="post" ng-repeat="feed in feeds | orderby:'title'"> <div class="col col-50" ng-repeat="item in feed.entries"> <div href class="accent"> <img style="max-width:100%;height:auto;" src=" {{item.mediagroups[0].contents[0].url}}" alt=""> <h4><a href="#/home/detail/{{feed}}/{{item}}"> //here href on h4 tag route params {{item.title}}</a></h4> <h4><small>{{item.author}}</small></h4> <p>{{item.contentsnippet}}</p> </div></div></div> he idea feed[index].entries[index].title ,so parsing feed in feeds index , item in feed.entries second index , give me nothing ,any work around

javascript - How to use require inside global and local function -

im using node js aplication , i've created new js file module , in module export 1 function,in module lets i've additional 2 functions internal use only , should not exposed outside, each function use different require modules following: module.exports = function (app, express) { var bodyparser = require('body-parser'), url = require('url'), http = require('http'); ..... }; function prrequest(req, res) { httpproxy = require('http-proxy'); .... } function postrequest(req, res) { url = require('url'); .... } my question best practice should put require (for url http etc) 1.inside every function need it?in case internal , external 2.globally in file every function can use? 3.if 2 not ok should put require url should use in 2 functions?better put in both function or in global or doesn't matter the modules should exposed outside functions calling require each time functi

java - JavaFX Database Application Guidance -

i thinking of using javafx desktop app let users upload files. thinking correct approach ? should use mysql database store references files or dump files in folder? coming web background bit confusing. contain jre in deployed app can run on machine right (even though machine not have jre)? thanks if want self-contained, try embedded database objectdb. here's link 4-step tutorial . what can read in file bytestream , store in entity other file parameters you'd (the tutorial explains this), , store entitiy in database. objectdb create small database file can stored app.

python - Defining any variable in __init__.py -

there many posts got use case of __init__.py , use define global variable 1 of them. want know there demerit in defining local variable in __init__.py ? there no technical reason prevents using __init__.py declaring global variables. nevertheless, mean of __init__.py modules define import structure of application. python documentation: the __init__.py files required make python treat directories containing packages; done prevent directories common name, such string, unintentionally hiding valid modules occur later on module search path. in simplest case, __init__.py can empty file, can execute initialization code package or set __all__ variable, described later. as developer, expect find in __init__.py file import layout of application itself. it's last place when i'm exploring source code. therefore, hiding implementation in __init__.py misleading. true global variable lifecycle definition hard follow. it's considered bad practice because brea

python - Microsoft Visual Studio 2015 Interactive window -

i'm running microsoft visual studio 2015 , trying run python 3.4 - 64-bit interactive window shows <disconnected> . if try restart - following error: method not found:'microsoft.visualstudio.text.spanmicrosoft.visualstudio.interactivewindow.iinteractivewindow.writeerro(system.string)'. i've tried reinstall updated , appropriate python tool kit. i've repaired installation of visual studio. interactive window nonfunctional , can't type window. true if change interpreter 2.7. configure interactive window properties doesn't have options connect python interpreter. python debug interactive doesn't work , gives same error. right click > highlighting code > send interactive, in .py file open (which runs fine) gives same error. i believe because need install separate interpreter (cpython, ironpython), described here: https://github.com/microsoft/ptvs/wiki/ptvs-installation

java - Adding a new OSGI bundle to local p2 repository -

i have created new osgi bundle existing jar file. have local p2 repository set target platform in eclipse. directly copied osgi bundle local p2 repository. build says cannot find new osgi plugin. manually added new entry in artifacts.xml new bundle well. still no luck. can please me resolve issue? you can use p2.publisher that. example: java -jar <eclipsedirectory>/plugins/org.eclipse.equinox.launcher_<version>.jar -application org.eclipse.equinox.p2.publisher.featuresandbundlespublisher -metadatarepository file:/<yourlocalrepo> -artifactrepository file:/<yourlocalrepo> -source <location sub-directory named plugin and/or features > -publishartifacts you need replace eclipsedirectory , version of equinox launcher bundle. information here eclipse wiki

php - subtract value and update multiple rows -

i have cart , want update database right stock values. ordered products inserted table, can't update stoc table right values. foreach($_post['produsc'] $row=>$produsc) { $produsc=mysqli_real_escape_string($link,$produsc); $masurac=mysqli_real_escape_string($link,($_post['masurac'][$row])); $codutc=mysqli_real_escape_string($link,($_post['codutc'][$row])); $cantitatec=mysqli_real_escape_string($link,($_post['cantitatec'][$row])); $pretc=mysqli_real_escape_string($link,($_post['pretc'][$row])); $tokc=mysqli_real_escape_string($link,($_post['tokc'][$row])); $row_data[] = "('$tokc' , '$codutc' , '$produsc' , '$masurac' , '$cantitatec' , '$pretc' , now())"; } if (!empty($row_data)) { $sql = 'insert orders (order_id, idd, produs, masura, cantitate, pret, data) values '.implode (',', $row_data); $result = mysqli_query($link, $sql

Matplotlib imshow low quality compared to OpenCV -

i doing computer vision python using both opencv , matplotlib. want switch matplotlib viewing images found image quality low compared opencv imshow images not shown right size on screen same size. this how use img = cv2.imread('a.png',0) f = plt.figure(figsize=(img.shape[1],img.shape[0]), dpi=1) plt.axes([0,0,1,1]) plt.axis('false') plt.imshow(img,cmap="gray",interpolation=none) i tried different values interpolation still quality low compared opencv there show image better quality? also when printing same low quality not opencv write method. you making figure size large. img.shape returns number of rows , columns in img figsize uses inches. also, want figure have different resolution dpi = 1. dots per inch should more 80 , may need higher depending on how you'll display image.

How to upgrade from V11 to V12 SQL Azure? -

i using v11 sql azure. at stage not want upgrade existing sql server contains current qa , production dbs. logically seems safer create new sql server setup v12, somehow copy/migrate v11 db instances v11 sql server new v12 sql server ie qa dbs start with. aware of: v12 upgrade article is possible , how? the easiest way create new v12 server , export databases , import them new server. there few ways this, either use portal ( https://manage.windowsazure.com ) , click database , click export button @ top, export database azure storage. import click new, data services, import , select bacpac file storage account , select new v12 server import to. your other option download ssms ( https://msdn.microsoft.com/en-us/library/mt238290.aspx ) , login both servers. right click database want export, , go tasks -> export data-tier application. select local storage download database locally. import, right click databases folder on v12 server , go tasks -> import data-tie

javascript - InfoWindowLite not appearing -

i trying implement infowindowlite javascript function on map. however, else working i.e. legend, scalebar, featurelayer. below code reference: <!doctype html> <html> <head> <!-- add in meta elements --> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>map</title> <!-- reference styles --> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css"> <!-- reference arcgis javascript --> <script src="http://js.arcgis.com/3.9/"></script> <style> html, body { height: 97%; width: 98%; margin: 1%; }

shipping - Different prices for multiple countries in PrestaShop -

Image
i need set store in prestashop 1.6 prices different every delivery country. point me correct approach of setting such request? my current idea set each country new shop in multistore, having 107 countries time-consuming. there other solution? thanks! you don't have create multistore. of shipping options same (in terms of price). can create custom zone (e.g., western europe, eastern europe...) , set price rule. http://doc.prestashop.com/display/ps16/managing+carriers creating new carrier using carrier wizard in section, going create complete carrier, z, using carrier wizard. can create many carriers wish. if 1 carrier has different shipping services, should create many carriers in prestashop, , differentiate them names: many of details asked prestashop's forms should provided carriers once have set account or under contract them directly. check them in order make sure configured correctly. create new carrier, click on "add new"

sql - Implicit conversion from int to varchar -

set @waveperiod = convert ( varchar,@value ) + convert (varchar,@value2) is valid sql statement in procedure ? @waveperiod varchar(20) @value , @value2 int i getting error message: implicit conversion int varchar it's valid syntax in sybase ase, see below. did not specify actual database other 'sybase' in tag'... declare @waveperiod varchar(20) declare @value int, @value2 int set @value = 123 set @value2 = 456 set @waveperiod = convert ( varchar,@value ) + convert (varchar,@value2) select @waveperiod result: -------------------- 123456

primary key - Microsoft Access - Duplicate record issue -

Image
i have issue in microsft access have table detailing amount of money paid client identifier particular month. table has not been set primary key table contains 1 record each payment made rather 1 record each individual includes every payment. see link clearer picture. the top table on image have linked example of have , bottom table hoping achieve. can advise me on best way achieve i'm looking for? i'd grateful if direct me somewhere teach me have never used access before , i'm keen learn. it seem me top image setup correctly database. if there single payment per month, make first 2 columns composite key...otherwise, 3 columns composite key. wouldn't want have go in every single month , create new columns month , total payment. database growing in wrong direction. if wanting use bottom image, think excel fine. also...i don't see duplicate records. having multiple rows same id pretty want in case.

c# - Expression.Body as MemberExpression returns null for primitive property -

i using code set value of property via reflection : public static void set<t>(this t target, expression<func<t, object>> memberlamda, object value) { var memberselectorexpression = memberlamda.body memberexpression; if (memberselectorexpression != null) { var property = memberselectorexpression.member propertyinfo; if (property != null) { property.setvalue(target, value, null); } } } but reason when : myobject.set(x=>x.id, 1); where id of type int, can see memberselectorexpression null. have no issue properties of reference type. i not familiar yet expression trees, doing wrong ? the solution use following signature : public static void set<t, tprop>(this t target, expression<func<t, tprop>> memberlamda, tprop value) to make sure memberexpression correctly inferred. "object" generic constraint not specific enough.

javascript - How to prevent a function create a new event window stack when resize -

i have problem, need run function when browser width less 769px . i'm using $(window).resize(); detect when browser changes wide. when adjust size of browser to, example 750px, function generates new stack of event, mean is, if click on button, each event runs twice, , if change browser width again say, 700px, each of them executed 3 times. each change of width of browser long less 769px, new event listener "stacked". how can update event , not allow new 1 created when resizing browser? to recreate problem, follow these steps: here's link jsfiddle reproduces problem. load page click button see initial behavior change size of smallest browser 769px click @ buttons , see new behavior. resize browser smaller width of 769px click on button , see behavior, event runs 3 times code: var app = function() { var tempo, body; var init = function() { body = $('body'); $(window).resize(function() { cleartime

excel - Calculating AVERAGEIF in R by factor level -

in calculating percentiles factor using ave() in r , asked how calculate percentiles within ave() function. task finished, i'm faced more difficult task. take following data: districtname building name x2.yr.avg thirty seventy ionia public schools emerson -0.337464323 -0.196387489 -0.046524185 ionia public schools jefferson -0.318673587 -0.196387489 -0.046524185 ionia public schools ionia middle -0.290854669 -0.196387489 -0.046524185 ionia public schools ionia middle -0.288202752 -0.196387489 -0.046524185 ionia public schools twin rivers el -0.23426755 -0.196387489 -0.046524185 ionia public schools r.b. boyce el -0.202319963 -0.196387489 -0.046524185 ionia public schools twin rivers el -0.142995221 -0.196387489 -0.046524185 ionia public schools emerson -0.141620372 -0.196387489 -0.046524185 ionia public schools jefferson -0.141407078

preg match - php preg_match exclude negative number -

preg_match_all('/(\b[0-9]+)/',"this -44 55433 example",$amatches); this grab numbers, how exclude minus in front of -44. thanks maybe solution you preg_match_all( '/(?:^|[^\-\d])(\d+)/' , 'this -44 55433 example', $matches ); var_dump($matches[1]);

data cleaning - Issue in For loop in R -

i new for loops in r. writing code this: attr <- names(training_data) attach(training_data) for(i in 1:500) { temp_var = attr[i] } the value of attr[1] abcd . when try displaying values of temp_var should abcd , getting "abcd" . quotes: > print(attr[1]) "abcd" how can below (without quotes): > print(attr[1]) abcd basically, want pass attribute names of table in run time , assign values of vector temp variable. how can achieve this? since char data type, getting "" around data.

javascript - Make menu selection before while loop is done -

i have i=1 5 loop sleep 5 seconds. how can make menu selection , continue page before while loop done. when chose menu item selection take place when while loop done. 30 seconds. have tried put while loop in iframe, , load page, still first load next page when while loop done. from index page <link rel="icon" href= (./image/favicon.ico)/> <link rel="stylesheet" href="./db/abcss.css" type="text/css"/> <script type="text/javascript" src="./db/cssnav.js"></script> </head> <body> <div id="wrapper"> <?php include("top.php"); include("indexmenu.php"); ?> <div id="content75"> <div id="h4"> <br/><b><center>velkommen til t</center></b> </div> <div id="h3"><br/><center> text here. </

angularjs - Elementor. How to make it use protractor.conf? -

i started adding e2e tests our project , seems few things changed since last time used protractor. example elementexplorer still useful, elementor way more cooler. in readme says launch running e.g.: webmanager start , elementor http://localhost:3000 . but way ignores protractor.conf. , since have binary path chrome browser in file, along logic clearing cookies , logging app in onprepare function, protractor has know file is. can't find way. starting protractor usual via protractor protractor.conf.coffee , elementor localhost:3000 not working either. says "unable start webdriver session" yes, should launch running webdriver-manager start , use run scripts: protractor script_file_conf.js since save scripts javascript code in repository. remember conf file should have reference script file.

java - If I've Downloaded JDK, Do I Need to Download Eclipse Too? -

i'm pretty new programming , java, i'm not sure. know jdk has own compiler , jre need eclipse? you need jre run java code on computer , jdk write it. however, many programmers tend prefer ide (integrated development environment) use along side writing code, debugging, , execute more efficiently. eclipse example of one, , 1 of many used/preferred ide's (in opinion @ least) out there. however, others exist too: drjava netbeans bluej jcreator these editors more preferred because make easier learn / write code. however, may choose normal text editor (like sublime, atom, textedit, notepad, textmate, etc..) or command line. mac & linux have "vim" built in command line editor tend prefer.

Tableless validation in Rails 4.2 -

i trying validate form, not bound real model, did following: a model class formrequest include activemodel::model attr_accessor :email validates :email, presence: true, email: true end and method in controller # form shown def index @form_request = formrequest.new end but when load page error: unknown validator: 'emailvalidator' what did miss? you don't have email: true validator. to validate email can use regular expression: valid_email = /\a[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, format: { with: valid_email }

javascript - Angular iterate through select options and set selected value -

i have select set states json data: <select name="parentstate" ng-model="selectedstate" ng-options="s.stateid s.statecode s in cstates | orderby:'statecode'"> <option value="">select state...</option> </select> and set selected state state returned logged in user i'm entirely sure how accomplish in angular. here's i've tried , isn't working. angular.foreach($scope.cstate, function (s) { if (s.statecode == xparentstate) { $scope.selectedstate = s.statecode; } }); xparent state initials e.g. 'mi' michigan the ngmodel set stateid (as seen in ngoptions - value text object in array ) - set rather statecode if (s.statecode == xparentstate) { $scope.selectedstate = s.stateid; }

c++ - Effect of std::memory_order_acq_rel on non-atomic variable read in other thread -

i think understand semantics of various memory_order flags in c++ atomic library. however, i'm confused following situation: suppose have 2 threads - thread a, "main execution" thread, , thread b, arbitrary thread part of thread pool tasks can scheduled , run. if perform "read-write-update" atomic operation using std::memory_order_acq_rel , perform non-atomic write on boolean variable, non-atomic write visible other threads? think answer no, unless other threads access atomic variable did "read-write-update" operation. so, example, given global std::atomic_flag variable x , global bool value b, , thread pool object threadpool has member function dispatch , execute arbitrary function handlers in thread: if (!x.test_and_set(std::memory_order_acq_rel) { if (some_condition) b = true; threadpool.dispatch([]() { // executes in thread b if (b) { /* */ } // guaranteed see changes b? }); } so in example, code inside

php - Performance: Lots of Images vs Lots of Directories in a web server -

so developing website company , may have, approx 1,000-5,000 profiles (of vendors , users), have store approx 10 images per vendor on directory on website's server (which retrieved using php), wondering better performing way it. have 2 choices: having images profiles in single folder (single folder having 10,000 images) having separate directories profiles having 10 images each (1,000 folders having 10 images each.) so way should performance of website, on server running linux, better? know @ scale, may not matter concern, may expand, have more profiles , server using slow (you can see impact in performance after include php file). i'll using like: <?php ($i = 1; file_exists("img/vendors/vendor_id_".$i.".jpg"); $i++) { echo "<img src=\"img/vendors/vendor_id_".$i.".jpg\">"; } ?> or <?php ($i = 1; file_exists("img/vendors/vendor_id/".$i.".jpg"); $i++)

R: Extract list columns based on column names and patterns -

i have list (here sample data) my_list <- list(structure(list(sample = c(2l, 6l), data1 = c(56l, 78l), data2 = c(59l, 27l), data3 = c(90l, 28l), data1namet = structure(c(1l, 1l), .label = "sam1", class = "factor"), data2namab = structure(c(1l, 1l), .label = "test2", class = "factor"), dataame = structure(c(1l, 1l), .label = "ex3", class = "factor"), ma = c("jay", "jay" )), .names = c("sample", "data1", "data2", "data3", "data1namet", "data2namab", "dataame", "ma"), row.names = c(na, -2l), class = "data.frame"), structure(list(sample = c(12l, 13l, 17l), data1 = c(56l, 78l, 3l), data2 = c(59l, 27l, 2l), datest = structure(c(1l, 1l, 1l), .label = "exa9", class = "factor"), dattestr = structure(c(1l, 1l, 1l), .label = "cz1", class = "

css - Are irrelevant media queries cached by browsers? -

in fictional stylesheet several media query sections rules within relevant media query processed browser, example @media screen , (max-width: 400px) { .container { width: 95%; } } @media screen , (max-width: 800px) { .container { width: 80%; } } .container 95% wide on screen maximum width of 400px. my question this: though media query max 400px 1 relevant (in fictional example), media query max 800px cached browser, though irrelevant, or not? the browser might cache entire css file these media queries contained in, browsers not cache particular sections of css file. so answer question, yes browser might cache non-active part of media query since might (and will) cache entire css file.

delphi - How to make my file DropSouce be accepted by all targets that works with files? -

i made control represents list of files , want able drag files control other applications work files. implemented idragsource interface (as shown below) when drag, files accepted windows explorer, other applications firefox, yahoo messenger, photoshop... not accept files. have done wrong ? have feeling idataobject not set correctly , i'm afraid have implemet myself... , coplicated job me because started work interfaces. here code reproduce problem: unit unit1; interface uses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, activex, shlobj; type tmycontrol = class(tmemo, idropsource) private function querycontinuedrag(fescapepressed:bool; grfkeystate:longint):hresult; stdcall; function givefeedback(dweffect:longint):hresult; stdcall; procedure dodraganddrop; function getfilelistdataobject:idataobject; protected procedure mousemove(shift:tshiftstate; x,y:integer); override; end; tform1 = class(tform

HDR image opening library -

i tried search question didn't find previous topic. hope didn't miss it. :) anyway; have program open image, applies couple of image enhancing algorithm , save results in folder. works normal images but, obviously, doesn't work hdr files. indeed, if select ".hdr" image , give run, behave didn't gave him image @ all. is there library allow me open , work (open , save) on kind of files? hdr images have high dynamic range. can't open , save in format (like can open jpg , save bmp). there regions bright, , others dark. so need sort of post processing (gamma correction , tone mapping) before storing standard dynamic range format. photoshop that. , there other commercial tools (search hdr processing). if you're looking free, imagemagic or blurate can extent, aren't advanced, , need tweaking.

python - cx_freeze error "cx_Freeze.freezer.ConfigError: no base named Console" -

i'm trying convert python 3.4 program of mine exe distribution. tried using cx_freeze this. however, when run python setup.py build setup.py: from cx_freeze import setup, executable setup( name = "converter" , version = "0.1" , description = "" , executables = [executable("filename.py")] , ) i error code: c:\python34>python setup.py build running build running build_exe traceback (most recent call last): file "setup.py", line 6, in <module> executables = [executable("helloworld.py")] , ) file "c:\python34\lib\site-packages\cx_freeze\dist.py", line 362, in setup distutils.core.setup(**attrs) file "c:\python34\lib\distutils\core.py", line 148, in setup dist.run_commands() file "c:\python34\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) file "c:\python34\lib\distutils\dist.py", line 974, in run_command c

How to get select option value from javascript to jsp -

my html having selection option value box,if select option box ,i value in javascript want value in jsp because using string showing selected rows database,i tried request.getparameter didn't work code: <script type="text/javascript"> function getappid() { var value=document.getelementbyid("planeselect").value; document.getelementbyid("demo").innerhtml="application id:"+value; } </script> <select id="planeselect" onchange="getappid()"> <% set<string> set=appslist.keyset(); (string s:set) { string appname = (string) appslist.get(s); %> <option value="<%=s%>"><%=appname%></option> <% } %> </select> on change can load page , use request.getparameter() <script type="text/javascript"> function getappid() { var value=d

sql - Select Record with common column field -

i have following table duplicate id.i want record duplicate id create table student1 (`id` int,`status` int,`amount` int , `name` varchar(10), `date` varchar(55)) ; insert student1 (`id`,`status`,`amount`, `name`, `date`) values (1,0,4500, 'ram', '04/02/2012'), (2,0,2000, 'shyam', '05/09/2013'), (2,0,6500, 'radhe', '11/11/2014'), (2,0,8000, 'radheshyam', '15/11/2013'), (4,0,1500, 'ghanshyam', '08/11/2014') ; id status amount name date 1 0 4500 ram 04/02/2012 2 0 2000 shyam 05/09/2013 2 0 6500 radhe 11/11/2014 2 0 8000 radheshyam 15/11/2013 4 0 1500 ghanshyam 08/11/2014 query: select * student1 group id having count(*)>1 result: id status amount name date 2 0 2000 hyam 05/09/2013 expected result : id status amount name date 2 0

python - Accessing array elements by internal data index and order -

this algorithmic problem bit complex me: i have numpy array of data internally indexed in peculiar way. data output of 2 arrays spliced (which don't have), distinct ordering. set parameter max positive integer, , data output has index format [ 00 10 20 ... max0 11 12 ... max1 22 23....max2 33....max max ] the parameter max determines output of array (i.e. length of array) , ordering. for several examples, max=2 , data of order [00 10 20 11 21 22] setting max=3 gives [00 10 20 30 11 21 31 22 32 33] and max=4 [00 10 20 30 40 11 21 31 41 22 32 42 33 43 44] and on. i write algorithm make list/array of 3x values, i.e. values first index 3. is, access certain data values, organized first index. however, determined parameter max . can see, determines datum placed array index. idea make sort of sorting tree, not sure how execute max parameter. this list comprehension (or iteration) produces indexs show [[j*10+i j in range(i,max+1)] in range(max

html - How to change div contents with javascript -

this seems simple don't know i'm doing really. have 2 radio buttons , depending on 1 selected contents of div change. right have 2 divs inside parent div hide 1 div , show other. wouldn't bad if didn't take space when they're invisible. html: <div> <form role="form"> <div> <div class="radio" id="radioselection" onchange="choosediv()"> <label> <input type="radio" name="optradio" id="selectiondiv1" checked />choose div1 </label> <label> <input type="radio" name="optradio" id="selectiondiv2" />choose div2 </label> </div> </div> </form> </div> <div id="parentdiv"> <div id="div1">you're awesom

android - options menu action bar -

can see why icon isn't showing in action bar? have pasted relevant parts of code below thank you menu topline.xml: ` <item android:id="@+id/gohome_id" android:title="home" trial10:showasaction="ifroom" /> <item android:id="@+id/helpme_id" android:title="help" android:icon="@drawable/ic_questionmark" android:orderincategory="200" trial10:showasaction="always" /> ` styles.xml: <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> </style> <style name="customactionbartheme" parent="@android:style/theme.holo.light.darkactionbar"> <item name="android:actionbarstyle">@style/myactionbar</item> </style> <style name="myactionbar" parent="@android:style/widget.holo.light.actionbar.solid.inverse"> <it

ios - Remove one view's layout constraints but keep its subviews'? -

working on project in ios 8 using storyboard , auto layout: in storyboard, specified constraints view , subviews in code, in response touch events, i'm going change view's size setting frame to make both 1 , 2 warning free, i'm doing following when first changing size code: [theview removeconstraints:theview.constraints]; theview.translatesautoresizingmaskintoconstraints = yes; theview.frame = cgrectmake(0,0,width,height); if not doing first line, xcode complain whole bunch constraint conflicts, adding line remove subview's constraints well. question is: there way remove uiview's constraints not subview, button on still wants center self relative view's size , position? first, don't need resize view setting frame otherwise point of keeping constraint @ first place. have position having correct initial frame. secondly, have mis-conception "to-whom" constraint has been applied to. say button on still wants center self

javascript - jquery - Changing styling of a class containing a particular child class -

i want height of .pst increased if contains child class .pa , code below doesn't work, , if use '.pst' instead of this keyword div elements .pst changes. help! window.onload = function() { if($('.pst').contents().find('.pa').length !=0){ $(this).css('height','+=200px'); } } <div class="pst"> <div class="pa"></div> <div class="pa"></div> <div class="pa"></div> <div class="pa"></div> </div> <div class="pst"> <div class="pb"></div> <div class="pb"></div> <div class="pb"></div> <div class="pb"></div> </div> i want height of .pst increased if contains child class .pa you using $(this) in if condition refers global window object not current .pst element. consider using

Cannot reset or replace default font in the Android application -

i set default font on application, , don't think fits on ui, wanted reset it. don't know how reset it. here codes, , solutions problem appreciated. (1) first created fontoverride class replace default font new one. public class fontsoverride { public static void setdefaultfont(context context, string statictypefacefieldname, string fontassetname) { final typeface regular = typeface.createfromasset(context.getassets(), fontassetname); replacefont(statictypefacefieldname, regular); } protected static void replacefont(string statictypefacefieldname, final typeface newtypeface) { try { final field staticfield = typeface.class.getdeclaredfield(statictypefacefieldname); staticfield.setaccessible(true); staticfield.set(null, newtypeface); } catch(nosuchfieldexception e) { e.printstacktrace(); } catch (illegalaccessexception e) { e.printstacktrace(); } } } (2) , created class named appconfig controls overall c