Posts

Showing posts from January, 2011

sql - Join when exact match other other wise join with default value -

i have 2 table , b table a id b c table b id value 1 b 2 default 0 so want join 2 tables on id when matching, otherwise use default value desired results id value 1 b 2 c 0 use left outer join purpose like select t1.id, coalesce(t2.value, 0) value tablea t1 left join tableb t2 on t1.id = t2.id;

sql - Can you run an UPDATE and WITH together? -

i trying run update on table, error error: syntax error @ or near "update" the query is: with first_users ( select min(created_at) first_at, company_id company_id users group company_id ) update companies set first_seen_at = least(first_seen_at, (select first_at first_users id = first_users.company_id) ); can not run updates , withs together? seems weird. my query more complex, why using syntax. when run select * first_users instead of update, works, there's wrong update keyword or something. i suggest changing update . . . from in case. there no reason update records not match. so: update companies set first_seen_at = u.first_at (select company_id, min(created_at) first_at users group company_id ) u companies.id = u.company_id , u.first_seen_at < companies.first_seen_at; postgres started supporting ctes updates in version 9.1 ( http://www.postgresql.org/docs/9.1/stat...

sdl - When coding a game, what am I supposed to use as units? -

i've been using pixels units aspects of game such movement, i've been told bad practice. however, i've never seen explanation on i'm supposed instead. can provide explanation on how handle units in games? it doesn't matter units use; can arbitrary. thing need make sure not fixed screen pixels , because later find out want change scale of things displayed. it's ok if conversion factor happens 1; make sure conversion exists , can change if have reason later. (and, practical matter, don't make conversion 1 because hides bugs if forgot convert in 1 place.) for 3d realistic games, common unit "1 meter". real world units don't matter, idea use unit similar size of objects in world. for tile-based or voxel-based games, common unit width of 1 tile. allows omit conversions, you're less have problem tying tiles pixels because tiles affect game rules anyway.

jquery - onclick with javascript and animate.css -

i don't why won't work. i did animation on div class header (fadeindownbig); want when click on link (a href) header fadeoutupbig. <script> $(function(){ $("a").click(function(){ $("#header1").addclass('animated fadeoutupbig'); }); }); </script> .header{ margin-left:10px; height:350px; background:url(../img/background_header2.jpg); background-repeat:no-repeat; } <div class="header animated fadeindownbig" id="header1" > <div class="menu"> <a class="wow animated fadein hvr-grow-shadow transition" data-wow-delay="0.5s" href="../index.html" >home </a> what doing wrong ? (does not include animate.css) like comment above mentioned clicking on anchor redirect before animations can take place. javascript can make not default action @ on cl...

php - SQL Server Update & Replace Spam in "text" and "ntext" fields -

first , foremost, thank time taking @ issue. an old database table has on 14k spam links injected it, many of in text , ntext fields. have written sql query runs , updates fields not "text" or "ntext" type, unfortunately not update "text" or "ntext" fields @ all. brief information database: running on iis7, sql server 2008, , php enabled (version 5.3). unfortunately have limited capability update database directly or control panel (otherwise have been handled swiftly) writing script in php automatically update compromised tables. script in form runs without error, not have updates in text or ntext fields. the script follows: //basic db connection $conn = database_info; $sql = "select * pages_test_only"; $result = sqlsrv_query($conn, $sql); //loop scrub each table foreach(sqlsrv_field_metadata($result) $fieldmetadata) { //the loop here updates each section of spam (starting </title>) "" (empty/null)...

python - Why does sys.path have "c:\\windows\\system\python34.zip"? -

when imported sys, >>> import sys >>> sys.path ['', 'c:\\program files\\python 3.5\\lib\\site-packages\\pyinstaller-3.0-py3.5.egg', **'c:\\program files\\python 3.5\\python35.zip'**, 'c:\\program files\\python 3.5\\dlls', 'c:\\program files\\python 3.5\\lib', 'c:\\program files\\python 3.5', 'c:\\program files\\python 3.5\\lib\\site-packages', 'c:\\program files\\python 3.5\\lib\\site-packages\\win32', 'c:\\program files\\python 3.5\\lib\\site-packages\\win32\\lib', 'c:\\program files\\python 3.5\\lib\\site-packages\\pythonwin']` i checked whether there file python34.zip in directory, answer no. why showing?

html - how to change styling on the same line within a <div> -

i have part of web page (incorporating bootstrap css) contains <div> id "drop-zone" pick later in javascript implement drag-and-drop functionality: <div id="drop_zone"> <p style="color: darkgray">drop</p> <p style="color: black">test.txt</p> <p style="color: darkgray"> here</p> </div> i have <p> s in there because want vary styling across single line, if use code above, or if swap <p> s <div> s, code renders on multiple lines so: drop test.txt here when want like: drop test.txt here i'm sure easy fix, thoughts here? use <span> instead of <p> .

c++ - Floating Point, how much can I trust less than / greater than comparisons? -

let's have 2 floating point numbers, , want compare them. if 1 greater other, program should take 1 fork. if opposite true, should take path. , should same thing, if value being compared nudged in direction should still make compare true. it's difficult question phrase, wrote demonstrate - float = random(); float b = random(); // returns number (no infinity or nans) if(a < b){ if( !(a < b + float_episilon) ) launchthemissiles(); buildhospitals(); }else if(a >= b){ if( !(a >= b - float_episilon) ) launchthemissiles(); buildorphanages(); }else{ launchthemissiles(); // should never called, in branch } given code, launchthemissiles() guaranteed never called? if can guarantee a , b not nans or infinities, can do: if (a<b) { … } else { … } the set of floating point values except infinities , nans comprise total ordering (with glitch 2 representations of zero, shouldn't matter you), not unlike working normal...

c# - Format datetime from string "20151210T11:25:11123" -

i have string format "20151210t11:25:11123" , can't convert type datetime in c# me? string date = "20151210t11:25:11123"; datetime datea = datetime.parseexact(date, "dd/mm/yyyy hh:mm tt", cultureinfo.invariantculture); you using time of 20151210t11:25:11123 telling parse if formatted dd/mm/yyyy hh:mm tt . format not match string, formatexception. need provide format matches string have. isn't clear me last 5 digits format yyyymmddthh:mm:ssfff parse string 12/10/2015 11:25:11 am . may need adjust last part of format match whatever encoded there in string. string date = "20151210t11:25:11123"; datetime datea = datetime.parseexact(date, "yyyymmddthh:mm:ssfff", cultureinfo.invariantculture) console.writeline(datea); // 12/10/2015 11:25:11

java - How to implement a ClickListener for a button from a custom layout to use in a FragmentDialog -

i'm try set action imagebutton. when dialgofragment called , shown on screen, want preess button , action. when put action inside onclick in code below didn't work. i'm sure that's not right way of doing it. i'm using class fragment: public class generaldialogfragment extends dialogfragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout use dialog or embedded fragment view v = inflater.inflate(r.layout.activity_dialog, container, false); imagebutton mimagebutton = (imagebutton) v.findviewbyid(r.id.image_button); mimagebutton.setonclicklistener(new view.onclicklistener(){ @override public void onclick(view v) { string name = ""; sharedpreferences prefs = getactivity().getsharedpreferences("my_prefs_name", context.mode_private); ...

css - Single Stylesheet Multiple Pages Dreamweaver CS6 -

i have 2 pages share same stylesheet. how make changes one, without affecting other? new coding, please specific possible. for instance: have main image on home page , want delete on practice areas page whenever deletes on pages. help please, , thank in advance! a practice styling pages differently have class name applied body or enclosing div corresponds page, e.g.: <body class="home"> <div>content here</div> </body> this gives greater specificity, in css, writing: .home div { background-image: url('your-image.jpg') no-repeat left top; } ... or such. but, sounds image on home page content , rather presentation. in case should including in html rather css. <body class="home"> <div><img src="your-image.jpg"> content here</div> </body> does help?

Python Pandas returns different output for the same code -

i have 10,000 row csv data file, read , wish manipulate data. want loop through, , compute results in matrix form, involves taking specific columns , doing computations. everytime run same program, different results. doing wrong here? there exceptions need know? use python 3.5. also,suggest if there's better way of doing this, i'm new analyzing data pandas. # import important stuff import numpy np # imports fast numerical programming library import scipy sp #imports stats functions, amongst other things import matplotlib mpl # imports matplotlib import matplotlib.cm cm #allows easy access colormaps import matplotlib.pyplot plt #sets plotting under plt import pandas pd #lets handle data dataframes #sets pandas table display pd.set_option('display.width', 500) pd.set_option('display.max_columns', 100) pd.set_option('display.notebook_repr_html', true) import seaborn sb #sets styles , gives more plotting options %matplotlib inline # read da...

javascript - Redirect all pages except a few specific ones -

i need use javascript on this, , place in header site pages. //.mysite.com - redirect pages within domain //.mysite.com/home except these 3 page examples, don't want these redirected. www.mysite.com/page2 www.mysite.com/article/sat www.mysite.com/home/message any ideas? i've never had request this. if (['/page2', 'article/sat', 'home/message', '/home'].indexof(window.location.pathname) < 0) window.location = 'www.mysite.com/home' no need jquery

javascript - jQuery set focus on selected item of a select list -

i have select list size="10" - shows 10 of 100 options available. when page loads, 1st 10 options displayed, if option value 50 selected . i have read adding focus selected item of select list work when page loads option 50 displayed in select list, instead of 1st 10 options. however, after reading many threads , searching google, unable work out how set focus selected item. i wanting set both selected , focus applied item of select list. here have tried , not work: $('#id_preview_style_select option:selected').prop('selected', true); //set selected value. $('#id_preview_style_select option:selected').prop('focus', true); //does not work. $('#id_preview_style_select option:selected').focus(); //does not work this seeking achieve: <select id="id_preview_style_select" size="10" autofocus> <option value="0">style 0</option> <option value="1">s...

How to write "decToBin" in Swift? -

i have been looking equivalent javascripts dectobin in swift 2. have not been able find anything. replicate following javascript code code: var max = 511; var maxlength = dectobin(max).tostring().length; you can use string achieve this: let max = 511 let maxlength = string(max, radix: 2).characters.count you can find more in apple string documentation

drag and drop - Adding new axis to Parallel Coordinates visualization in d3.js -

Image
i have hosted parallel coordinates code here: http://bl.ocks.org/aditeyapandey/d416c90c99e19f7c9209 upon clicking paragraph element can add new axis visualization. however, new axis not interacting other axes.so if drag newly added "shipping" axis on other axes not throw problem. but, if drop other axes "shipping" interaction not work. attaching screenshots reference. fig1 before adding axis: fig2 new axis "shipping" fig3 error when dragging axis on shipping ps. sorry bad code, work in progress , gist has blocked me, considers me robot. so, not able modify it. lot. i found solution. apparently drag behaviour still being called earlier code. therefore have override previous drag behaviour , add new 1 data fields , axes. updated code reference : http://bl.ocks.org/aditeyapandey/d416c90c99e19f7c9209

javascript - Styling 2 different classes of jQuery UI selectmenus -

i'd have 2 different styles (classes) select menus on site. don't want use ids since there can numerous drop downs on same page. so example: <div class="row"> <select class="style1"> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> <select class="style1"> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> <select class="style2"> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> </div> however, when create selectmenus javascript call: $("select").selectmenu(); it doesn't transfer class name selectmenu creates (it creates id based on original 1 plus "-button"). is there...

ruby on rails - ActiveRecord Eager Load model that isn't belongs_to -

i'm running issue n+1 queries , want eager load relationship, except i'm having trouble defining relationship. it's complicated, haha, hear me out. i have 2 models. class pokemon < activerecord::base belongs_to :pokemon_detail, primary_key: "level", foreign_key: "level" end class pokemondetail < activerecord::base has_one :pokemons, primary_ley: "level", foreign_key: "level" end let's say, have following record: <pokemon id: 1, name: "squirtle", level: 1> which correspond following pokemondetail <pokemondetail id: 1, name: "squirtle", level: 1, health: 150> and can eager loaded pokemon.all.includes(:pokemon_detail) , however, want eager load information 1 level higher. <pokemondetail id: 2, name: "squirtle", level: 2, health: 300> i find information 1 level higher following method within pokemon model. def next_level_info pokemondetail.where(leve...

arrays - filling matrix with user's input in C# -

i wanna fill matrix in c# user's inputs,but have trouble it.when enter rows , cols equal each other,it work; when enter rows , cols different each other program stop . code is int row = 0; int col = 0; int[,] matrix1; row = convert.toint16(console.readline()); col = convert.toint16(console.readline()); matrix1=new int[row,col]; console.writeline("enter numbers"); (int = 0; < row; i++) { (int j = 0; j < col; j++) { matrix1[i, j] = convert.toint16(console.readline());// have problem line,... plz show me correct form } } you allocate memory before input array size. correct code: int row = 0; int col = 0; int[ , ] matrix1; row = convert.toint16( console.readline( ) ); col = convert.toint16( console.readline( ) ); matrix1 = new int[ row, col ]; console.writeline( "enter numbers" ); ( int = 0; < col; i++ ) {...

javascript - how to work with Tagged URL [VBA] -

i new in field. my problem url when visited gives me nice webpage in web browser when try extract information using winhttp[vba] or internet explorer method, fails. my url https://search.rpxcorp.com/lit/txedce-165478?utm_campaign=rpxs_daily_lit_alert&utm_medium=email&utm_source=rpxsearch similarly when try download pdf same, link in website https://search.rpxcorp.com/litigation_documents/11809340 when use adodb.stream download pdf url fails. when visited pdf url in browser directs link: https://rpx-docs.s3.amazonaws.com/lits/043/90811/txedce-165478.pdf?signature=iw62rbsiciyar7gnyjianyunjdo%3d&expires=1452925167&awsaccesskeyid=akiai2uwkalieybvokda my problem is, how work type of websites html work with. edit think contains javascript, impossible solve problem without use of java script.

Overriding start_requests is Scrapy not synchronous -

i'm trying override scrapy's start_requests method, unsuccessful. i'm fine iterate through pages. problem have iterate firstly through cities , pages. my code looks this: url = "https://example.com/%s/?page=%d" starting_number = 1 number_of_pages = 3 cities = [] # there array of cities selected_city = "..." def start_requests(self): city in cities: selected_city = city print "####################" print "##### city: " + selected_city + " #####" in range(self.page_number, number_of_pages, +1): print "##### page: " + str(i) + " #####" yield scrapy.request(url=(url % (selected_city, i)), callback = self.parse) print "####################" in console see when crawler starts working prints cities , pages, , start requests. therefore result crawler parses first city. work asynchronously, while need synchronous. what r...

serialization - Django Rest Framework Serializer format -

i have 2 serializers: 1 restaurant model, mainmenu model: class restaurantserializer(serializers.modelserializer): class meta: model = restaurant class mainmenuserializer(serializers.modelserializer): restaurant = restaurantserializer() main_menu_items = serializers.stringrelatedfield(many=true) class meta: model = menumain fields = ('id', 'restaurant', 'main_menu_items') the current output of mainmenuserializer is [ { "id": 1, "restaurant": { "id": 1, "name": "restaurant a", "location": "street b" }, "main_menu_items": [ "fried rice" ] }, { "id": 2, "restaurant": { "id": 1, "name": "restaurant a", "location":...

go - Is it possible to recover from a panic inside a panic? -

it looks it's not possible recover panic inside panic? func testerror(t *testing.t) { e := &myerr{p: false} fmt.println(e.error()) // prints "returned" panic(e) // prints "panic: returned" e1 := &myerr{p: true} fmt.println(e1.error()) // prints "recovered" panic(e1) // prints "panic: panic: paniced // fatal error: panic holding locks // panic during panic" } type myerr struct { p bool } func (m *myerr) error() (out string) { defer func() { if r := recover(); r != nil { out = "recovered" } }() if m.p { panic("paniced") } return "returned" } backstory: error error() function uses os.getwd, seems panic when inside panic, i'd handle gracefully. i think solves problem replace this panic(e1)...

java - Implementing class embedded in an interface -

assume have interface class embedded in (the purpose being interface must provide 'type'. interface has methods using 'type'. so, in file s.java, have public interface s { public class stype { } public abstract void f( stype ); } i want implement interface, , try this, in file ss.java: public final class ss implements s { public class stype extends java.util.hashset<integer> { } public void f( stype ) { // ... } } however, when try compile these files ("javac s.java ss.java"), usual error message "ss not abstract , not override abstract method f(stype) in s" indicating "f()" in concrete class not proper implementation of "f()" in interface. why? try with: public final class ss implements s{ public class stype extends java.util.hashset<integer> { } public void f(s.stype a) { // .. } } edit: perhaps, need this:...

xml - xslt function to separate a string with delimiter -

i have string. want xslt function can separate every 2 characters of string delimiter '|'. e.g.: input abadferewq output ab|ad|fe|re|wq. if you're using xslt 2.0, can use replace() ... xml input <root> <string>abadferewq</string> </root> xslt 2.0 ( working example ) <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="string"> <xsl:copy> <!-- inner replace() adds '|' after every 2 characters. outer replace() strips off trailing '|'. --> <xsl:value-of select="replace( ...

angularjs - Function or filter vs computed attribute with css class name -

i have user object , have complex logic, want unit test, takes user object , decides how should displayed - css class should used. there 2 approach consider: <td class="{{ user | classify }}"> or <td class="{{ user.cssclass }}"><!-- or --><td ng-class="user.cssclass"> or <td ng-class="computecssclass(user)"> the first approach assumes create filter based on provided user objects returns css class. the second approach assumes add new attribute cssclass model , whenever new user object created (fetched rest api) compute cssclass attribute. the third approach assumes create function computes css class provided user object. what pros , cons of above 3 approaches? i have created jsfiddle play these 3 approaches. the significant difference can think of around data-binding 1st approach, using filter <td class="{{ user | classify }}"> pro: leverage angular's ...

ruby on rails - How to install refinerycms to my ROR app -

i working in 'rails', '4.1.10' , want build cms app used gem 'refinerycms' then in terminal: brew install imagemagic gem install refinerycms what should after that? when put http://localhost:3000/refinery , give me no route matches [get] "/refinery" here guide need > link the next step should generate refinerycms! in terminal type. $ refinerycms rickrockstar

javascript - AngularJS $scope is not updating in DOM -

i have following codes : the state (lets make short simplicity purposes) .state('foo', { url: '/foo', templateurl: 'path/to/template.html', controller:'fooctrl', }) the controller controller = function($scope){ // not actual code $scope.barcount } template.html <div> <span>{{ barcount }}</span> // updating </div> other html partial <div ng-controller="fooctrl"> <span>{{ barcount }}</span> // **not** updating </div> i have scope variable on controller . 2-way binding working fine on template declared on state controller . not on other partial template in binded controller using ng-controller . is kind of bug? or missing something? thanks. you have 1 controller 2 instances of controller. each time use ng-controller or declare in differents views new instance created, controllers in differents scopes. best way share data between contr...

javascript - Bootstrap3 two dropdowns on the same line -

i'm trying make 2 bootstrap3 dropdown element working on same line: i've tried this: <div class="btn-group btn-block"> <button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">first <span class="caret"></span> </button> <ul class="dropdown-menu btn-block"> <li><a href="#">reason 1</a></li> <li><a href="#">reason 2</a></li> <li><a href="#">reason 3</a></li> </ul> <button class="btn btn-lg btn-default dropdown-toggle" data-toggle="dropdown">second <span class="caret"></span> </button> <ul class="dropdown-menu btn-block"> <li><a href="#">reason 5</a></li> <li><a hre...

SQL Server date column sorting dates automatically -

i have table date column. inserting dates in column using datetimepicker in c#. everything works fine. want dates inserted in table ordered. when add today's date in 1 row , add yesterday's date or past date, gets added in 2nd row ofc. i want added in 1st row instead. before today's date, make dates in order. is there property of date column can use ensure dates order? there absolutely no implicit order in sql server datatables! no index, no clustered index, no trick... simple select * table may come sorted data - or not... if need data sorted in special way must add order by now 1 solution problem: create updateable view ( https://msdn.microsoft.com/en-us/library/ms180800.aspx ) on table ordered want it. commuicate through view... important is: when specify select top 100 percent * yourtable order yourcolumn view not come sorted data... the trick here introduce sorting row_number() i took testing 1 of tables. make more difficult took 1 i...

php - How to cache dynamicaly created form fields -

i have laravel project view user adds form fields dynamicaly. there's ajax "save" button , link opens "print view" of page. if user hits button after printing, there's no dynamicaly added fields, although saved ( - if reload page, renders correctly) am missing regarding caching fields? thanx y ok, found few possible solutions: 1) target: _blank links lead away 2) input type=hidden dynamically added fields, populated on onbeforeunload, , restored on page load ( link ) but choosed force reloading pages after button such (dyn) content. after body tag: <input type="hidden" id="tmkreloadtest" value="reloaded" /> <script> if(document.getelementbyid('tmkreloadtest').value!=="reloaded") { location.reload(); } window.onbeforeunload = function (e) { document.getelementbyid("tmkreloadtest").value = "fromcache"; } </script> hope helps.. ...

why xargs cannot receive argument -

i have sql files , want dump local db, first used shell command , not work ls *.sql|xargs -i mysql -uroot -p123456 foo < {} zsh: no such file or directory: {} but below work echo hello | xargs -i echo {} world hello world so why first command not work? redirections handled shell before commands run. if want xargs handle redirection, need run subshell. ls *.sql | xargs -i sh -c 'mysql -uroot -p123456 foo < {}' however, should not using ls drive scripts. want for f in *.sql; mysql -uroot -p123456 foo <"$f" done or quite possibly just cat *.sql | mysql -uroot -p123456 foo

Change select distinct SQL statement to work on SQL Server 2008 -

i have sql statement works on postgresql , returns 2 columns ordering other columns: select distinct on (title) gender_id, title persons account_id = 100 order title, created_date i need change sql work on sql server 2008 , postgres, in sql server can't use on clause how can it? use row_number() : select p.* (select p.*, row_number() on (partition title order created_date) seqnum persons p account_id = 100 ) p seqnum = 1; this version work in both postgres , sql server. note: in postgres, distinct on faster using row_number() .

c# - MVC Merging two foreign tables to one view very slow -

i have managed load data 1 table , return view, working well. unfortunately through learning process , failing understand other posts relating returning 2 models 1 view , using mvc 5 tutorial rick anderson my controller taking forever create "merged" data table model , return view, when manipulate view goes through whole process again ever big kick in shin. i have van model not hold sim or imei number of gprs unit stored in assett table both not index linked (if correct wording). wish return view full list of vans along imei , sim number assett table. van model [metadatatype(typeof(vanviewmodel))] public partial class vans__ { public string imei { get; set; } public string simno { get; set; } } public class vanviewmodel { [required] public int assetid { get; set; } [required] [display(name = "chassis number")] public string van_serial_number { get; set; } [required] [display(name = "seller dealer id")] ...

_unAnswered_ Turn on android hotspot by button click in my application then see the connected devices MAC address -

i want turn on hotspot of android mobile click on button in hello world application. after want below list of connected devices mac address must seen. , there option of giving custom name mac address(alias). this question asked way before stack overflow , never answered properly. please try give ans we not give code this. way can explore. to control wifi of android device have add line manifest : <manifest ...> <uses-feature android:name="android.hardware.wifi" /> <uses-permission android:name="android.permission.change_wifi_state" /> <uses-permission android:name="android.permission.change_network_state" /> <uses-permission android:name="android.permission.access_wifi_state" /> ... </manifest> after have use class : wifimanager manage hotspot

android - Error while fetching data in ListView in dialog box? -

i trying fetch data though json in listview . problem when dialog open first time show listview correct data when close dialog , try open again give me error. error is: java.lang.illegalstateexception: content of adapter has changed listview did not receive notification. make sure content of adapter not modified background thread, ui thread. make sure adapter calls notifydatasetchanged() when content changes i modify adapter ui thread of asynctast , call notifydatasetchanged() method ui thread. don't know why opening dialog box second time give me error. so how can solve problem? this onpostexecute method of asynctast: @override protected void onpostexecute(string result) { super.onpostexecute(result); pdialog.dismiss(); planlist.clear(); applist.clear(); try { jsonobject obj = new jsonobject(result); string errcode = obj.getstring("errcode"); if(errcode.equalsignorecase("-1")){ js...

Google geocoding API don't recognize french amusement parks -

all in title, why google-geocoding-api don't recognize french amusement parks ? example request "parc asterix" : https://maps.googleapis.com/maps/api/geocode/json?address=parc+asterix&components=country:fr here, result "parc asterix" in google maps . thanks help

struct - Accessing enum Members in C -

i have function of type of struct, contains integers , reference enum, such: typedef struct test { error e; int temp; int value; }test; where enum is: typedef enum error { ioerror, externalerror, elseerror, }error; and have function wants return error (of enum of 3), depending on if happens. where function of type test (i can't change types or values passed in), why can't return error this? how go returning (i can't change struct definitions nor function prototypes). test errorfunc() { return test->e->ioerror; //gives error } any appreciated! in c, code: test errorfunc() { return ioerror; } this c, in global namespace, there no "strong" enums , enum "members" "weakly typed integer constants". so, accessing "data member" of enum makes no sense. use constant. compiler check if constant used of type return , complain if isn't. how complain depends on compiler, ...

postgresql - Flask-sqlalchemy losing connection after restarting of DB server -

Image
i use flask-sqlalchemy in application. db postgresql 9.3. have simple init of db, model , view: from config import * flask import flask, request, render_template flask.ext.sqlalchemy import sqlalchemy app = flask(__name__) app.config['sqlalchemy_database_uri'] = 'postgresql://%s:%s@%s/%s' % (db_user, db_password, host, db_name) db = sqlalchemy(app) class user(db.model): id = db.column(db.integer, primary_key=true) login = db.column(db.string(255), unique=true, index=true, nullable=false) db.create_all() db.session.commit() @app.route('/users/') def users(): users = user.query.all() return '1' and works fine. when happens db server restarting ( sudo service postgresql restart ), on first request /users/ obtain sqlalchemy.exc.operationalerror : operationalerror: (psycopg2.operationalerror) terminating connection due administrator command ssl connection has been closed unexpectedly [sql: .... is there way renew connection in...

javascript - How to crate custom drag and drop web components for a web app -

Image
i trying r&d work around web app. in preceding image have described requirement.let have custom web components components 1,components 2 etc in left side.users should able drag , drop components play area , should generate predefined xml or text snippet belong component , generated value should store in variable later use.currently using angular , js , html languages achieve requirement.i know can use html5 drag , drop feature items.but don't have idea how can generate code snippet or text belong dragged items.so maybe guys have kind of experience that.i thought share requirement. appriciate ideas.

php - How to change every email value in a table -

Image
i work zend framework 1.12 , mysql. in database have 4k rows, , have unique e-mail value. how should change value every row? better use php script or use mysql query? example of desired result: use php script makes use of zend framework, eg: $data = array( 'email' => $mynewemail, ); $n = $db->update('users', $data, 'user_id = ' . $userid); http://framework.zend.com/manual/1.12/en/zend.db.adapter.html

javascript - Format Date in JS from .NET Service AJAX call -

i have problem. date .net service ajax call. format of date got (i in italy) mon dec 31 2012 08:25:21 gmt+0100 (ora solare europa occidentale) how can format date in format dd/mm/yyyy ? cannot work on .net service side, js side. in advance. you can parse bits date object, create formatted string in whatever format want. following takes account of timezone, might different client: var s = 'mon dec 31 2012 08:25:21 gmt+0100'; function getdate(s) { // split string bits var s = s.split(/[ :]/); // conversion month month number (zero indexed) var months = {jan:0,feb:1,mar:2,apr:3,may:4,jun:5, jul:6,aug:7,sep:8,oct:9,nov:10,dec:11}; // calculate offset in minutes var offsetmins = s[7].substring(4,6) * 60; offsetmins += s[7].substring(6,8) * 1; offsetmins *= s[7].substring(3,4) == '+'? 1 : -1; // build utc date value, allowing offset in minutes, // , pass date constructor var date = new da...

Java lower bounded type List as parameter -

hello got 2 classes: person class , employee class extends person simple public class person { private string name; private string surname; public string getname() { return name; } public void setname(string name) { this.name = name; } public string getsurname() { return surname; } public void setsurname(string surname) { this.surname = surname; } public person(string name, string surname) { super(); this.name = name; this.surname = surname; } } public class employee extends person { private string salary; private string position; public string getsalary() { return salary; } public void setsalary(string salary) { this.salary = salary; } public string getposition() { return position; } public void setposition(string position) { this.position = position; } public employee(string name, string surname, ...

Matlab Quadratic equation -

struggling matlab quadratic equation. keep getting complex number answer , other errors keep occurring. write matlab function solves quadratic equation of form a*x^2 + b*x + c = 0 the syntax of function should take form [quadroots1,quadroots2] = q1_quadratic (a,b,c); where a , b , c quadratic coefficients; , quadroots1 , quadroots2 2 determined roots. case 1 root present (for example when a=1 , b=2 , c=1 ), should set second output nan (not number). if no roots present, set both outputs nan . make sure check if number under root sign in quadratic formula is: positive ( >0 ): 2 distinct real roots, equal 0 ( ==0 ): single real numbered degenerate root (or, rather, 2 non-distinct roots). negative ( <0 : roots complex (recall sqrt(-1) = i , our imaginary unit i ). sound of question specs, seems treat complex if "no roots present" . you can check cases above in function q1_quadratic(...) using if-elseif-else clause, e.g.: ...

Should I use django-gunicorn integration or wsgi? -

i setting web server gunicorn + django. there 2 deployment options: either use regular wsgi, or use gunicorn's django-integration. i'm tempted use latter, because simplifies configuration, django documentation says this: if using django 1.4 or newer, it’s highly recommended run application wsgi interface using gunicorn command described above. they give no explanation, wonder why it's "highly recommended" go wsgi? ideas? thanks lot. starting django 1.4, project have wsgi.py, can used wsgi server (of there many, gunicorn being one). essentially old django integration gunicorn convenience , running faster, it's no longer necessary because django projects have wsgi.py

JavaScript performance: simple key search in object vs value search in array -

i need emulate set in javascript — i.e. variable able answer question "do contain x ?". performance of insertion/deletion doesn't matter. order doesn't matter. , isn't multiset . there 2 ways implement it: using regular array value search: var set = [17, 22, 34]; if (set.indexof(x)!=-1) ...; 1a. using typedarray (e.g. int32array ), when possible: var set = int32array.of(17, 22, 34); if (set.indexof(x)!=-1) ...; using object key search: var set = {17: true, 22: true, 34: true}; if (set[x]) ...; theoretically object key search should faster (depending on how implemented in js engine, should either o(log(n)) , or o(1) — vs o(n) on array value search). however, case in javascript (where access object member may require multiple lookups) — on small sets dozens of items? assuming values in set quite simple (either integers, or short strings). resume. want know: minimum amount of set items required make object key search faster array valu...

Python lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException -

i'm trying set ssl certificate letsencrypt, when run following: user@box:/opt/letsencrypt$ ./letsencrypt-auto --apache -d example.com updating letsencrypt , virtual environment dependencies...traceback (most recent call last): file "/home/user/.local/share/letsencrypt/bin/pip", line 7, in <module> pip import main file "/home/user/.local/share/letsencrypt/local/lib/python2.7/site-packages/pip/__init__.py", line 13, in <module> pip.utils import get_installed_distributions, get_prog file "/home/user/.local/share/letsencrypt/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 15, in <module> import zipfile file "/usr/lib/python2.7/zipfile.py", line 6, in <module> import io file "/usr/lib/python2.7/io.py", line 51, in <module> import _io importerror: /home/user/.local/share/letsencrypt/lib/python2.7/lib-dynload/_io.so: undefined symbol: _pyerr_replaceexception python -v returns p...