Posts

Showing posts from January, 2014

ruby - How to only read a few lines from a remote file? -

before downloading file, need set way (the .csv typically, not always) parsed. i don't want download whole file if "headers" not match expected. is there way download until number of byes , gracefully kill connection? there's no explicit support in ftp protocol. there's expired draft rang command allow this: https://tools.ietf.org/html/draft-bryan-ftp-range-08 that's supported new ftp servers. though there's nothing prevents initiating normal (full) download , forcefully break amount of data need. all need close data transfer connection. ftp clients do, when end user decides abort transfer. this approach might result in few error messages in ftp server log. if can use sftp protocol, it's easy. sftp supports natively.

java - What is the difference between raw types and generic types in this declaration -

this question has answer here: what raw type , why shouldn't use it? 12 answers what difference between raw types , generic types in declaration list<integer> list1 = new arraylist<>(); list<integer> list2 = new arraylist(); for these declaration can't do list1.add("hello"); list2.add("hello"); so difference on other word benefit of angle brackets in first declaration when arraylist<>(), type in angle brackets inferred declaration, resolves arraylist<integer> @ compile time. if omit angle brackets, assignment uses raw type, i.e. collection type without information of element type. no type inference done compiler assignment. both lines not compile: list1.add("hello") list2.add("hello") because both list1 , list2 variables declared arraylist<string> .

xml - Can XSD extension re-order elements? -

i want extend type in xml schema, this: <complextype name="alieninfo"> <complexcontent> <extension base="personalinfo"> <sequence> <element name="planet" type="xsd:string"/> </sequence> </extension> </complexcontent> </complextype> where <complextype name="personalinfo"> <sequence> <element name="name" type="xsd:string" /> <element name="age" type="xsd:int" /> </sequence> </complextype> but want change order of constituent elements. say, have planet before name , age . possible? deriving types extension cannot used change order of elements in base type: when complex type derived extension, effective content model content model of base type plus content model specified in type derivation. furthermore, 2 content models treated 2 ch

css - How do I make a dropdown in Firefox look the same as Chrome/IE? -

Image
so, i'm building website dropdown menu. in chrome looks nice, on firefox takes no padding , find way make them same on both browsers. i'm aware known issue, didn't find decent fix problem. here's drawing dropdown code on debug <div class="collapse navbar-collapse" id="mainmenu_nav"> <ul class="navbar-nav nav h> <li aria-haspopup="true" class="hasitems hover focus"> <div class="wrapper" tabindex="-1"> .... </div> </li> </ul> </div> css .navbar-collapse{ max-height:none; margin-left:-10px; margin-right:-10px; } .h{ position:relative; back-ground-color:black; margin-left:5px; white-space:nowrap; width:100%; display:table; } .h>li.hover{ background-color:white; top:3px } .h>li{ position:relative; white-space:nowrap; display:table

tableau - Cannot use calculated offset in BigQuery's DATE_ADD function -

i'm trying create custom query in tableau use on google's bigquery. goal have offset parameter in tableau changes offsets used in date based clause. in tableau this: select date_add(utc_usec_to_month(current_date()),<parameters.offset>-1,"month") month_index, count(distinct user_id, 1000000) distinct_count [orders] order_date >= date_add(utc_usec_to_month(current_date()),<parameters.offset>-12,"month") , order_date < date_add(utc_usec_to_month(current_date()),<parameters.offset>-1,"month") however, bigquery returns error: error: date_add 2nd argument must have int32 type. when try same query in bigquery editor using simple arithmetic fails same error. select date_add(utc_usec_to_month(current_date()),5-3,"month") month_index, [orders] any workaround this? option far make multiple offsets in tableau, seems. thanks help! i acknowledge hole in functionality of date_add. can fixed

html - How can I 'grow' text in only one direction if the text is centered? -

i'm trying create overlay says: 'waiting...', want ellipses animated. text go from:- 'waiting' -> 'waiting.' -> 'waiting..' -> 'waiting...' -> 'waiting' -> however, when ellipses count changes it's pushing 'waiting' left since content centered in container. html: <div style='text-align: center'> <span>waiting</span> <span id='ellipses'></span> </div> javascript: var ellipses = 0; setinterval(function () { $('#ellipses').text('.'.repeat(ellipses)) ellipses = (ellipses + 1) % 4; }, 400) any way handle ?, easy magic numbers or manual calculation of 'center' + fixed position, i'd have clean css solution if possible.. using pure css, try fiddle , .ellipses1 { -webkit-animation: elipses 1.3s infinite; -webkit-animation-delay: 0.0s; } .ellipses2 { -webkit-animation: elip

How to use Google.Apis.Analytics.v3 API with vb.net service app -

i have managed autenticate self succesfully google etc. need how use google.apis.analytics.v3 or google.apis.analytics.v3.data dll retrive data. example need last month vistors. far have this: imports system.security.cryptography.x509certificates imports system.threading imports google.apis.auth.oauth2 imports mailbee imports mailbee.imapmail imports mailbee.smtpmail imports system.data imports system.io imports system.data.sqlclient imports google.apis.analytics.v3 imports google.apis.analytics.v3.data imports google.apis.authentication.oauth2.dotnetopenauth imports google.apis.services imports google.apis.util public class gaimport inherits system.web.ui.page public shared sub main(sender object, e eventargs) dim serviceaccountemail string = "xxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com" dim useremail string = "xxxxx@gmail.com" dim certificate new x509certificate2("c:\works\gaimport\gaimport\analyticsdata-xxxxxx

elasticsearch - Extracting matching conditions from querystring -

elasticsearch query formed using query string multiple , / or operators. i.e. ((condition 1 or condition 2) , (condition 3 or condition 4 or condition 5)), based on condition provides me multiple documents. getting exact condition again loop through resultant documents again , mark particular conditions. there simple way resultant conditions specific documents ? can provide better example using nest api? i think need highlight data made hit on query. highlight functionality of elasticsearch marks text each search result user can see why document matched query. marked text returned in response. please refer in elasticsearch documentation in order understand how api works. refer in nest documentation in order see how can implement nest library. for example, using elasticsearch api imagine below example: get /someindex/sometype/_search { "query" : { "match_phrase" : { "about" : "rock climbing" }

Adding multiple markers in Google Maps API v2 Android -

i want add multiple markers in map, don't know way. at moment, im using this, , works correctly: marker m1 = googlemap.addmarker(new markeroptions() .position(new latlng(38.609556, -1.139637)) .anchor(0.5f, 0.5f) .title("title1") .snippet("snippet1") .icon(bitmapdescriptorfactory.fromresource(r.drawable.logo1))); marker m2 = googlemap.addmarker(new markeroptions() .position(new latlng(40.4272414,-3.7020037)) .anchor(0.5f, 0.5f) .title("title2") .snippet("snippet2") .icon(bitmapdescriptorfactory.fromresource(r.drawable.logo2))); marker m3 = googlemap.addmarker(new markeroptions() .position(new latlng(43.2568193,-2.9225534)) .anchor(0.5f, 0.5f) .title("title3") .snippet("snippet3")

ODBC php Excel Encoding Issues -

i'm making odbc connection php excel file. when encounter characters "~", "^", "´" appear messed this: mês -> m?s formação -> forma??o i'm doing following utf-8 treatment column names: $con = odbc_connect($odbcname, $dbuser, $dbpassword) or die('failed'); //the set names utf8 doesn't work excel. //$try = odbc_exec($con, "set names utf8"); $rs = odbc_exec($con, utf8_encode($dbquery)) or die('erro no sql'); $intnumfield = odbc_num_fields($rs); for($i=1; $i<=$intnumfield;$i++){ $columns[] = utf8_decode(odbc_field_name($rs,$i)); } the file saved web options -> encoding -> unicode (utf-8). is there else should doing in php? thank in advance! incase stumbles same problem had, solved following way: in excel file change encoding western european (windows-1252 utf-8); in php convert windows-1252 utf-8 -> $value = iconv("windows-1252", "utf-8", $auxvar);

symfony - How to save additional entity while persisting another in Doctrine? -

i've got place entity , distance one, so: class place { /** @orm\id @orm\column(type="integer") @orm\generatedvalue(strategy="auto") */ private $id; /** @orm\column(type="string", length=62, nullable=false) */ private $name; /** @orm\onetomany(targetentity="distance", mappedby="origin") */ protected $distancesto; /** @orm\onetomany(targetentity="distance", mappedby="destination") */ protected $distancesfrom; } class distance { /** @orm\id @orm\column(type="integer") @orm\generatedvalue(strategy="auto") */ private $id; /** @orm\manytoone(targetentity="place", inversedby="distancesto") */ protected $origin; /** @orm\manytoone(targetentity="place", inversedby="distancesfrom") */ protected $destination; /** @orm\column(type="integer") */ private $miles; } i want every

How can I speed up Pkg.add() in Julia? -

take cairo example, when run pkg.add("cairo") , there's nothing displayed in console. is there way let pkg.add() display more information when working? what steps pkg.add() carry out? download, compile? is possible speed up? kept waiting 15 minutes, nothing out! maybe it's julia's problem, or maybe it's system's problem, how can 1 tell? edit julia version: 0.3.9 (installed using binary julia-lang.org) os: winsows 7 64bit. cpu: core duo 2.4ghz ram: 4g hard disk: ssd ping github.com passed, 0% loss. internet download speedtest: ~30 mbps. i don't know whether normal: took me 11 seconds version. ps c:\users\nick> measure-command {julia --version} days : 0 hours : 0 minutes : 0 seconds : 11 milliseconds : 257 ticks : 112574737 totaldays : 0.000130294834490741 totalhours : 0.00312707602777778 totalminutes : 0.187624561666667 totalseconds : 11.25747

intentfilter - Launch Android activity when click on href in Chrome browser -

i want open app's loginactivity when click on <a href="www.myhost.com"/> in web in chrome browser app. have code not working: <activity android:label="@string/app_name" android:launchmode="singletask" android:name=".activities.loginactivity" android:screenorientation="portrait" android:windowsoftinputmode="statevisible"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> <intent-filter> <data android:scheme="http" android:host="myhost.com"/> <category android:name="android.intent.category.default"/> <category android:name="android.intent.category.browsable"/> <action an

microsoft speech platform - how to update srgs grammar in C# -

i have created srgs file semantic recognition, want udate mygrammar file,now how update my_grammar.xml file , add more cities in item tag textbox. helping material regarding appreciated , in advance. <grammar version="1.0" xml:lang="en-us" mode="voice" root="destination" xmlns="http://www.w3.org/2001/06/grammar" tag-format="semantics/1.0"> <rule id="source"> <one-of> <item> karachi </item> <item> lahore </item> <item> abbottabad </item> <item> murree </item> </one-of> </rule> <rule id="destination"> <one-of> <item> karachi </item> <item> lahore </item> <item> islamabad </item> </one-of>

websocket - Socket between browser and iOS devices -

Image
we have proprietary template format rendering articles. have written editor in html editing this. while editing/writing template want live preview of results directly on different ios , android devices through custom app we've made preview. it seems redundant have server in between browser , preview-app if possible browser connect directly , have multiple sockets devices. so guess question browser preview-app have no problem setup. if html editor in browser , app on smartphone, unlikely can connect directly browser smartphone. from browser, have 2 connection options: ajax request or websocket. and, need able connect either public dns name or known ip address configured incoming connections. smartphone not have either public dns name or known ip address. if tried make connection other way smartphone apps browser, can't that. browser web pages don't accept incoming connections , behind firewall block incoming http connections anyway. this why 2 end

salesforce - Get data from SAP Hana to SFDC -

i have requirement data salesforce web portal developed open ui5 , sap hana . data has moved salesforce @ each , every insert of records happening in open ui5 portal. again record processes @ salesforce , updated records has moved sap hana please let me know possible , let me necessary steps need follow , how achieve this. thanks in advance you want use replication salesforce system hana system. depending on architectural needs, should at: sap landscape transformation (slt) trigger based approach. sap replication server (srs) log based approach. in sap community network, @ presentations , related resources on left column find of documentation need. both have different advantages, , disadvantages, should read on them decide better suit needs.

unity3d - Getting Information from a Collider to another method -

i have 3 game objects have trigger collider on them script called detectcollision.cs following code: public void ontriggerenter(collider col) { string name = ""; name = col.gameobject.name; } i pass name of object collides object method add names of collided object. example: place holder 1 collides gameobject called a, place holder 2 collides gameobject called b, place holder 3 collides gameobject called c ... send names of collided objects method add strings make word - abc. any tips appreciated im not sure question meant im assuming want call class method store strings im writing this for need create class static instance public class classtostoreinfo : monobehaviour { public static classtostoreinfo thisinstance; private string collisionline = ""; void start() { thisinstance = this; } public void addstringaftercollision(string value) { collisionline += value; } } then call

html5 - Some bootstrap divs are overlapping with other bootstrap div -

i have created following layout bootstrap: demo as can see 'if know more about...' div overlapped 4 small divs. can give me suggestions fix this? appreciated. check code.. .more-info > div > div:nth-child(3) { color: #8b8b8b; font-family: calibrilight; font-size: 18px; padding: 0 139px; letter-spacing: -0.3px; line-height: 1.2; margin-bottom: -42px; } you have added "margin-bottom:-42px". remove , check again. if want have part. include "padding-bottom: 42px". space remains same.

javascript - Creating deep links with History_API -

i trying pull deep linking. have found 1 tutorial , tried implement it. here history_api jquery/ajax loader: $('.hor_menu').click(function() { var url = $(this).attr('href'); $.ajax({ url: url + '?ajax=1', success: function(data) { $('#destination').html(data); } }); so if div -button .hor_menu class clicked, ajax loads it's contents #destination block. link changed with: if (url != window.location) { window.history.pushstate(null, null, url); } return false; }); to make back/forward buttons activated use: $(window).bind('popstate', function() { $.ajax({ url: location.pathname + '?ajax=1', success: function(data) { $('#destination').html(data); } }); }); sample div button: <div class="hor_menu" id="b5" href="/pages/about.htm" onclick=" ('main_hor_menu')"&g

cookies - Class Not Updating when useing case in javascript -

i don't know why class not udpated in following script using (case): if (favorite !== null) { switch (favorite) { case 'cat': document.getelementbyid("one").classname = "favblue"; //document.getelementbyid('one').classname ='favred'; //document.createattribute('class','favred') break; case 'dog': document.getelementsbyname('dog').classname = 'favblue'; break; case 'gerbil': document.getelementsbyname('gerbil').classname = 'favyellow'; break; case 'gopher': document.getelementsbyname('gopher').classname = 'favwhite'; break; } } please click on link in order see complete script http://jsfiddle.net/gu8u6eoc/6/ your case statement working. think should use docum

Uploading Excel Report Data to Sql Server -

Image
i want upload custom excel reports sql server database. designed tables reports. uploading data 1st month works fine when upload data second month replace other data in table. don't want replace date of first month. uploading use import export wizard or ssis. how can solve problem? when you're in "select source tables , views" page of wizard click "edit mappings": then select "append rows destination table"

python 3.x - urlopen is not working for python3 -

i trying fetch data url. have tried following in python 2.7: import urllib2 ul response = ul.urlopen("http://in.bookmyshow.com/") page_content = response.read() print page_content this working fine. when try in python 3.4 throwing error: file "c:\python34\lib\urllib\request.py", line 161, in urlopen return opener.open(url, data, timeout) i using: import urllib.request response = urllib.request.urlopen('http://in.bookmyshow.com/') data = response.read() print data it works me (python 3.4.3). need use print(data) in python 3. as side note may want consider requests makes way easier interact via http(s). >>> import requests >>> r = requests.get('http://in.bookmyshow.com/') >>> r.ok true >>> plaintext = r.text finally, if want data such complicated pages (which intended displayed, opposed api), should have @ scrapy make life easier well.

Inno Setup: How to overwrite on install but not on change? -

i know how overwrite files using method [files] source: "project\*"; destdir: "{app}"; flags: ignoreversion recursesubdirs onlyifdoesntexist; permissions: everyone-full but when change program using change option in 'install or change program' section want not overwrite files. i create change option installer this: [setup] appmodifypath="{srcexe}" /modify=1 how do this? first, code seems wrong. onlyifdoesntexist flag, files never overwritten, contrary claim. anyway, solution create 2 [files] entries, 1 overwrites , 1 not. , use pascal scripting pick entry respective installation mode. [files] source: "project\*"; destdir: "{app}"; flags: ... onlyifdoesntexist; ...; check: isupgrade source: "project\*"; destdir: "{app}"; flags: ...; ...; check: not isupgrade example of isupgrade implementation: [code] function isupgrade: boolean; var s: string; innosetupreg: string;

http - koa-static not following max-age -

i using koa-static serve assets. have set max-age minute 60000ms (as described in docs) for testing purposes, using big image background in page, seems browser still re-downloads every time page opened anyway... here related code: var app = require('koa')(), serve = require('koa-static'); app.use(serve('./public', { maxage: 60000, })) how can fix this? are sure not problem browser instead of koa-static? tried example is, instead of using browser used curl check out headers: if curl -i http://localhost:3000/img.png you see max-age header set 1 minute desired. seems cache-control set wanted, must browser doing tricky headers. example, if using chrome, set max-age=0 in situations: chrome doesn't cache images/js/css hope helps!

php - Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) on line 10 -

this question has answer here: php parse/syntax errors; , how solve them? 11 answers so error "parse error: syntax error, unexpected '->' (t_object_operator) in /applications/mamp/htdocs/classes/class.manageusers.php on line 10", does know part of syntax wrong? below relevant class. 5 class manageusers { 6 public $link; 7 8 function __construct(){ 9 $db_connection = new dbconnection(); 10 $this->link = db_connection->connect(); 11 return $this->link; 12 } db_connection->connect(); should $db_connection->connect(); notice missing $

android - EditText Removing Currency Symbol in TextWatcher not working -

i want remove dollar sign amount formatter not working assigned replace it contains dollar sign. how can this? here code text watcher. numberformat canadaenglish = numberformat.getcurrencyinstance(locale.canada); public class moneytextwatcher implements textwatcher { private final weakreference<edittext> edittextweakreference; boolean hasfractionalpart = false; private edittext edittext; public moneytextwatcher(edittext edittext) { edittextweakreference = new weakreference<edittext>(edittext); this.edittext = edittext; } @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void ontextchanged(charsequence s, int start, int before, int count) { if (s.tostring().contains(string.valueof(df.getdecimalformatsymbols().getdecimalseparator()))) {

php assign unique variable foreach iteration of array -

i want assign each set of array in foreach loop assigned in unique variable i have formed array array ( [0] => array ( [title] => mobiles & accessories ) [1] => array ( [title] => mobile accessories ) [2] => array ( [title] => cables ) ) array ( [0] => array ( [title] => computers ) [1] => array ( [title] => tv & video accessories ) [2] => array ( [title] => cables ) ) array ( [0] => array ( [title] => home entertainment ) [1] => array ( [title] => video players & accessories ) [2] => array ( [title] => video accessories ) [3] => array ( [title] => cables ) ) i want each array set in unique variables like $a = ( [0] => array ( [title] => mobiles &

tfs2013 - How to refresh updated opened work item from TFS 2013 server side plugin? -

i trying create tfs 2013 server side plugin transition work item state depending upon fields. fields being updated correctly, not refreshed work item opened in client (vs team explorer). need manually press refresh button display correct state. can force refresh displayed work item after state change plugin? following code handling work item changed event. if (null != workitem) { workitem.partialopen(); if (!workitem.fields["almtool.ff.team.leader"].value.equals(string.empty)) { if (workitem.fields["system.state"].value.equals("raised")) { workitem.state = "analyse"; } } else { workitem.state = "raised"; } workitem.save(); workitem.store.refreshcache(true); //workitem.close(); workitem.synctolatest(); } i've had same need long time ago. trying achieve in web access rather team explorer. web access, not possible, becau

Excel VBA to find and mask PAN data using regex for PCI DSS compliance -

because of tools discover credit card data in file systems no more list suspicious files, tools needed mask data in files must retained. for excel files, loads of credit card data may exist, figure macro detects credit card data in selected column/row using regex , replaces middle 6-8 digits xs useful many. sadly, i'm not guru in regex macro space. the below works regex 3 card brands only, , works if pan in cell other data (e.g. comments fields) the below code works, improved. improve regex make work more/all card brands , reduce false-positives including luhn algorithm check. improvements/problems remaining : match card brand's pans expanded regex include luhn algorithm checking (fixed - idea ron) improve while logic (fixed stribizhev) even better handling of cells don't contain pans (fixed) here's have far seems working ok amex, visa , mastercard: sub pci_mask_card_numbers() ' written mask credit card numbers in excel files in accordance pci

android - Handle "Cannot play this video" in VideoView -

is there way handle cannot play video in android video view programatically. you have implement mediaplayer.onerrorlistener , provide following videoview method public void setonerrorlistener (mediaplayer.onerrorlistener l) it may mediaplayer.onerrorlistener onerrorlistener = new mediaplayer.onerrorlistener() { @override public boolean onerror(mediaplayer mp, int what, int extra) { log.e(getpackagename(), string.format("error(%s%s)", what, extra)); return true; } }; mp mediaplayer error pertains to what type of error has occurred: media_error_unknown media_error_server_died extra code, specific error. typically implementation dependent. media_error_io media_error_malformed media_error_unsupported media_error_timed_out media_error_unsupported constant represents state looking for. returns true if method handled error, false if didn't. returning fa

html - How to center horizontal table-cell and content inside it in the middle -

i building on question asked here how center horizontal table-cell slight modification. basically, divs need centered now, however, need vertically align content in cell in middle. changing vertical-align: middle; .column nothing. if change display: inline-block; .column display: table-cell , align content in middle, .column divs no longer centered , widths broken (currently evenly set 25%). setting margin:auto; or text-align on parent nothing. i've been running around days. appreciated. /* setting container table maximum width , height */ #container { display: table; height: 100%; width: 100%; } /* sections (container's children) should table rows minimal height */ .section { display: table-row; min-height: 1px; } /* need 1 container, setting full width */ .columns-container { display: table-cell; height: 100%; width:100%; text-align: center; } /* creating columns */ .column { display: inline-block; vertical-align

Node.js with Express fails to connect to MongoDb - Error: connect ECONNREFUSED -

if don't start connection mongo on port 27017 via mongod in console, when try starting express server following error: error: connect econnrefused @ exports._errnoexception (util.js:746:11) @ tcpconnectwrap.afterconnect [as oncomplete] (net.js:1000:19) if connect via mongod in shell, , run node app.js, works fine. //app.js var express = require('express'), app = express(), mongoclient = require('mongodb').mongoclient; app.route('/') .get(function(req, res){ res.send("hello, world!") global.db.close(); }); mongoclient.connect('mongodb://localhost:27017/nvps', function (err , database) { if(err) throw err; global.db = database; app.listen(3000, function(){ console.log('express server started on port 3000'); }); }); why doesn't mongo connection initiated when go http://localhost:3000/ on machine?

Git: How do I keep update with a specific branch? -

question 1 if have not yet created git repo locally, , need first time sync specific branch. question 2 if local folder git in sync master, , want sync branch ? if don't have local repo, have nothing. first have clone remote repository using git clone <remote_repo_url> . if want start developing on different branch, if name of branch branch_name , execute command git checkout branch_name . note assumes branch exists on local repository. if exists on remote repository, run command git fetch --all pull remote branches onto local branch.

Look up a song in MPD's database by song ID -

i'm using python-mpd2, can accept answers in raw mpd command form. given song's id in database (such "8231"), correct way query mpd's database song? mpdcli.find("any", "8231") (translates find 8231 ) returned no results, , can't find in documentation. the solution can think of maintaining copy of database within client, not want do, obvious reasons. i'm aware of existence of currentsong it's not suitable (i need songs aren't playing, id). playlistid {songid} displays list of songs in playlist. songid optional , specifies single song display info for. from here https://www.musicpd.org/doc/protocol/queue.html

sql server - Deleting duplicates in a time series -

Image
i have large set of measurements taken every 1 millisecond stored in sql server 2012 table. whenever there 3 or more duplicate values in rows delete middle duplicates. highlighted values in image of sample data ones want delete. there way sql query? you can using cte , row_number : sql fiddle with ctegroup as( select *, grp = row_number() over(order ms) - row_number() over(partition value order ms) yourtable ), ctefinal as( select *, rn_first = row_number() over(partition grp, value order ms), rn_last = row_number() over(partition grp, value order ms desc) ctegroup ) delete ctefinal rn_first > 1 , rn_last > 1

sql - select clause evaluates and return value from different columns of joined tables -

i'm pretty sure question answered before cannot search properly. please support. my question following: i have 2 tables(a+b) joined. put condition in select clause return value column - either or b based on specific value evaluate. for example select a.id, a.country, case city when a.city '%york' "value a.city" else value b.town end a, b a.id=b.id thanks in advance your pseudo code pretty close select a.id, a.country, case when a.city '%york' a.city else b.town end location join b on a.id=b.id

android - SurfaceView doesn't work with Video 360 used Panframe library -

i have 2 videos, first video suferfaceview, use mediaplayer library, , video 360 video, use panframe library. problem can't show these videos same time. when load 360 video , after add surface. in screen app show video 360. this code i'm using: public void loadvideo(string filename) { mpfview = pfobjectfactory.view(mainactivity.this); mpfasset = pfobjectfactory.assetfromuri(this, uri.parse(filename), this); mpfview.displayasset(mpfasset); mpfview.setnavigationmode(mcurrentnavigationmode); //mviewsurfacelibrary mframecontainer.addview(mpfview.getview(), 0); mvidsurface = (videoview) findviewbyid(r.id.surfview); mvidholder = mvidsurface.getholder(); mvidholder.addcallback(this); } does know how use panframe library , add overlay surfaceview? both videos seem playing can hear sound of 1 playing in surfaceview, panframe library overlaying everything.

php - How to allow wordpress website browsing but no file write or create -

i know how can setup website in way can browse website deny creation or editing of file except ftp access. i have wordpress website gets hacked on , over. know have find exact vulnerability, quick temporary fix, deny website create new php pages or modify existing ones still allow update done ftp. for folder 755 , files 644 , can find, files/folder owned account user. on dedicated hosting using whm/cpanel. from i've read, doable using file ownership, hardly know group or user ownership put on files , folders achieve this. all malicious files loaded directly file upload script. can't deny wordpress uploading files. wordpress doesn't know ftp. via ftp permissions change file's permissions (not whole website upload rules). you have secure wordpress. process isn't hardly. steps: check if have last wordpress version (update wordpress themes/plugins/wordpress core). there plugins hide using wordpress. search on google "hide wordpress plugin

html - Spring MVC + jsp: How to receive a list of items in controllers? -

the requirement letting users upload list of tickets like: @requestmapping(value="/tickets", method=requestmethod.post) public void uploadtickets( @requestbody list<ticket> tickets) { // list of tickets } i know how upload single ticket. need create html form 3 fields (section, row, seat) , submit button. spring automatically convert uploaded form ticket object. not sure how upload list of tickets spring controllers. help? thanks! this depends on configuration. assuming normal spring configuration. you upload single ticket json request { "section":"", "seat":"", "row":"" } to list of tickets, use json array. [ { "section":"", "seat":"", "row":"" }, ......., { "section":"", "seat":"", "row":"" } ] to data format, of course depends

scroll - $(...).mCustomScollbar is not a function (JavaScript Modules and Dependencies) -

having trouble setting malihu-custom-scrollbar-plugin. i installed follows: jspm install mcustomscrollbar=npm:malihu-custom-scrollbar-plugin i import relevant viewmodel follows: import mcustomscrollbar 'mcustomscrollbar'; ... $('.article').mcustomscrollbar(); i following error: $(...).mcustomscrollbar not function looking @ dev-tools:network, library has loaded ?? you have 2 problems: 1) you've spelled mcustomscrollbar wrong (missing r in scroll) 2) need required css in template otherwise plugin fails load (your css location may differ) <link rel="stylesheet" href="../jspm_packages/npm/malihu-custom-scrollbar-plugin@3.0.9/jquery.mcustomscrollbar.css" /> <template> ... </template>

ruby - Rails 4.2 - Made a 'services' directory for PORO helpers but console/controllers etc don't see it -

i have logic going manipulate data before starting job queue. however, inside controller , in rails console cannot seem access classes. example: in app/services/hobo_service.rb have class hoboservice def initialize @api = hobos::api.new end def run hobo end private attr_reader :api def hobo api.hobo end end however, if in relevent controller put ... def create @name = hoboservice.new.run end ... raises exception saying object cannot found. it seems if in app directory should in pipeline , available. missing here? haven't been on rails since 3.2 until recently. i'm not sure why subdirectory of app ignored, let's try simple solution- happens when add application class in application.rb? config.autoload_paths += %w(#{config.root}/app/services)

php - Difference between 2 datetimes in minutes? -

i got following code: $now = new datetime(); $then = new datetime($accountexists['sub_limit']); $interval = $then->diff($now); $hours = $interval->format('%h'); $minutes = $interval->format('%i'); echo 'diff. in minutes is: '.($hours * 60 + $minutes); which returns difference between 2 datetimes in minutes. if then 2015-05-31 19:15:31 , now 2015-05-31 19:20:31 returns 5 minutes. day changes, if then changes 2015-05-30 19:15:31 still returns 5 minutes when should 1445 minutes. point out error? because months, years can have arbitrary number of minutes, might best want convert dates timestamps (seconds since epoch) have divide 60. fortunately, it's easy so: $now = new datetime('2015-05-31 19:20:31'); $then = new datetime('2015-05-30 19:15:31'); $seconds = abs($now->format('u') - $then->format('u')); $minutes = floor($seconds / 60); print $minutes;

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum

ios - All Exceptions breakpoint not finding "unrecognized selector sent to instance" error -

i getting following error: [__nscfnumber length]: unrecognized selector sent instance i understand error means, not able find coming from. turning on all exceptions breakpoint not helping, , not showing me line , file error coming from. does. wasted 4 hours trying manual breakpoints no luck. idea how can find this? i figured out. api using changed string value number, nsstring had 1 of objects getting set nsnumber instead of string. then, later in code trying set label. caused crash.

Two handles to same variable in C -

is there way can create 2 variables point same memory location, can read same memory int, float, char, way like? i want this, without pointer f, not have dereference every time read/write f. char myarray[100]; float* f = (float *)&myarray[10]; i want closest thing c++'s reference in c. i hope question makes sense. edit: read stream (4 kb worth) of bytes flash memory. stream contains shorts, ints , floats. know locations of these ints , floats in array. , want read/write aforementioned ints , floats ordinary variables. this example reads data predefined struct , packed (if necessary). beware of endian-ness! , of data types: int on target might short on pc. #include<stdio.h> #pragma pack(push, 1) struct mydata { int version; char title[16]; float reading[8]; } mydata; #pragma pack(pop) int main(void) { file *fp; struct mydata data = {0}; fp = fopen("mydata.bin", "rb"); if (1 != fread(&data, s

python - Correct use of sphinx tabularcolumns directive -

i'm trying center single table column using tabularcolumns directive documented http://sphinx-doc.org/markup/misc.html?highlight=tabularcolumns#tables simple example: .. tabularcolumns:: |c|l| +----------+------+ | num | name | +==========+======+ | 1 | 1 | +----------+------+ | 2 | 2 | +----------+------+ according reading, should center first column, html output of column 1 left aligned. misreading or misunderstanding something? using sphinx-build version 1.3.1

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

i've website developed using phpfox v3.0.7 . now i'm trying implement 'sse(server sent events)' 1 of php files. reference i'm giving below necessary code part of file. file titled process.class.php , present @ location /var/www/module/notification/include/service/process.class.php present on server having ip http://34.124.40.142/ . <?php /** * [phpfox_header] */ header('content-type: text/event-stream'); header('cache-control: no-cache'); defined('phpfox') or exit('no dice!'); /** * * * @copyright [phpfox_copyright] * @author raymond benc * @package phpfox_service * @version $id: service.class.php 67 2009-01-20 11:32:45z raymond_benc $ */ class notification_service_process extends phpfox_service { /** * class constructor */ public function __construct() { $this->_stable = phpfox::gett('notification'); } public function add($

Python flask form gives 405 -

i have form , every time try post method in buttom of question. application gives me 405 error directly. have checked database works using same method in console. (i have removed alot of html because styling , stuff that) <form action="/register" method="post" class="grid"> <div class="cell colspan3" style="margin-left:2%;"> <div class="input-control modern text"> <input type="email" name="email" id="email"> <span class="label">email</span> <span class="informer">skriv din email</span> <span class="placeholder">email</span>

javascript - Not able to render two canvas elements on same page - Backbone -

<div class="col-lg-5" id="id-sales-pie"> </div> <div class="col-lg-7" id="id-sales-line"> </div> mainchartview this.line.setelement(this.$('#id-sales-line')).delegateevents().render(); this.pie.setelement(this.$('#id-sales-pie')).delegateevents().render(); i have main chart view contains 2 id's , main chart view contains 2 views piechartview , linechartview. both views have templates when rendering 1 renders , other canvas element gives error uncaught typeerror: cannot read property 'getcontext' of null complete code: var $ = require('jquery'), handlebars = require('handlebars'), backbone = require('backbone'), maincharttemplate = require('../../templates/dashboard/chartscontainer.html'), piechartview = require('../../views/dashboard/piechartview'), linechartview = require('../../views/dashboard/line

javascript - Jquery hover out halting script -

i have script: $(document).ready(function () { var $navtoggle = $('.nav-toggle'); $(".navbtn").click(function () { if ($navtoggle.hasclass('active')) { $('#menu').multilevelpushmenu('collapse'); $navtoggle.removeclass('active'); $(this).addclass('active'); } else { $('#menu').multilevelpushmenu('expand'); $navtoggle.addclass('active'); $(this).removeclass('active'); } }); $(".navbtn").hover(function () { $('.nav-toggle').addclass('hover'); }); }); this works great hover incomplete because whenever add removeclass line , stops working ? so: $(".navbtn").hover(function () { $('.nav-toggle').addclass('hover'); $('.nav-toggle').removeclass('hover'); }); please can someonne trying res

python - No recipients have been added when trying to send message with Flask-Mail -

i trying send email flask-mail. create message recipients, assertionerror: no recipients have been added when try send it. in following code, print out message recipients , correct. how fix error? from flask import flask flask_mail import message, mail app = flask(__name__) app.config.update( debug=true, mail_server='smtp.gmail.com', mail_port=465, mail_use_ssl=true, mail_username='socialcreditsystem@gmail.com', mail_password='mypassword' ) mail = mail(app) @app.route('/') def hello_world(): msg=message('hey hey hey', sender='socialcreditsystem@gmail.com', recipients=['julian.fink1000@gmail.com']) print(msg.sender, msg.recipients) # ('socialcreditsystem@googlemail.com', ['julian.fink1000@googlemail.com']) print(msg.send_to) # set(['julian.fink1000@googlemail.com']) mail.send_message(msg) return 'hello world!' if __name__ == '__main

OWL API Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader -

owl api when write owlontologymanager man = owlmanager.createowlontologymanager(); the exception like: exception in thread "main" java.lang.noclassdeffounderror: com/google/common/cache/cacheloader @ org.semanticweb.owlapi.vocab.owlfacet.<init>(owlfacet.java:87) @ org.semanticweb.owlapi.vocab.owlfacet.<clinit>(owlfacet.java:60) @ org.semanticweb.owlapi.vocab.owl2datatype$category.<clinit>(owl2datatype.java:328) @ org.semanticweb.owlapi.vocab.owl2datatype.<clinit>(owl2datatype.java:74) @ uk.ac.manchester.cs.owl.owlapi.internalsnocache.<clinit>(internalsnocache.java:59) @ uk.ac.manchester.cs.owl.owlapi.owldatafactoryimpl.<init>(owldatafactoryimpl.java:128) @ uk.ac.manchester.cs.owl.owlapi.owldatafactoryimpl.<clinit>(owldatafactoryimpl.java:74) @ org.semanticweb.owlapi.apibinding.owlmanager.getowldatafactory(owlmanager.java:150) @ org.semanticweb.owlapi.apibinding.owlmanager.createowlontolog

Creating bitmap using C -

this follow question here, link i read , copy pasted code link code::blocks little change, now want create 20x20 black image so edited code unable open image on win7, says 'windows photo viewer can't open image'. can please advice me wrong code ?? my code:- #include<stdio.h> unsigned char bitmap[1000]; void bmpmake() { int i; // -- file header -- // // bitmap signature bitmap[0] = 'b'; bitmap[1] = 'm'; // file size bitmap[2] = 0xc6; // 40 + 14 + 400 bitmap[3] = 0x01; bitmap[4] = 0; bitmap[5] = 0; // reserved field (in hex. 00 00 00 00) for( = 6; < 10; i++) bitmap[i] = 0; // offset of pixel data inside image //thats 54 or d8 difference between starting , position data starts. bitmap[10]=0xd8; for( = 11; < 14; i++) bitmap[i] = 0; // -- bitmap header -- // // header size bitmap[14] = 40; for( = 15; < 18; i++) bitmap[i] = 0; // width of i