Posts

Showing posts from September, 2011

Rails 4 jquery link with bind firing on reload -

hi have strange behaviour in rails 4. have partial next code: #add_tabs = link_to "add tab", "#", id:"test" #data_retrieved :javascript $("#test").bind("click",function(){ alert("i'm working"); }); and everythime reload page alert fired. i'm lost. thanks in advance. update: thanks pavan realised happened. rails 4.1.8 uses turbolinks manages links on site in order preloaded. therefore everytime site reloads links fired. prevent behaviour must (as pointed pavan) set links remote: true in order let them managed ajax/javascript event. this: link_to "add tab", "#", id:"test", remote: true also, , more important, must use gem 'jquery-turbolinks' and sure application.js looks this: /= require jquery //= require jquery.turbolinks //= require jquery_ujs // // ... other scripts here ... // //= require turbolinks last not least, sure binding callbacks s

codemirror string coloring multiple lines -

i'm using codemirror javascript code coloring, , when put string in quotes "like this" colored fine. but when put string line break "like this" color messed on second line. is there way make sure color starts first quote , ends second quote, if there line break? javascript doesn't allow multi-line strings. can use backslash before newline, or use template literals (backtick-quoted strings), if don't, aren't writing valid javascript, , reason why codemirror mode doesn't highlight code expected.

yocto - Embedded system USB update via opkg -

i need provide single update file customer in order update embedded system via usb. system built using yocto . i'm curious if plan have implement usb updating viable, or if i'm missing should obvious. opkg exists on system, in order use opkg update needs have repo pull from. since have no network capabilities need put entire repo on usb drive. since need provide single file customer repo need tar file. procedure plug usb drive in the udev rule calls script , pushes background since long process (see this ) un-tar repo update file opkg update notify user may remove usb drive at least high-level point of view sound way update embedded system via usb? pitfalls might exist? well, regarding pitfalls might exist, 1 of biggest pitfall power outage in middle of process. how recover in case? (the answer might depend on type of embedded device making). (personally, i'm in favour of complete image based upgrades , not package based upgrades). regarding

php - Assoc. Array, get Element with special id -

i have assoc array alldept. want 'name' element array id e.g. '1'; how access id , output 'name'? the id saved in $result[$i]['abteilung'] thank much! $manager = $this->getdoctrine() ->getmanager('olddb') ->getrepository('chrisolduserbundle:bpdepartment'); $dept = $manager->findby([],['name' => 'asc']); $alldept = array(); foreach ($dept $singledpt){ $alldept[] = array("id" => $singledpt->getid(), "name" => $singledpt->getname() ); } as building array seem sensible build in way later usable. so why not build array this $manager = $this->getdoctrine() ->getmanager('olddb') ->getrepository('chrisolduserbundle:bpdepartment'); $dept = $manager->findby([],['name' => 'asc']); $alldept = array(); for

Spring: disabling validation also disables autowiring? -

as had learn typical spring configuration files headers, e.g.: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd" default-autowire="byname"> ... do indeed cause spring reach out , fetch referenced .xsd files internet validation of config file(s). if can not find or download schemas, fails. since code developing later run on servers won't have access internet need pre

queue - RabbitMQ Shovel Message Rate -

i have queue following parameters: x-ha-policy: all durable: true there static shovel configured process queue , server set destination. shovel configuration: {sources, [ {broker, "amqp://web:web@thisserver.spc/%2f"} ]}, {destinations, [ {broker, "amqp://web:web@remoteserver.spc/%2f"} ]}, {queue, <<"queuename">>}, {prefetch_count, 10}, {publish_fields, [ {exchange, <<"exchangename">>} ]}, {reconnect_delay, 5} my problem deliver / , ack rates never go on 50/s "queuename" queue, therefore causing huge build-up (7 million) in queue. i wonder if changing prefetch_count increase message rate? also "ack required" enabled consumer of queue. default value is: on_confirm. if messages forced acknowledged, limit message rates? there few things going on here affect message rates including network speed, message size, memory size rabbitmq broker, etc. can change pre-fetch count , make hi

pseudocode - Understanding pseudo-code for Python implementation -

i given pseudo-code written no longer around question. told need implement in python. @ point not looking write code in python me, trying understand pseudo-code can write in python. statsout = open('/shared/succedentsupercedent_stats','w') supercedents = tuple(open('/path', 'r')) succedents = tuple(open('abcd_.raw', 'r')) ( cols = 1 succedents.columns , colg = 1 supercedents.columns ) /**** load users 1 succedent/supercedent array future stats xy_array = new array ( supercedents.rows , 2 ) ( user = 1 supercedents.rows ) if succedents[user,cols].isvaliddouble , supercedents[user,colg].isvaliddouble xy_array [ user , 1 ] = succedents[user,cols].todouble xy_array [ user , 2 ] = supercedents[user,colg].todouble enddo endif endfor /*** stats 1 succedent:supercedent key users sumx = sum( of xy_array[1:supercedents.rows][1] sumy = sum( of xy_array[1:supercedents.rows][2] /*** out

Spring Tool Suit- Issue with launching Spring Starter Project -

while launching spring starter project , getting below exception. sts version 3.7.0 . new spring , appreciated. !entry org.eclipse.fx.core 4 0 2015-07-22 11:09:51.697 !message frameworkevent error !stack 0 org.osgi.framework.bundleexception: not resolve module: org.eclipse.fx.core [412] unresolved requirement: require-capability: osgi.ee; filter:="(&(osgi.ee=javase)(version=1.8))" unresolved requirement: require-bundle: org.eclipse.jdt.annotation; bundle-version="[2.0.0,3.0.0)"; resolution:="optional" -> bundle-symbolicname: org.eclipse.jdt.annotation; bundle-version="2.0.100.v20150311-1658" org.eclipse.jdt.annotation [421] unresolved requirement: require-capability: osgi.ee; filter:="(&(osgi.ee=javase)(version=1.8))" at org.eclipse.osgi.container.module.start(module.java:434) @ org.eclipse.osgi.container.modulecontainer$containerstartlevel.incstartlevel(modulecontainer.java:1582) @ org.eclips

node.js - CORS enabled - ajax response failure -

i trying make ajax 'post' request backbone client node.js server. have enabled cors on server seems successful not getting 'allow-cross-origin' errors in console' , server receiving posted data - posting username / password client , searching match in user database - server responds username found receiving ajax error on client. can soemone please - has been killing me days here client user model: app.userauth = backbone.model.extend({ defaults : { username : '', password : '' }, initialize : function(){ this.testreq() }, testreq : function(){ $.ajax({ url : "http://localhost:8080/api/authenticate", method : "post", datatype : "json", xhrfields : { withcredentials : true }, data : { username:"bottles24", password:"yoyo1234" }, success : function(data){ console.log

vb.net - Alternatives to returning Nothing (Null) when unable to use exceptions -

i'm facing problem @ work on very big system which, because of server performances , ressources, can't have exceptions managment. instead, system architects have decided return nothing when, exemple, database connector finds nothing. system coded in vb.net. i aware returning , passing nothing bad habbit various reasons such violation of of solid principles, noise in code null checks , addition of fragility because of nullpointerexceptions can passed-by. alongside fact returning nothing can mean hell lot of things (did crash?, did encountered error 1 of dependencies?, parameters valid?...) book "clean code" robert c. martin (or uncle bob) talks saying it's not practice. the question alternatives returning null not old doesn't give alternatives on instead of returning nothing. there's null object pattern . read on subject community seems divided in 2 camps, discourage use saying it's hiding faulty design , says it's actualy solution. i

excel - How to gather structural information of file? -

i writing function store 1 of sheets excel file. need repeat multiple times. think can use apply functions need check number of sheets in excel use is. there function or way check number of sheets (+ more information) of excel without opening file? no, believe have open file reference other workgook work. way without open connection excel adodb provider , use sql query gather information, extreme overkill need.

c# - Strange behavior of Enumerator.MoveNext() -

could explain why code running in infinity loop? why movenext() return true always? var x = new { templist = new list<int> { 1, 3, 6, 9 }.getenumerator() }; while (x.templist.movenext()) { console.writeline("hello world"); } list<t>.getenumerator() returns mutable value type ( list<t>.enumerator ). you're storing value in anonymous type. now, let's have @ does: while (x.templist.movenext()) { // ignore } that's equivalent to: while (true) { var tmp = x.templist; var result = tmp.movenext(); if (!result) { break; } // original loop body } now note we're calling movenext() on - copy of value in anonymous type. can't change value in anonymous type - you've got property can call, give copy of value. if change code to: var x = new { templist = (ienumerable<int>) new list<int> { 1, 3, 6, 9 }.getenumerator() }; ... you'll end getting reference in anon

linux - C++ Stand-alone executable -

i'm writing program in c++ requires file in current directory, want distribute 1 executable. love2d uses distribution method games create .love file , use cat combine love2d binary , .love file (eg. cat love2d awesomegame.love > awesomegame ). how can write program can use information @ end of itself, , extract out file. --- update --- thanks wonderful @dawid, have got working in cleaner method suggested (see answer if want way). here final source code: #include <fstream> #include "ncat.h" using namespace std; int main () { ofstream ofile("ncat.exe", ios_base::out | ios_base::binary); (unsigned long = 0 ; < ncat_exe_len; ++i) ofile << ncat_exe[i]; ofile.close(); return 0; } here's (binary) file i'm using: https://www.dropbox.com/s/21wps8usaqgthah/ncat.exe?dl=0 you can use xxd tool. can dump binary hex in c style include header. eg. > echo test > > xxd -i > a.h > cat a.h unsi

javascript - list only all keys including nested from json object in jquery -

i want list keys(including nested) in json object in jquery... keys/ json object dynamic program never format json sure i need jquery list keys json following sample data: { "status_code": 200, "status_text": "success", "count": 6, "data": [{ "date": "2012-02-27", "zone": "north zone", "centre": "chandigarh", "commodity": "tea loose", "price": "265" }, { "date": "2012-02-24", "zone": "north zone", "centre": "chandigarh", "commodity": "tea loose", "price": "265" }] } from above json want list keys. var jsonarray={ "status_code": 200, "status_text": "success", "count": 6, "data": [ { "date": "2012-02-27&quo

ios - MailCore2 Alternative -

i've spent great deal of time creating objective-c based application iphone. incorporated mailcore2 emails sent without dialog popping (apple's system of in-app email). app works on of devices, including outside devices associated testflight beta testing. unfortunately, moment apple reviews app, reject it, saying mailcore2 made alertview contents: "error! please connect internet or try again later.", , email never sends. my question is, there alternative mailcore2? i've heard of mailgun, see no documentation on site either objective-c or swift. thanks in advance reply. mailigun services , yes can send mail mailgun, not receive mail normal email app. anyway different mailcore (imap/pop). mailcore hard use... if need send email can provide entirely code achieve using mailgun.

php - What is the reason of using strip_tag or a write list for text input -

this question has answer here: when used correctly, htmlspecialchars sufficient protection against xss? 3 answers i know both use prevent xss attack. when use htmlspecialchars , seems ok. <script> , <?php ?> displayed on screen. means not functioning, right? so, question , htmlspecialchars enough preventing xss. if so, reason using strip_tag or white list of tag? htmlspecialchars safe enough. common displays same user typed, makes harmless. strip_tags takes tags away, usefull alot of other things.

windows - unable to use for loop output to set variable in batch -

i'm using loop acces text file bunch of files + directory formatted this: //srv/something/somethingelse/movie.mpg //srv/something/somethingelse/movie2.mkv //srv/something/somethingelse/movie3.mpg //srv/something/somethingelse/movie4.mkv i have replace .mpg , .mkv .xml, , write output away text file, i'm trying this: for /f "tokens=*" %%a in (%~dp0temporary\movies.txt) ( set string=%%a set find=.mkv set replace=.xml set string=%%string:!find!=!replace!%% set find=.mpg set string=%%string:!find!=!replace!%% echo %string%>>%~dp0temporary\xml.txt ) the output want this: //srv/something/somethingelse/movie.xml //srv/something/somethingelse/movie2.xml //srv/something/somethingelse/movie3.xml //srv/something/somethingelse/movie4.xml but this: echo off. echo off. echo off. echo off. i have been searching on over hour can't find works here rewritten batch code produces expected output input file. @echo off setlocal enabledelayedexpans

regex - Search for string in filename Perl -

i trying find filename contains string requested. instance, have string companyabc , looking search directory string in file name. want return file looking for. i tried following using regex not string checks letters in order not looking for: $foundfile = grep(/[comapnyabc]/i, readdir dir); is there way search string within file in perl , return file name? you close, had couple of problems. firstly, square brackets changing meaning of regex. pair of square brackets defines "character class" - set of characters match. regex match if finds one of characters. looking 'c' or 'o' or 'm' ... etc. that's not want. lose brackets. $foundfile = grep(/comapnyabc/i, readdir dir); but still doesn't give quite want. instead of returning filename, you'll number of matches found. if read the documentation grep , you'll see says: evaluates block or expr each element of list (locally setting $_ each element) , returns l

vb.net - How do I determine if a class member exists? -

i have public subroutine called many classes. however, need in subroutine pertains small number of classes call it. instead of going , adding property of existing classes, check see see if class has property , if so, it. can't seem figure out how check existence of member without getting error. for example: public class_1 public a1 string = "" public sub new() ' when button clicked call subroutine "check()" end sub end class public class_2 public a1 string = "" public a2 integer = 0 public sub new() ' when button clicked call subroutine "check()" end sub end class public class whatever public sub check(sender object) if sender.a2 = 0 ' end if end sub end class i have tried such things as if not(sender.a2 nothing) if isnothing(sender.a2) but can't past fact error using "sender.a2" since a2 not member of sender. how can chec

uiviewcontroller - Instantiating a Swift ViewController in an Objective-C project -

i've imported swift uiviewcontroller in objective-c-based project , i've followed apple's guide using swift classes in objective-c and this useful step-by-step swift integration xcode objc-based projects my project doesn't crash, can't view load. i'm attempting instantiate viewcontroller , shows white blank screen: uiviewcontroller *rootviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"myswiftvc"]; i put breakpoint in after prior line , po rootviewcontroller gives memory address. i threw println in viewdidload of myswiftvc , nothing comes up. lights "are on", nothing displays/executes. ideas resolution? here's method prior line called: - (void)checkdisclaimer { uistoryboard *storyboard = self.window.rootviewcontroller.storyboard; if ([[[nsuserdefaults standarduserdefaults]valueforkey:@"disclaimeracknowledged"]boolvalue] == no) { // set instantiate disclaimer vc

c# - EF insert in link table creates entries in one of the parent tables -

this situation: - table user (id, name) - table role (id, name) - link table usersroles (iduser, idrole) in link table iduser , idroles fks , both of them marked composite primary key. in ef produces following models: public class user { public int id {get;set;} public string name {get;set;} public icollection<role> roles {get;set;} } public class role{ public int id {get;set;} public string name {get;set;} public icollection<user> users{get;set;} } when inserting role user strange thing happens. user.roles.add(role); context.savechanges(); creates entry in usersroles table , adds role in role table. practically duplicates role trying associate user. is ef related? because fk , pk settings tables? any hint appreciated. does role adding have id value of role exists. if has name ef may add new entry database.

cmd - Want to exclude specific files with dir findstr -

i want find *.csv files within folder-structure except 2 files this code for /f "tokens=*" %%i in ('dir /b /s *.csv | findstr /v /i "\combinedold.csv" | findstr /v /i "\combined.csv"') the 2 files "combined.csv" , "combinedold.csv". the basic command should dir /s /b /a-d *.csv | findstr /v /i /e /c:"\\combinedold.csv" /c:"\\combined.csv" now, include inside for /f command, necessary escape non quoted special characters (the pipe in case), becomes for /f "delims=" %%i in (' dir /s /b /a-d *.csv ^| findstr /v /i /e /c:"\\combinedold.csv" /c:"\\combined.csv" ') echo %%i

c# - SQL Table Headers Not Saved To Excel -

the following code used save data sql table excel. problem is, not save table headers if table empty. worksheet4 = workbook.sheets[4]; worksheet4.name = "adjs "; sql.datatable dtag = new sql.datatable(); using (sqlconnection cn1 = new sqlconnection(constr)) { using (sqldataadapter da4 = new sqldataadapter(query4.tostring(), cn1)) { da4.fill(dtag); } } datacolumncollection dccollection4 = dtag.columns; (int = 1; < dtag.rows.count + 1; i++) { (int j = 1; j < dtag.columns.count + 1; j++) { if (i == 1) worksheet4.cells[i, j] = dccollection4[j - 1].tostring(); else worksheet4.cells[i, j] = dtag.row

smartcard - Connect to a SharePoint site when IIS requires client certificates -

i have application developed in c# helps me in managing permissions on our share-point 2013 site. recently, learned may loosing our local instance , moving instance that's behind cac enforced iis. have converted 1 of test sites require certificates , have tried several way send cert iis server still "the remote server returned , error: (403) forbidden. below few things have tried. var handler = new webrequesthandler(); handler.clientcertificateoptions = clientcertificateoption.automatic; handler.clientcertificates.add(pki.getclientcertificate()); handler.useproxy = false; using (var client = new httpclient(handler)) { context connection code here } the pki.getclientcertificate method, made returns selected certificate in case cac cert. funny sharepoint designer connects without issue or prompt. on matter appreciated. just add more things have tried context.credentials = new sharepointonlinecredentials(uli.username, uli.password); the uli userna

convert String format into datetime format in crystal report -

i have 1 field,i want convert date filed date time format following format in crystal report level. please suggest me formula cdatetime({database_string_field})

sql server - DBCC SHRINKFILE failing -

i'm trying shrink database on test system file won't smaller. size of mdf file 47 gb , unused space 38 gb. lot of data removed database hence large amount of unused space. the following error appears: start dbcc shrinkfile ( olympus_dat, 46912 ) @ 2015-07-23 15:27:19.300 dbcc shrinkfile: page 1:6017543 not moved because has not been formatted. how can fix error? sql server 2012 x64 additional information. following queries return error: dbcc traceon(3604) go dbcc page('olympus', 1, 6017543, 1) go dbcc traceoff(3604) go dbcc execution completed. if dbcc printed error messages, contact system administrator. page: (14440:908631589) buffer: buf @0x0000000009682040 bpage = 0x00000002b46b8000 bhash = 0x0000000000000000 bpageno = (1:6017543) bdbid = 6 breferences = 1 bcputicks = 0 bsamplecount = 0 buse1 = 23548 bstat = 0x809 blog = 0x5adb215a

c++ - netbeans (with Qt ) show "unable to resolve identifier" but just for some modules -

Image
i using netbeans7.1 qt , mingw on win64x . netbeans show me "unable resolve identifier" modules! checked everythings ( used lots of other modules many time working ) all qt modules on ( project properties -> build -> qt modules ) enabled modules file/header exists in right place ( check them navigate -> go deceleration/definition menu ) i rebuild project many time, check system path .. restart netbeans , etc.. updated: tried code assistance -> reparse project error disappear when i'm building project it's occurs again updated(2) system environment path variables related netbeans+qt+mingw c:\osprogramingpack\mingw\bin; c:\osprogramingpack\qt\4.8.6\bin; c:\osprogramingpack\mingw\msys\1.0\bin; show me this! updated(3): after used navigate -> go deceleration/definition directed me to another file witch contain #include again , happened 3 times! "c:\osprogramingpack\qt\4.8.6\include\qtnetwork\qsslsocket" directed

c# - Why this call to AddEventHandler is not working? -

i have following proof of concept classes: private class sourcemock { public event propertychangedeventhandler testevent; public void raise() { if (this.testevent != null) { this.testevent(this, new propertychangedeventargs("s")); } } } private class handlermock { public handlermock() { } public void propertyhandler(object sender, propertychangedeventargs e) { } } then if following works: sourcemock sourcemock = new sourcemock(); handlermock handler = new handlermock(); sourcemock.gettype().getevent("testevent").addeventhandler(sourcemock, new propertychangedeventhandler(handler1.propertyhandler)); but if following not work: sourcemock sourcemock = new sourcemock(); handlermock handler = new handlermock(); sourcemock.gettype().getevent("testevent").addeventhand

mysql - SQL storing large amount of data for each user -

i'm developing website, people able play small games. @ end of each game user given score, wish store in mysql database timestamp. allow me present data in nice way further down line. i use facebook login system, have table consists of user id, name, , facebook id. have table looks this: id------name------uid 1 bob 123123 2 marley 23134 then, each user need this: game1time game1score game2time game2score etc.... 3292 400 10 7824 129 32 101 231 i've looked @ of other related posts, , seems people think it's bad idea have table each user, me, seems easiest way. i this, store data in 1 table: id------name------uid-------game1time-----game1score----game2time-----game2score etc... 1 bob 123123 3291, 129 400, 32 10, 101 7824, 231 2 marley 23134 but seems might cause problems, when people play lot of same game. i feel i'm miss

sql - java.lang.ArrayIndexOutOfBoundsException: 0 -

this simple program check database , sql queries are create database studentapp_db ; create table students_info ( regno int(10) not null, firstname varchar (50) , middlename varchar (50), lastname varchar (50), primary key(regno) ) ; insert students_info the error getting while executing java program are exception in thread "main" java.lang.arrayindexoutofboundsexception:0 @ com.jspider.jdbc.common.callablestatementexample1. main(callablestatementexamp le1.java:32) and here java program package com.jspider.jdbc.common; import java.sql.callablestatement; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import com.mysql.jdbc.driver; public class callablestatementexample1 { public static void main(string[] args) { connection con = null; callablestatement cstmt = null; resultset rs = null; try { //1. load driver

apache kafka - BrokerNotAvailableError: Could not find the leader Exception while Spark Streaming -

i have written kafka producer in nodejs , kafka consumer in java maven. topic "test" created following command: bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test producer in nodejs: var kafka = require('kafka-node'); var producer = kafka.producer; var client = kafka.client; var client = new client('localhost:2181'); var producer = new producer(client); producer.on('ready', function () { producer.send([ { topic: 'test', partition: 0, messages: ["this 0 message sending kafka spark"], attributes: 0}, { topic: 'test', partition: 1, messages: ["this first message sending kafka spark"], attributes: 0}, { topic: 'test', partition: 2, messages: ["this second message sending kafka spark"], attributes: 0} ], function (err, result) { console.log(err || result); process.exit(); }); }); w

css - Align center inside relative container position -

actually have css show 2 cols , inside of cols button end of each col , button must show end of col , in center of col , no code works , when put width of button 5o% of container in col , show bad , , if use pixels show ok , in cases never in center , put code here : #container { position:relative; width:90%; margin:auto; border:1px solid #111; overflow:hidden; text-align:center; } #col { display:inline-block; width:20%; min-height:300px; text-align:left; background-color:red; margin-bottom:-9000px; padding-bottom:9000px; vertical-align:top; } .access { position: absolute; width:50%; height:35px; background-color:#111111; color:#ffffff; border:0px solid; bottom:3px; } <div id="container"> <div id="col"> hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>hi , how ?<br>

java - How to write a proper unit test for ClassNotFoundExceptions? -

i want test method following lines appear: try (connection connection = datasource.getconnection()) { ((org.postgresql.pgconnection) connection).adddatatype("geometry", class.forname("org.postgis.pggeometry")); ((org.postgresql.pgconnection) connection).adddatatype("box3d", class.forname("org.postgis.pgbox3d")); try (statement statement = connection.createstatement()) { /* * 4326 id of format in longitude , latitude values should * retreived. */ string sqlquery = "select st_transform(way, 4326) planet_osm_line (highway='footway' or highway='steps');"; resultset resultset = statement.executequery(sqlquery); while (resultset.next()) { pggeometry geom = (pggeometry) resultset.getobject(1); linestring line = (linestring) geom.getgeometry(); point[] waypoints

javascript - (JQuery) Use of word or phrase in textbox triggers action -

i have working jquery looks phrase , trigger: $("#id_message").on('keyup', function(){ if($('#id_message').val().tolowercase().indexof('foo foo') > -1){ doegg(); } }); however love able expand list of words or phrases. have separate list this, assume need in array? var phraselist = [ "foo foo", "foobar", "fooby foo foobar" ]; how can search word list? imagine list having maybe 5 phrases or so. , if user types "i foo foo" or "i love @ foobar" should still trigger textbox contains words list. also added problem, have script undoes function if user decides delete phrase: $("#id_message").on('keyup', function(){ if($('#id_message').val().tolowercase().indexof('foo foo') == -1){ undoegg(); } }); edit #1 the closest answer have found comes @nixful-autistic: $("#id_message").on('keyup', fu

cordova - PhoneGap BUILD and phonegap-facebook-plugin sample -

i want use phonegap-facebook-plugin in phonegap build application. the documentation here explains how add plugin config file not explain how use it. more specifically, does have experience plugin , phonegap build or matter other plugin? sample code? what version of "facebookconnectplugin.js" should use? (there several of in project) during development phase testing in browser first , on phone. how make work in both environments? thanks. actually, if go here , author has example of usage there. the version you're looking @ deprecated. use <plugin name="cordova-plugin-facebook4" source="npm" spec="1.4.0"> instead. you have add localhost facebook app settings.

Leaflet on Chrome - Tiles are pending -

i have website uses leaflet apis creating map custom tiles. works fine if zoom down , slowly, if go fast tiles stay pending. in chrome website freeze , after nothing works, firefox says tiles corrupted website continues work fine. when used google apis never happened. experienced same issue? how did solve?

awk - Regex to delete a line -

i have following pattern : "gear_size"=>"small", "gear_size"=>"medium", "name"=>"node.cip4pc.cisco.com", "region_name"=>"ccs", "gear_size"=>"large", node.cip4pc.cisco.com:10.203.24.175, i need delete line "gear_size"=>"small" , , "gear_size"=>"large" ,. these 2 lines don't have "name"=> pattern getting followed. so, need delete line "gear_size" not followed "name". i checked if command pcregrep works, command not supported. getting resolved great. thanks. edit: better solution if need name come directly after sed '/^"gear_size"/{n;/\n"name"=>/!d}' if line matches /^"gear_size"/ , , next line doesn't match /^"name"=>/ , delete it. original: horrible solution separation between gear_size , name sed '/ge

r - Change the position of the ticks in ggplot2 (inside the plot) -

Image
this question has answer here: how make axis ticks face inwards in ggplot2 1 answer i change position of ticks of left plot right 1 (ticks inside plot). library(ggplot2) library(grid) p <- ggplot(mtcars,aes(mpg,cyl))+ geom_point() + theme( axis.ticks.length=unit(0.5,"cm"), axis.line = element_line(color = 'black',size=0.1), axis.ticks.y = element_line(size=1,color='red'), axis.text.y = element_text(hjust=0.5)) i think can desired plot playing grobs surprise there not simple setting adjust ticks position! edit (shift tick marks using solution here ): setting axis.ticks.length mentioned gives right solution , axis text should postioned more near axis. hjust has no effect. p <- ggplot(mtcars,aes(mpg,cyl))+ geom_point() + theme( axis.ticks.length=unit(-0.25, "cm"),

javascript - data-ng-bind from $scope controller -

i'm lost, me? i have value in $scope retrieved json file: in controller: $scope.scopetitle = title; in json file: "title": "fruit.id || 'empty'" the fruit.id retrieved backend, , want display it's id in html. everything works fine if in html sth like: <span class="navbar-brand" data-ng-bind="fruit.id || 'empty'" /> the result on html is: fruit/12 or empty <- , it's if want pass via $scope, this: <span class="navbar-brand" data-ng-bind='scopetitle' /> it's not working, result on html is: fruit.id || 'empty' <- it's not my html generated in template in directive , i'm using $compile function compile html code. how write ng-bind expression achieve result via $scope? try use $scope.$eval in controller , use declare scopetitle $scope.scopetitle = $scope.$eval(title); **update : * can see assigning "fruit.id || &#

visual studio - Start a service appliction using StartService in C++ -

i created windows service application in c++ using visual studio 2013 . in main() function, call function body contains following code: : service_table_entry sertable[] = { { const_cast<char *>(servicename.c_str()), (lpservice_main_function)servicemain }, { null, null } }; int res = startservicectrldispatcher(sertable); if (res == 0) { debug_log(servicename+":startservicectrldispatcher failed", getlasterror()); return qerror; } my main() function contains system("start notepad"); i can build program , executable generated. try open exe program using openscmanager() , , createservice() . service created , listed under services.msc . right-clicked , started service , shows status started . nothing happens.. now if double click on exe shows message: error 1063: startservicecontroldispatcher failed , opens notepad. why notepad not opened when service started under services.msc ?

symfony - Choose php version on Ubuntu 14.04 (php vs php5) -

im trying start projects on laravel , symfony the issue following when write on terminal this: php -v i this: php 5.6.11 (cli) (built: jul 13 2015 09:19:13) copyright (c) 1997-2015 php group zend engine v2.6.0, copyright (c) 1998-2015 zend technologies and when write this: php5 -v i this: php warning: module 'pdo' loaded in unknown on line 0 php 5.5.9-1ubuntu4.11 (cli) (built: jul 2 2015 15:17:32) copyright (c) 1997-2014 php group zend engine v2.5.0, copyright (c) 1998-2014 zend technologies with zend opcache v7.0.3, copyright (c) 1999-2014, zend technologies the thing have few modules in php 5.6.11 version , modules have installed in 5.5.9 version. , both frameworks need modules in 5.5.9 version 5.6.11 version. english isnt native language, sorry if made mistakes writing this. did chance compiled 1 of versions manually? the best option have modules php 5.6 follow following guide: ht

python - AttributeError: 'unicode' object has no attribute 'xpath issue -

i trying capture value in "//html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td[17]/font" through xpath. not sure wrong doing when running below code getting error message "attributeerror: 'unicode' object has no attribute 'xpath'" can please me import smtplib import requests #import bs4 lxml import html email.mime.text import mimetext def login(): url = "http://172.16.3.16/bkg/nimble/newsite_airfail_isimba_dom.php" r = requests.get(url, auth=('stats', 'stats')) page = r.text return page def extractfailure(): loginpage = login() fail = loginpage.xpath('/html/body/table/tbody/tr/td[2]/table/tbody/tr[2]/td[17]/font') print fail if __name__ == '__main__': extractfailure() you appear have forgotten parse response body. you need use lxml.html parser somewhere before can use xpath expressions: def extractfailure(): loginp

Why the C structure definition in the implementation file is unavailable? -

i give following example illustrate question: 1) a.h structure declared a.h struct a_structure; typedef struct a_structure *a_structure_ptr; 2) b.c structure definition implemented #include "a.h" struct a_structure { int a; int b; int c; }; 2) main.c structure invoked #include <stdlib.h> #include "a.h" int main () { struct a_structure b; return 0; } however, cannot compile these c codes receive following error message: >main.c(6): error c2079: 'b' uses undefined struct 'a_structure' any ideas? thank in advance. edit : #include <stdlib.h> #include "a.h" int main () { struct a_structure *b=0; b=(struct a_structure*)malloc(12); b->a=3; free(b); return 0; } i tried create structure in way still failed. you need this: struct a_structure { int a; int b; int c; }; in a.h this typical approach when defining struct s i

c# - Combobox text property twoway binding not working -

i have combobox below <combobox verticalalignment="center" width="83.84" canvas.left="626.24" canvas.top="249.088" datacontext="{binding items[0]}" text="{binding textvariable, mode=twoway, notifyonvalidationerror=true, targetnullvalue='', validatesondataerrors=true, validatesonexceptions=true}" height="68.293" style="{staticresource comboboxdialogcontrolq69_74}" /> the problem is: when set value textvariable in view model gets displayed on ui. when change on ui not updated in property. i think missing obvious, appreciated. it works when tried doing below text binding on combobox, text="{binding textvariable, mode=twoway, updatesourcetrigger=lostfocus, notifyonvalidationerror=true, targetnullvalue='', validatesondataerrors=true, validatesonexceptions=true}" i have added 1 more property m

java - How eclipse generates .classpath file? -

when create java project in eclipse ide, .classpath , .project file. can guys please give me idea how eclipse generates both files? the .classpath file holds same information eclipse gui presents build path information. .project file holds other project-specific information eclipse has, except ui related information, places in files in .settings sub directory.

mysql - ERROR 1025 (HY000): Error on MODIFY column command -

i need modify primary key column. want change int bigint. there error. how can change it? don't want delete keys.. alter table items modify column itemnumber bigint(12) unsigned not null auto_increment; error 1025 (hy000): error on rename of './kohadata/#sql-3ae3_5cf5' './kohadata/items' (errno: 150) my table; create table `items` ( `itemnumber` int(11) not null auto_increment, `biblionumber` int(11) not null default '0', primary key (`itemnumber`), ) engine=innodb auto_increment=2147483647 default charset=utf8 collate=utf8_unicode_ci complications occur because of auto_increment , primary key attributes. how doing in 2 phases : remove primary key (alter table items modify column itemnumber bigint(12) unsigned not null, drop primary key;) add primary key again (alter table items modify column itemnumber bigint(12) unsigned not null auto_increment primary key;) or have read, might because foreign key constraints. n

php - What's the purpose of '\' when we create an object? -

this question has answer here: reference — symbol mean in php? 15 answers what's purpose of using backslash \ when create object in php? $iter = new \arrayiterator($arr); it's used create new object of qualified class. say, you're code in namespace "namespace1": namespace namespace1; $iter = new arrayiterator(); would resolved namespace1\arrayiterator(); and $iter = new \arrayiterator(); would resolved arrayiterator(); see: http://php.net/manual/de/language.namespaces.basics.php more infos namespaces.

ios - convert big yml data -

there other way/trick store depth map in database? basically, trying store 300000 double values. if helps can convert array nsmutablearray or similar can serialize it. don’t know yet how it. tried find way convert binary file instead of ascii no luck yet. you can save lot of memory storing raw binary data in blob. if don't have fixed rows , cols of matrix, can put @ beginning of file 2 integers rows , cols. i'll add simple example on how save , load data of matrix, preceded rows , cols. #include <opencv2/opencv.hpp> #include <fstream> using namespace cv; using namespace std; int main() { mat1d m = (mat1d(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9); mat1d n; { ofstream ofs("test.bin", fstream::binary); ofs.write((char*)&m.rows, sizeof(int)); // save rows ofs.write((char*)&m.cols, sizeof(int)); // save cols ofs.write((char*)m.data, m.total()*sizeof(double)); // save data } {

RPM-GPG-KEY error while doing 'yum update' / 'yum install' -

while trying update fedora release got following error: gpg key retrieval failed: [errno 14] curl#37 - "couldn't open file /etc/pki/rpm-gpg/rpm-gpg-key-fedora-x86_64" therefore update not finish. not able install using yum due same error. i'm running of fedora 21 (recently updated fedora 19 using fedup). i looked @ differens of files fedora-updates.repo , fedora-updates.repo.rpmnew in directory /etc/yum.repos.d/ i notiched $releaseserver varialble missing in fedora-updates.repo so changed lines from gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-fedora-$basearch to gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-fedora-$releasever-$basearch after update without problems.

java - Wicket: scroll to certain anchor after clicking a link -

i've asked similar question form, need scroll anchor after user clicked link - my solution other thread not work. :( final link link = new statelesslink("linkid") { @overrride public void onclick() { dosomething(); add(new behavior() { @override public void renderhead(component component, iheaderresponse response) { super.renderhead(component, response); response.render(new headeritem() { @override public iterable<?> getrendertokens() { return collections.singletonlist("javascript-anchor"); } @override public void render(response response) { response.write("<script type=\"text/javascript\">\n"); response.write("window.location.href='#rules';\n"); response.write("</script>\n"); } }); } }); setresponsepa

android - WebView videos not playing on samsung devices -

Image
i have simple webview ,nothing complex url = getintent().getextras().getstring(finalvariables.load_url); mwebview =(webview) findviewbyid(r.id.mywebview); progressbar = (progressbar)findviewbyid(r.id.progressbar); if(!textutils.isempty(url)) mwebview.loadurl(url); mwebview.setwebviewclient(new webviewclient() { @override public void onpagestarted(webview view, string url, bitmap favicon) { super.onpagestarted(view, url, favicon); progressbar.setvisibility(view.visible); } @override public boolean shouldoverrideurlloading(webview view, string url) { return super.shouldoverrideurlloading(view, url); } @override public void onpagefinished(webview view, string url) { super.onpagefinished(view, url); progressbar.setvisibility(view.gone); } }); websettings websettings = mwebview.getsettings(); websettings.setjavascrip

javascript - Filter array to match other array -

i need able filter array based on ids contained in array. basically, have array of tweet ids contain specific hashtag within hashtag object manipulate. h.tweet_ids = [*sometweetid*, *someothertweetid*, …] on other hand, have usertimeline array contains tweets sent authenticating user. its structure looks ( https://dev.twitter.com/rest/reference/get/statuses/user_timeline ): [ { "coordinates": null, "favorited": false, "truncated": false, "created_at": "wed aug 29 17:12:58 +0000 2012", "id_str": "240859602684612608", "entities": { … }, "in_reply_to_user_id_str": null, "contributors": null, "text": "introducing twitter certified products program: https://t.co/mjj8xant", "retweet_count": 121, "in_reply_to_status_id_str": null, "id": 240859602684612608, "geo":