Posts

Showing posts from July, 2015

Php: defaulting optional param performance -

in php, there difference in performance if calling function fills in optional parameters (with respective defaults), or leave them blank? for example: function foo($id, $a = '', $b = false) { ..... } which faster: foo(1234); or foo(1234, '', false); it doesn't matter far speed, helps out readability , code duplication. setting defaults means, don't have set same values in multiple places in code stack means readability , consistency!

database - Having great difficulty implementing login system using SQLite in Java -

private void jbutton1actionperformed(java.awt.event.actionevent evt) { string query; boolean login = false; string username = jtextfield1.gettext(); string password = jtextfield2.gettext(); try{ query = "select (cusername , cpassword) customer cusername = '"+username+"' , cpassword = '"+password+"'"; pst = conn.preparestatement(query); pst.setstring(1, username); pst.setstring(2, password); pst.executequery(); string usercheck = rs.getstring(1); string passcheck = rs.getstring(2); if((usercheck.equals(username)) && (passcheck.equals(password))) { login = true; system.out.println("it works?!"); } else { login = false; system.out.println("psyche, that's wrong number!"); } } catch(exception e){ system.out.println(e); } system.exit(0); }

apache - PHP mail will only send with two recipients -

using php mail() function on server client when do: mail("name@domain.com",$sub,$body,$head); it fails (returns nothing , not sent) if do: mail("name@domain.com,x",$sub,$body,$head); it works fine i have set this, client can work mail("name@domain.com,no-reply@domain.com",$sub,$body,$head); which not great solution, ideas? thanks andy if second senario works fine in case can use $receivers = array( "name@domain.com", "no-reply@domain.com" ); foreach ($receivers $receiver) { // send email 1 one recipients mail("$receiver,x",$sub,$body,$head); } ?>

c# - Value of TempData becomes null after "Redirect" -

i facing issues tempdata after redirect . public actionresult logincredentials() { // calling "seterror()" in catch(), if password mismatch. try{} catch() { return seterror(); } } public actionresult seterror() { // set value of tempdata "true" tempdata["error"] = true; return redirect("/login"); } public actionresult index() { viewdata["useerror"]= tempdata["error"]; // @ point tempdata["error"] null. ... } in seterror() value of tempdata set true, issue takes place after "redirect", value becomes "null" , can't use anymore. maybe browser cookieless the data in tempdatadictionary object persists 1 request next, unless mark 1 or more keys retention using keep method, accoding code, if redirect login page, , redirect index, value null. can read @ login page.

ruby - How can i refresh token using omniauth gem? - Rails 4.2 -

so far have managed login users google plus using omniauth-google-oauth2 gem. as far concerned access token expires @ time. how can refresh token google api lets once week if user logins google plus on website in week now? below code have in sessioncontroller.rb def google_oauth2 auth_hash = request.env['omniauth.auth'] @identity = identity.find_by_provider_and_uid(auth_hash["provider"], auth_hash["uid"]) if @identity log_in @identity.user flash[:success] = "welcome, #{@identity.user.name}!" else random_password = securerandom.urlsafe_base64(n=6) #@user = create_with_omniauth(auth_hash) @user = user.new( name:auth_hash['info']['name'], email:auth_hash['info']['email'], password:random_password, password_confirmation:random_password, activated:true ) @user.identities.build( uid: auth_hash['uid']

php - symfony 2 - object created twice -

in current symfony project work doctrine. in 1 of controllers creating object , saving db: $article = new article(); $article->setname('article'); $em = $this->getdoctrine()->getmanager(); $em->persist($article); $em->flush(); $data = $this->prepareindexaction(); $html = $this->container->get('templating')->render( 'index.html.twig', ['data' => $data] ); return new response($html); this object saved 2 times database. anybody knows how deal this? greetings , thanks!

Android - Time Comparison "hh:mm:ss a" format -

"i try compare 2 time in "hh:mm:ss a" format. not work in think. googled couldn't find proper answer. sorry cause i'm new programming." i try compare time this: string strsql = "select * " + table_schedule + " lecturer_id=? , schedule_day=? , schedule_endtime > ?"; schedule_endtime > ? however, comparison has ignored am/pm caused result become this: eg. 12:00:00 pm bigger 02:00:00 pm. hope can give tips or provide solution. appreciate it. instead of comparing formatted string, compare value in milliseconds. take @ convert string date : simpledateformat formatter = new simpledateformat("dd-mmm-yyyy"); string dateinstring = "7-jun-2013"; try { date date = formatter.parse(dateinstring); system.out.println(date); system.out.println(formatter.format(date)); } catch (parseexception e) { e.printstacktrace(); } then once have 2 dates can compare them so: boolean before =

javascript - dynamic dropdown list with jquery and sqlite show incorrectly -

i try use sqlite create dynamic dropdown list. sql tabels country, country_district , district. country tabel have c1 , c2. district table have d1,d2,d3,d4. country_district gave pair (c1,d1),(c1,d2),(c1,d3) , (c2,d4). select c1 in country dropdown , d1 in district dropdown. after change selection in country c2. district dropdown still show d1 wan empty string. thank $(document).ready(function () { $("#country").change(function () { country = $(this).val(); $('#district option:eq(0)').attr('selected','selected'); db.transaction(changecountry, errorcb, sucesscb); }); }); function changecountry(tx) { tx.executesql('select d.* country_district cd , district d cd.country=? , cd.district = d.district', [country], renderdistrictlist, errorcb); } function renderdistrictlist(tx, results) { var len = results.rows.length; var htmlstring = "<option value=\"\" > </option>"

java - Where can I check whether a particular jdk version is compatible with Windows server -

where can check whether particular jdk version compatible windows server 2008 and/or server 2012. i need below list.but didn't found in oracle website. j2se development kit 5.0 update 11 j2se development kit 5.0 update 12 j2se development kit 5.0 update 15 j2se development kit 5.0 update 18 j2se development kit 5.0 update 21 j2se development kit 5.0 update 22 j2se development kit 5.0 update 6 j2se development kit 5.0 update 7 j2se runtime environment 5.0 update 10 j2se runtime environment 5.0 update 11 j2se runtime environment 5.0 update 12 j2se runtime environment 5.0 update 15 j2se runtime environment 5.0 update 16 j2se runtime environment 5.0 update 18 j2se runtime environment 5.0 update 19 j2se runtime environment 5.0 update 2 j2se runtime environment 5.0 update 21 j2se runtime environment 5.0 update 22 j2se runtime environment 5.0 update 4 j2se runtime environment 5.0 update 5 j2se runtime environment 5.0 update 6 j2se runtime environment 5.0 update 7 j2se runtime envi

perl - Sorting multidimensional array with exceptions -

i have file contains time , data. need sort array time, there 2 snags: if time 23:59:59:999 or null, needs stay in relation else. i've taken in file , placed in array of arrays. for example: data1 10:25:34.001 data2 data1 10:25:34.002 data2 data1 10:25:34.005 data2 data1 null data2 data1 null data2 data1 null data2 data1 10:25:34.006 data2 data1 10:25:34.007 data2 data1 10:25:34.008 data2 data1 23:59:59:999 data2 data1 23:59:59:999 data2 data1 10:25:34.003 data2 data1 10:25:34.004 data2 data1 10:25:34.010 data2 data1 10:25:34.011 data2 should become: data1 10:25:34.001 data2 data1 10:25:34.002 data2 data1 10:25:34.003 data2 data1 10:25:34.004 data2 data1 10:25:34.005 data2 data1 null data2 data1 null data2 data1 null data2 data1 10:25:34.006 data2 data1 10:25:34.007 data2 data1 10:25:34.008 dat

matplotlib - Anaconda Python 3.4 using Seaborn figure too tight -

i developing hierarchal clusters in form of dendrograms using python 3.4 , seaborn, using work of olga botvinnik ( http://nbviewer.ipython.org/gist/olgabot/bfe1e3638af3eea52fb1# ). goal cluster u.s. cities based on greenhouse gas emissions. able read csv file , create figure residential , commercial buildings emissions on x axis , city names on y axis, cannot see of city names because squished together. image needs elongated can read it. can point me in direction? import pandas pd import seaborn sns import matplotlib.pyplot plt data = pd.read_csv('/users/jcmartel 1/desktop/ghg_directory/rescom.csv', index_col=0) data.index = data.index.map(lambda x: x.strip()) sns.clustermap(data); #need improve layout fig = plt.gcf() fig.savefig('clustermap_bbox_tight.png', bbox_inches='tight') following final script using: import pandas pd import seaborn sns import matplotlib.pyplot plt data = pd.read_csv('/users/jcmartel 1/desktop/ghg_directory/ghg

java - CardLayout - how to change name of component -

is there way change name of panel added panel cardlayout? want use show method without having use name gave panel when added main panel. jpanel panel = new jpanel(); add(panel, "0"); show(this, "0"); ... // change name of panel "1" show(this, "1"); // can show panel // original cardpanel1 name "card1" cardlayout lay = (cardlayout)parentpanel.getlayout(); lay.removelayoutcomponent(cardpanel1); lay.addlayoutcomponent(cardpanel1, "card4"); // cardpanel1 can shown using "card4" name

java - JavaFX filter ListView File elements using FileFilter -

Image
i hava javafx application shows folders of specific directory , watches new/deleted folders , updates listview . now i'm trying let user filter/search folders using textfield . i've done before, relevant code: @override public void initialize(url location, resourcebundle resources) { // configure other stuff configurelistview(); } private void configurelistview() { searchfield.textproperty().addlistener((observable, oldval, newval) -> { handlesearchontype(observable, oldval, newval); }); // more stuff here } private void handlesearchontype(observablevalue observable, string oldval, string newval) { file foldertosearch = new file(config.getdlrootpath()); observablelist<file> filteredlist = fxcollections.observablearraylist(foldertosearch.listfiles( pathname -> pathname.isdirectory() && pathname.getname().contains(newval))); // seems wrong here?! if (!searchfield.gettext().isempty()) { lis

Formulas for Lists/Tables in Excel VBA -

trying add formula list/table programmatically via vba not sure correct syntaxis. i need add formula looks similar below: activesheet.range("b2")="[@turnover]/sum([turnover])" where "turnover" name of column. i guess there issue escaping characters, couldn't find reference or workaraounds. you're close! when giving range formula want use: activesheet.range("b2").formula = "=[@turnover]/sum([turnover])" it inputs string formula range.

OLAP cube powering Excel Pivot. What's a better solution? -

i'm looking build dynamic data environment non-technical marketers. want provide large sets of data in excel pivot table form marketers without analytics/technical backgrounds can access relevant performance information. i'm trying avoid non-excel front ends since don't want users have export data when need manipulate in way. my first thought throw olap cube populated pre-aggregated data, got pushback team olap "obsolete." don't disagree them - there faster data processing architectures out there. so question this: there other ways structure data marketers can access still manipulate degree in excel? i'm working 50-100m rows of data , need ability scale dimensionality. this thoughts. really question thrown @ team. first thought throw olap cube. didn't this. if they're achingly hip consider olap "obsolete", suggest better, more up-to-date alternative? or, put different way - substance of objection olap solution? (i

vba - Text Function for multiple cells -

i wanted know if there alternative method (than loops) using text function on multiple cells. for example, below code work correctly lookups range("c2:c6").value = application.worksheetfunction.vlookup(range("a2:a6"), range("a2:b6"), 2, 0) however error below text functions range("c2:c6").value = application.worksheetfunction.text(range("a2:a6"), "000000") surly want format cells , copy values? like below? range("c2:c6") .value = range("a2:a6").value .numberformat = "000000" end the macro recorder gave me similar above optimisations using formula range("c2").formular1c1 = "=text(rc[-2],""000000"")" range("c3").formular1c1 = "=text(rc[-2],""000000"")" range("c4").formular1c1 = "=text(rc[-2],""000000"")" range("c5").f

java - Spring treating servlet contextConfigLocation class as path despite correct contextClass -

we're using javaconfig, , i'm trying set separate application context around issues in jersey 1.7 (namely, way includes spring beans annotated @controller in paths). i've set springservlet want use separate application context so: <servlet> <servlet-name>my servlet</servlet-name> <servlet-class>com.sun.jersey.spi.spring.container.servlet.springservlet</servlet-class> <init-param> <param-name>com.sun.jersey.api.json.pojomappingfeature</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>com.sun.jersey.config.property.resourceconfigclass</param-name> <param-value>com.sun.jersey.api.core.packagesresourceconfig</param-value> </init-param> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.mycompa

c# - WPF - CollectionViewSource Custom Sorting: Sort items within the groups, without sorting the groups themselves -

simple question, except fact answer seems not exist. i've created custom sorting method collectionviewsource sorts collection groups in specific order. want sort items within groups alphabetically, without altering order of groups themselves. i know using sortdescriptions , sorting property name followed sortdescrpiton property name sort items groups , sort items in said groups. not find such implementation custom sorting methods. (note: sortdescriptions not allow custom sorting logic, require) i tried create 2 sorting methods, 1 sort groups , other alphabetically sort within groups second sort method received ungrouped , unsorted original list of items reason. xaml collectionviewsource: <collectionviewsource x:key="typefacetsbycategory" source="{binding values}"> <collectionviewsource.groupdescriptions> <propertygroupdescription propertyname="category" /> </collecti

Sending a KEY to a Page with Selenium IDE -

i need simulate pressing f5 trigger refresh of site. idea using sendkeysandwait ${key_12}, understand it, need element target command. with webdriver solved problem this: actions action = new actions(_driver); action.sendkeys(keys.f12).perform(); is there way send f12 or other key page? i tried sending event body, doesn't work. i tried sending event first input find (this works dont want it, there sites without input elements in out appplication) my last hope javascript file. created function , added selenium core extensions : selenium.prototype.dohotkey = function(target,value) { var keyboardevent = document.createevent("keyboardevent"); var initmethod = typeof keyboardevent.initkeyboardevent !== 'undefined' ? "initkeyboardevent" : "initkeyevent"; keyboardevent[initmethod]( "keypress", // event type : keydown, keyup, keypress true, // bubbles true, // cancelable

Pass name to nested function in Python? -

what (if anything) different between using name in nested function , passing name nested function? if there's no difference, preferred convention? def foo(bar): def put(): bar.append('world!') print(', '.join(bar)) put() foo(['hello']) versus def foo(bar): def put(bar): bar += ['world!'] print(', '.join(bar)) put(bar) foo(['hello']) the difference in first one, bar variable in scope of parent function, can used in child function , unless assignment on (this case similar using global variables in function) . example - >>> def foo(bar): ... def put(): ... bar = bar + ['world'] ... print(', '.join(bar)) ... put() ... >>> >>> foo(['hello']) traceback (most recent call last): file "<stdin>", line 1, in <module> file "<stdin>", line 5, in foo file "&

r - Error Installing caret on AWS Red Hat Linux -

i'm trying install r package caret r -e "install.packages('caret', repos='http://cran.rstudio.com/')" on amazon linux ami dependancies rcppeigen,lme4, bradleyterry2 fail. warning messages: 1: in install.packages("caret", repos = "http://cran.rstudio.com/") : installation of package ‘rcppeigen’ had non-zero exit status 2: in install.packages("caret", repos = "http://cran.rstudio.com/") : installation of package ‘lme4’ had non-zero exit status 3: in install.packages("caret", repos = "http://cran.rstudio.com/") : installation of package ‘bradleyterry2’ had non-zero exit status 4: in install.packages("caret", repos = "http://cran.rstudio.com/") : installation of package ‘caret’ had non-zero exit status when try install rcppeigen (among other verbose massages): /usr/bin/ld: cannot find -lrlapack /usr/bin/ld: cannot find -lrblas collect2: ld returned 1 exit status make

What does comparable mean in Elm? -

i'm having trouble understanding comparable in elm. elm seems confused am. on repl: > f1 = (<) <function> : comparable -> comparable -> bool so f1 accepts comparables. > "a" "a" : string > f1 "a" "b" true : bool so seems string comparable. > f2 = (<) 1 <function> : comparable -> bool so f2 accepts comparable. > f2 "a" infer type of values flowing through program, see conflict between these 2 types: comparable string so string is , is not comparable? why type of f2 not number -> bool ? other comparables can f2 accept? normally when see type variable in type in elm, variable unconstrained. when supply of specific type, variable gets replaced specific type: -- says have function: foo : -> -> -> int -- once give value actual type foo, occurences of `a` replaced type: value : float foo value : float -> float -> int comparab

sql - MySQL count rows from multiple tables using join -

i have 3 mysql tables: **locations** id location_name 1 london 2 new york 3 washington **bookings** id voucher_code location_id 1 disc100 1 2 null null 3 disc200 1 4 disc500 2 5 disc700 1 **vouchers** id voucher_code net_value 1 disc100 155.00 2 disc200 135.00 2 disc500 155.00 2 disc700 155.00 i'm trying display count of voucher net values each location. example can see 'london' location has 3 vouchers have been redeemed in bookings table, of 2 155.00 values vouchers , 1 135.00. need write mysql query pull these counts out of database. so using above tables example, sql query should result in following: location netvalue155 netvaue135 london 2 1 new york 1 0 washington 0 0 below have written far: sel

css - How can i create horizontal line between heading? -

how can create horizontal line between heading? --------heading------ is possible make line attractive zig zag or other customization. using wordpress & know css screenshot - screenshot

c# - Entity Framework 6 - Enforce asynchronous queries, compile time prevent synchronous calls -

with move ef6.1, our goal use exclusivity async/await options speaking our data sets. while porting our previous linq2sql, there many .tolist(), .firstordefault(), , .count()'s. know can search , fix all, nice if could, @ compile time, prevent functions being permitted build. have have creative idea on how accomplish this? if compiler warnings thrown (such use of obsolete attribute). you can use .net compiler platform write diagnostic , code fix these patterns , provide warnings/errors. you implement syntax transformation automatically change these constructs - though effort might more expensive doing hand.

compiler errors - OkHttp Request is not public in com.squareup.okhttp; cannot be accessed from outside package -

i'm trying okhttp work in android studio project, created class , pasted in following code here: https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/com/squareup/okhttp/recipes/parseresponsewithgson.java package com.my.project; /** * created me on 07/08/2015. */ import com.google.gson.gson; import com.squareup.okhttp.okhttpclient; import com.squareup.okhttp.request; import com.squareup.okhttp.response; import java.io.ioexception; import java.util.map; public final class parseresponsewithgson { private final okhttpclient client = new okhttpclient(); private final gson gson = new gson(); public void run() throws exception { request request = new request.builder() .url("https://api.github.com/gists/c2a7c39532239ff261be") .build(); response response = client.newcall(request).execute(); if (!response.issuccessful()) throw new ioexception("unexpected code " + response); gist gist = gson.fromjson(

node.js - Verify if OpenId provider is valid -

i trying make user log in steam account via openid. able make request steam openid , log in user. my concern dont have way confirm openid provider valid. if cant verify provider, hacker make succesful response website in order log in. thought there might way confirm url of provider, have no idea hot this. so how make sure provider steam , not 3rd party? (i using passport-openid library) you extract user's openid provider page give @ openid url login form. that's place you'll know openid provider user wishes use. unless url https 1 cannot sure there wasn't man-in-the-middle-attack gave different openid provider application.

database - Postgresql pagination -

i came know postgresql pagination (using limit , offset ) damn slow, unfortunately, late me understand this, because 1 of small web app project uses db , development over. i have seen few workarounds in , other sites, of them uses indexes , things that. not suit me because have create many indexes (there few dozens of tables) tables , have rewrite queries. question : is there way can avoid without spending more time (creating indexes , rewriting query, etc) ? mean, simple workaround ? i have not felt slow mysql (and guess, oracle), hence, postgresql people improving in future versions ? or won't @ ? (if have plan, keep on postgresql, if not go mysql, because typical web app/erp have lot of pagination requirements, , not wise work basic need) pagination?.. if mean limit offset quite fast. comparing limit rownum of oracle, limit n,o in mysql... quite same in aspects so answers be: without spending time - nothing happen things being improved in every versi

regex - Attach a string to every group of substrings separated by a set of symbols -

imagine have string newton = 'kg*m/s^2' and need be: newtonmupad = 'unit::kg*unit::m/unit::s^2' is there simple way detect every physical unit , attach unit:: it? can assumed every unit seperated either / , * or exponent ^2 or ^3 . for used several regular expressions, like x = regexp(newton ,'*','split') y = regexp(newton ,'/','split') z = regexp(newton ,'^','split') and i'm able create string need loop. wonder if there simpler , faster solution using matlab? you can use regexprep : >> newton = 'kg*m/s^2' >> regexprep(newton,'(([a-za-z]+)(*|/|\^|$))', 'unit::$1') ans = unit::kg*unit::m/unit::s^2

angularjs - Ng-repeat doesn't works with localStorage -

something weird happening localstorage. data saved in localstorage never displayed in ng-repeat. however, when data less 2 items, in case, displayed on screen. when greater 2 not shown. controller code $scope.saved = localstorage.getitem('todos'); if($scope.saved != null ) { $scope.invoice = { items: json.parse($scope.saved) }; } else { $scope.invoice = { `enter code here` items : [{ qty: 10, description: 'item', cost: 9.95}] }; } and addition code: $scope.additem = function(x) { $scope.invoice.push({ qty: 1, description: x.cakename, cost: x.id }); localstorage.clear(); localstorage.setitem('todos', json.stringify($scope.invoice)); }; this table code: <div> <table class="table" style="margin-top:50px"> <tr> <th>name</th> <th>qty</th> <th>cost</th&g

progress bar - C# ProgressBar initial display not working -

i have problem winform in visual studio 2010 progress bar. making 2 progress bars read files folder, 1 amount of files , other amount of lines. progress bars instantiated , line progress bar display standard green progress bar, file progress bar not display till after update or two. i have tried this.progressbar1.show() , this.progressbar1.visible = true , not work in case. any appreciated :) this.progressbar1.location = new system.drawing.point(15, 25); this.progressbar1.name = "progressbar1"; this.progressbar1.size = new system.drawing.size(373, 23); this.progressbar1.tabindex = 0; this.progressbar1.visible = true; here methods in program: public progressbar() { initializecomponent(); } public void settitle(string title) { this.text = title; } public void setmessage(string txt) { label1.text = txt; label1.refresh(); } public void setfile(string txt) { label2.text = txt; label2.refresh(); } private void timer1_tick1(object sender, event

linux - Centos 6.7 cron bug run-parts starts twice -

just updated couple of centos latest version 6.7 via yum (official repository) , since experiencing problems cron while executing cron.hourly scripts. seems run-parts program starts twice scripts in cron.hourly folder. from cron log can see (look @ mailgraph script): aug 7 22:01:01 spam run-parts(/etc/cron.hourly)[8066]: starting mailgraph aug 7 22:01:01 spam run-parts(/etc/cron.hourly)[8180]: finished crm114_cleanup.sh aug 7 22:01:01 spam run-parts(/etc/cron.hourly)[8067]: starting mailgraph aug 7 22:01:02 spam run-parts(/etc/cron.hourly)[8194]: finished mailgraph aug 7 22:01:02 spam run-parts(/etc/cron.hourly)[8066]: starting rules.php aug 7 22:01:02 spam run-parts(/etc/cron.hourly)[8203]: finished mailgraph i see script mailgraph started twice, before first 1 ends , causes error script itself. i have situation on different machines, since last upgrade latest centos 6.7. installations centos 6.6 working ok. any idea? thanks found it! upgrade restored file

php - Dynamically select fields from a list and add them to a form -

in form need dynamically add (and remove) fields (0 n) select. every item should removed list after being added can't selected twice. for example have select this: <select name="list">     <option value="1">a</option>     <option value="2">b</option>     <option value="3">c</option>     <option value="4">d</option>   </select> and want add new field in form shows , d , stores values can through post. if click on select, there b , c. can me? what type of fields want? input type text? if so: $("[name=list]").on("change", function (e) { var val = $(this).val(); if (val.length > 0) { $(this).find("option:selected").remove(); $("<input>").attr("name", "the-name").val(val).appendto($("#the-form")) } }); check out fiddle https://jsfiddle.net/etoysp

Class Design in C++ program -

i'm working on little project in c++. i'm new c++/programming , wanted ask how classes should designed. to specific: want write little program chatting. simple communication between 2 programs/computers. want use class design because, although small project (just sake of learning), want designed , extensible. my program should have 5 classes ( handlers etc, updater , app - main class program). i'll give few examples of ideas have how design 1 part of program. first part should connection part (handled connection ). task build connection between 2 programs. set local files, hold information print, , connect 'server' file. later in program there should access file_handler class can edit/read local file , read/request write 'server' file. (how it's gonna figured out, long not necessary i'd keep system ;) ). let's ideas have: idea 1 app creates instance of connection set connection. connection creates instance of file_handler

ruby on rails - Paperclip: Permission denied error -

paperclip works fine on localhost, on deployed app, returns following error when try update avatar: errno::eacces in userscontroller#update permission denied - /rails_apps/website/releases/20150807211111/public/system/users/avatars/000/000/562 this line in users controller getting singled out: if @user.update_attributes(user_params) this in user model: has_attached_file :avatar, :styles => { :full => "400x720" }, :processors => [:cropper] validates_attachment_content_type :avatar, :content_type => /\aimage\/.*\z/ my server uses ubuntu 10.04.4 lts. what error mean , how can fix it? this seems problem file permissions , not ruby on rails. try run following command in terminal logged in user runs web server: chmod -r +w /rails_apps/website/releases/20150807211111/public

Embedded SurveyMonkey survey not appearing on mobile -

i'm looking embed existing survey monkey survey webpage, following instructions here: http://help.surveymonkey.com/articles/en_us/kb/website-collector which working on desktop , tablet sizes, reason not working on mobile (either on android device or in chrome emulator) the following steps appear working: loading embed script page embed script calls surveymonkey.com, , retrieves smcx script smcx.boot() called but, survey (or markup) not appear in page. has else run issue? other additional information can provide? the website collector used work everywhere, changed api , document mobile not supported. http://help.surveymonkey.com/articles/en_us/kb/website-collector "website collectors display on desktop browsers only—not on mobile devices or tablets." it's worse not supporting mobile or tablets, surveys don't load on desktop browsers if browser 760 pixels or less wide. the solution iframe web link in manually. <iframe height

sql server - Why is SSIS job using connection manager parameters in package to validate instead of configuration file values? -

i have ssis package run sql server agent job configuration file specified in job contains servers , initial catalogs connection managers of package. running fine in production , using servers , databases specified in configuration file when package runs. however, when changed table in dev environment, production package failed validation because apparently validating package based on dev database specified in connection managers in package (which naturally point dev environment) , using config file values when running package. absurd, of course. how stop doing that? should both validate , run using config file parameters, otherwise point of using config files?! i should clarify production job ran without problems after generating errors internally, have error handling task emails me details of errors package raises during execution. getting emails of failures packages didn't encounter errors when ran not thing. i using ssis in sql server 2008 r2 , both ssis package , xml co

angularjs - jqxgrid and angular form -

i'm using jqxgrid inside angular form. when change in grid, angular form not become dirty. decided bind grid cellvaluechaned event in call $setdirty() angular form. works. not want in each place form used call $setdirty(). please tell me how can find closest form in dom tree , make dirty? want write code 1 time , want works each form there grid inside these forms. guys. you can create directive loop on necessary html elements under , add relevant events. here's template started: angular.module("app", []).directive("changeform", function() { var directive = { restrict: 'a', require: 'form', link: function(scope, element, attrs, ctrl) { // here use element.find() elements // , use .on() on elements event // , use ctrl (which of type formcontroller) // set $dirty [https://docs.angularjs.org/api/ng/type/form.formcontrol

html - How to make a paper-toolbar stay at bottom? -

i using polymer paper elements. need 2 toolbars page, 1 @ top , other @ bottom. how make other one. i have looked here answer. core-toolbar , using v1.0. still on using .bottom , toolbar remains on top. thanks i use flexbox things this. here's example paper-header-panel: <paper-header-panel> <paper-toolbar><span>top toolbar</span></paper-toolbar> <div class="layout vertical fit"> <div class="layout flex">content</div> <paper-toolbar><span>bottom toolbar</span></paper-toolbar> </div> </paper-header-panel> note using iron-flex-layout & should use mixin version of layout styles instead of classes directly i've done here (i.e. @apply(--layout-vertical), etc) or use flexbox styles directly.

Can't post back JavaScript changes to ASP.NET ListBox option properties/attributes -

i'm trying use javascript change properties or attributes of asp.net listbox's options, changes server sees on postback (asp:button click) selected state of options. i'm trying convey ss code should ignore selected options, , hoping use simple noting hidden state, setting option's disabled property, or adding attribute. control, , failed js lines: <asp:listbox id="lstfacilities" runat="server" selectionmode="multiple" height="200" /> //lbxfacs returned document.getelementbyid lbxfacs.options[f].style.display = 'none'; lbxfacs.options[f].disabled = true; lbxfacs.options[f].setattribute('disabled', 'disabled'); i hide them view after selecting filter control, , works ui standpoint, server seems have no way of knowing they're hidden. try disable them, enabled property true. adding attributes useless too; attributes collection empty. server-side snippet: bool allselected

apache - Why isn't curl working with my TLS ngrok tunnel? -

when run curl --insecure 'https://foo.ngrok.io/page' on tls tunnel apache ip-based virtual host, "400 bad request" response saying "your browser sent request server not understand...reason: you're speaking plain http ssl-enabled server port...instead use https scheme access url, please." however if use curl make request directly localhost address e.g. curl --insecure 'https://foo/page' correct response. also, if make request in browser https://foo.ngrok.io/page correct response. i'm running: os x 10.9.5, apache 2.4, ngrok2, , curl 7.43.0. ssl certificate self-signed. what noticed access log when use curl on foo.ngrok.io http/1.1 requests changed http/1.0 requests. also, here's corresponding relevant bits error log: ssl_engine_kernel.c(1824): [client 127.0.0.2:50517] openssl: exit: error in sslv2/v3 read client hello [client 127.0.0.2:50517] ah01996: ssl handshake failed: http spoken on https port; trying send html error

computational geometry - Small circle inside simple polygon -

i've been working on computational geometry problem , ran across following problem (which needed subroutine) failed find references or algorithms. given simple (possibly concave) polygon p, goal compute center , radius of smallest circle contained in p (empty circle) touches polygon in @ least 2 places (point or edge). if 2 "places" happen points of polygon there no constraints. no constraints if hit point , edge. if hit 2 edges should not consecutive (assuming clockwise or counter-clockwise order). i aiming implementable algorithm running in order of n^3 or better. pointers, references, or ideas helpful. thanks! amer since you're looking pointers or ideas, i'll brief. medial axis of polygon set of centers of circles touch boundary in 2 or more locations ( https://en.wikipedia.org/wiki/topological_skeleton#centers_of_bi-tangent_circles ). known skeleton, medial axis consists of tree-like graph made of lines , parabolas. if check circles @ vert

x86 - assembly, segmentation fault -

this code results in segmentation fault, have no idea why it, code supposed pass current location of esp @ stack ebp , use indirect addressing mode on ebp value of address, don't know why os terminating results in segmentation fault .section .data .section .text .globl _start _start: movl $50,%edx pushl, %edx movl %esp,%ebp movl (%ebp),%ebx ## causes problem reason, movl $1,%eax int $0x80 ## program should return exit status of %ebx value as jester says, problem 64bit linux tools default making 64bit programs. has bad habit of writing answers in comments, i'll duplicate here: as --32 test.s -o test.o; ld -melf_i386 test.o -o test or gcc -m32 foo.s -ffreestanding -nostdlib -o foo you segfault at movl (%ebp),%ebx because %rsp isn't all-zero in upper 32 bits, %esp different address %rsp . find problem gdb. you'd have noticed had 64bit registers. see https://stackoverflow.com/tags/x86/info info on using gdb asm. i'm go

xcode - How to search for object in PickerView -

i have search bar , pickerview. in pickerview approx 20 items, need filter them searchbar i don't think there off-the-shelf way this. you'll have maintain array of original items, feed text search bar filter statement, , tell picker view reload using reloadcomponent or reloadallcomponents.

c# 4.0 - How to control zooming of browser using c# code -

i using selenium , application writing code has issues. find login object have zoom in 30% approx. , want control using c# code. so, can me this? you should send hotkeys (ctrl+plus) zooming it: webelement myrootelement = driver.findelement(by.tagname("html")); new actions(driver) .sendkeys(myrootelement, keys.control, keys.add, keys.null) .perform();

regex - Capturing AES encrypted strings (including slashes) with Django URLs? -

i have encrypted string, nituk+n1ly2cjo1jlj9/vdsesld7aqpmwf4iefad3ao8yeiaypqb4tbehabgt0q+ how pass value variable? my url configuration url(r'^secure/(?p<code>[a-za-z0-9/\+]\w+)$', 'user.views.decrypt_url'), thanks regexr changed .* , works. url(r'^secure/(?p<code>(.*))$', 'user.views.decrypt_url'), regexr

Running Powershell With PHP On IIS -

php code -: <?php $user = "email@outlook.com"; $script = "c:\\inetpub\\wwwroot\\shell_script\\sc.ps1"; $query = shell_exec("powershell -command $script <nul"); if($query) { echo "successful" ; } else echo "failed"; } ?> powershell code -: $outlook = new-object -comobject outlook.application $mail = $outlook.createitem(0) $mail.to = "email2@outlook.com" $mail.subject = "new leave request" $mail.body =" dear, email contains body of email" $mail.send() i have powershell installed on laptop windows server 2012 on windows 8. i have website hosted on windows server 2012 iis when run powershell script sc.ps1 on command line on server command ./sc.ps1 mail sent outlook. but when run php page in have shell_exec command mail not triggered outlook , returns page message successful written in php code. work done on windows server 2012 running powershell script o

javascript - Google Maps V3: Pass drag event on marker to map -

Image
i'm drawing multiple radius circles on map following code: function drawradius(size){ var circle = new google.maps.marker({ position: map.getcenter(), zindex: 1, icon: { path: google.maps.symbolpath.circle, scale: size, strokeopacity: 0.65, strokeweight: 4, fillcolor: '#fefcf3', fillopacity: 0.08, strokecolor: '#efe8b2' }, map: map }); } this method called multiple times different size parameters, results in the following image: unfortunately, can't move map anymore, because - far can tell - events fired on circles , not on map. how can fix this? want able drag/move map. thank you! if don't need click on circles (markers), set clickable: false on them, prevents markers receiving mouse events. from the documentation : clickable boolean if true, marker receives mouse , touch events. default value true. function drawradius(size){ var circle = ne

playframework - Not a valid key: eclipse (similar: deliver, licenses, clean) -

i have downloaded typesafe activator , have followed following steps activator new helloworld play-java cd helloworld activator build activator eclipse i got error [warn] global sbt directory versioned , located @ /users/abhi/.sbt/0.13. [warn] seeing warning because there global configuration in /users/abhi/.sbt not in /users/abhi/.sbt/0.13. [warn] global sbt directory may changed via sbt.global.base system property. [info] loading project definition /users/abhi/javaprojects/helloworld/project [warn] global sbt directory versioned , located @ /users/abhi/.sbt/0.13. [warn] seeing warning because there global configuration in /users/abhi/.sbt not in /users/abhi/.sbt/0.13. [warn] global sbt directory may changed via sbt.global.base system property. [info] set current project helloworld (in build file:/users/abhi/javaprojects/helloworld/) [error] not valid command: eclipse (similar: help, alias) [error] not valid project id: eclipse [error] expected ':' (if select

php - PDO Insert does not work -

i have problem can not make request prepared pdo every time returns false me. $table = 'paroles'; $array = array(     'timestamp' => 'valeur',     'cle' => 'valeur',     'titre' => 'valeur',     'paroles' => 'valeur',     'titre_trad' => 'valeur',     'paroles_trad' => 'valeur' );   $values = '';$datas = ''; foreach ($array $key => $value) {     $values = $values.$key.',';     $datas = $datas.':'.$key.','; } $values = trim($values, ','); $datas = trim($datas, ',');   $requestconstr = 'insert '.$table.'('.$values.') values('.$datas.')';   $sth = $this->_db->prepare($requestconstr);   foreach ($array $key => $value) {     $sth->bindvalue(':'.$key, $value);

html - Javascript credit card expiration validation -

i new html , javascript thank in advance help. trying add validation form. having trouble speificlaly credit card expiration date validation. expecting if date previous todays date should trigger alert of "your card expired. please select valid expiration date." let submit expired date. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>assignment 8</title> <meta http-equiv="content-language" content="en-us"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <style type="text/css"> table, th, td { border: 1px solid black; border-collapse: collapse; } </style> <script type="text/javascript&q

combobox - Does JavaFX 8.0 TableView have a sort bug? -

Image
java 8.0 x64, win7 x64, clojure, emacs. i'm doing stuff in clojure tableview wherein i'm proxy ing tablecell can render , edit arbitrary things in it. values fields of map inside atom. code below. makes use of plenty of utility functions , macros make simpler, gist. main thing management of cell's graphic , text properties. there keyboard handler attached combobox knows when user presses enter , etc. handler removed on defocus cell, don't end multiple handlers in object. in example have 3 columns, 1 name of field (a simple cell factory shows text , not editable), 1 value (fancy cell factory), , 1 type (simple cell factory). output, using sample data, looks this: when sort table based on value things seem work fine, follows: normally, when keyboard handler triggers, calls cell's commitedit function, calls tablecell superclass commitedit . tableview magic behind scenes calls column's oneditcommit handler, commits edit database. after