Posts

Showing posts from June, 2014

jQuery possible optimize custom hover code -

i have menu , each list item gets different color border on hover. works feels clunky. how can optimize code don't repeat much. $('ul>li:first-child>a').hover(function() { $(this).css('border-bottom', '0.2em solid blue'); }, function() { $(this).css('border-bottom', '0'); }) $('ul>li:nth-child(2)>a').hover(function() { $(this).css('border-bottom', '0.2em solid green'); }, function() { $(this).css('border-bottom', '0'); }) $('ul>li:last-child>a').hover(function() { $(this).css('border-bottom', '0.2em solid yellow'); }, function() { $(this).css('border-bottom', '0'); }) ul li { display: inline-block; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul> <li><a href="#">blue</a></li> <li...

swift - Add a Custom Back Button to a Custom Navigation Bar -

i have been trying add custom button nav bar being created on load using multi-storyboard set-up, button not appear automatically, plus trying use custom image it. this have far: class addfundsmethodtable : uitableviewcontroller { override func viewdidload() { super.viewdidload() } override func didreceivememorywarning() { super.didreceivememorywarning() } override func viewwillappear(animated: bool) { self.stylenavbar() } func stylenavbar() { var newnavbar = uinavigationbar(frame: cgrectmake(0,0, cgrectgetwidth(self.view.frame), 100.0)) newnavbar.tintcolor = uicolor.whitecolor() var navitem = uinavigationitem(title: "choose method") var backimage = uiimage(named: "backbtn") var backitem = uibarbuttonitem(image: backimage, style: .plain, target: self, action: "backbutton:") navitem.leftbarbuttonitem = backitem newnavbar.setitems([navitem], animated: false) self.view.addsubview(newnavbar) } func bac...

Any Plugin For In app display calendar Cordova -

i ask cordova/phonegap plugin can display calendar inside application, user allow click on date perform action. thanks. example : screenshot application https://www.facebook.com/photo.php?fbid=480297695450952&set=a.265532286927495.1073741826.100004121760330&type=1&theater you cannot use calendar directly app. need iframe google calendar can opened using in-app browser in cordova. you can use phonegap calendar plugin : https://github.com/eddyverbruggen/calendar-phonegap-plugin

angularjs - how to add filter on button click in angular js? -

i trying add filter on image click .actually there icon in demo "v" consider first 1 near "inject" on header.i apply click event on .actually want add orderby filter in first column on click of image. did reverse array on button click .but may come condition when array not sorted need first sort given array .that trying add filter on image click .i try read documentation of orderby there nothing written how can use button click event . https://docs.angularjs.org/api/ng/filter/orderby javascript code $scope.sortdata = function() { //alert('--') $scope.displaydata=$scope.displaydata.slice().reverse(); }; here code http://plnkr.co/edit/fql7g2w5ylereopy4b10?p=preview here code working fine when user click image come ascending , descending order.but when array not sorted not work ? i assume $scope.sortdata click, if so, can add filter via: scope.sortdata = function() { //alert('--') $filter('filtername...

javascript - Is it possible to enable unbounded number of renderers in THREE.js? -

in order avoid xy problem, let me explain i'm coming from. plot large number of waveforms stacked on top of each other using same time axis, using three.js. waveforms three.line's , implementing zoom/pan/scaling of these waveforms modifying view bounds of orthographic camera. my initial attempt @ accomplishing lead me create multiple canvas elements fixed height, stacked on top of each other, , attach three.webglrenderer each canvas. worked perfectly, until tried scaling past 15 or waveforms, three.js gave me warning "too many active webgl contexts", , started deleting old contexts. i feel decent practice, considering it's same technique applied here: http://threejs.org/examples/#webgl_multiple_canvases_grid in example, 4 webglrenderers created, 1 each canvas. so, possible override warning somehow, , create unbounded number of canvas elements, each own renderer? aside: i have considered using 1 scene , positioning waveforms accordingly within it,...

javascript - How do I fix this AngularJS error: Can't find variable: $interval -

modulet1.controller('sessionclock', function ($scope) { $interval(wtf, 5000); }); from error console: error: can't find variable: $interval i using angularjs 1.3.14. setting $scope variables in controller , data-binding them in html works fine, until add $interval or $timeout line controller , error. what's going on? modulet1.controller('sessionclock', [ '$scope','$interval', function ($scope,$interval) { $interval(wtf, 5000); }]); this should solve problem. make sure have same order in injector , function().

express.static doesn't work in node.js project -

i have socket.io project doesn't let me use public folder. launch hello.js http://i.stack.imgur.com/ugdzw.png but see http://i.stack.imgur.com/fzhjj.png i tried , reinstalled node.js var express = require('express'); var app = express(); var http = require("http"); var io = require('socket.io'); var url = require('url'); var fs = require('fs'); app.use(express.static(__dirname + '/public')); var server = http.createserver(function(request, response){ console.log('connection'); var path = url.parse(request.url).pathname; switch(path){ case '/': response.writehead(200, {'content-type': 'text/html'}); response.write('hello world'); response.end(); break; case '/socket.html': fs.readfile(__dirname + path, function(error, data){ if (error){ response.wr...

c# - "Compiler executable file csc.exe cannot be found" on IIS 8.5 -

i'm trying run application on iis @ localhost , displaying error message: compiler executable file csc.exe cannot found here stack trace : [invalidoperationexception: compiler executable file csc.exe cannot found.] system.codedom.compiler.redistversioninfo.getcompilerpath(idictionary`2 provoptions, string compilerexecutable) +8338491 microsoft.csharp.csharpcodegenerator.fromfilebatch(compilerparameters options, string[] filenames) +739 microsoft.csharp.csharpcodegenerator.system.codedom.compiler.icodecompiler.compileassemblyfromfilebatch(compilerparameters options, string[] filenames) +170 system.web.compilation.assemblybuilder.compile() +12076312 system.web.compilation.buildproviderscompiler.performbuild() +301 system.web.compilation.applicationbuildprovider.getglobalasaxbuildresult(boolean isprecompiledapp) +12615825 system.web.compilation.buildmanager.compileglobalasax() +50 system.web.compilation.buildmanager.ensuretoplevelfilescompiled() +665 [httpexception (0x80004...

c - TFTP Client (based on ENET) won't connect to remote TFTP server -

i'm trying implement tftp client in c (windows, visual studio 2005). the tftp client supposed connect remote tftp server address on port 69. the tftp client using enet api networking stuff, can't work. the tftp client never switches 'connected' state , stuck in 'connecting' state. when run native windows tftp client on windows 7 (cmd, windows console), has no problem connecting tftp server , can retrieve remote file without problems. so must doing wrong in code below , i'm hoping out there can tell me i'm doing wrong: #include "enet.h" #include <stdlib.h> #include <stdio.h> #pragma comment(lib, "winmm.lib") #pragma comment(lib, "ws2_32.lib") void main(void) { enetaddress address; enetevent thisevent; enetpeer *peer; enethost* client; int rc; memset(&thisevent,0,sizeof(enetevent)); rc = enet_initialize (); /* create tftp client */ client = enet_host_crea...

java - maximum number of elements which can be added to an arraylist -

question :- you're given string s of n characters. it's known string consists of lowercase latin letters. string generated randomly. means every symbol chosen randomly , independently others set {'a', 'b', ..., 'z'}. letters has equal probability appear. you're given q queries on string. each query of form p c, p integer between 1 , n (both inclusive) , c character set {'a', 'b', ..., 'z'}. both p , c chosen @ random , independently other queries. when have query of form p c have change pth symbol of s c. after every change ask output number of distinct nonempty sub-strings of s. input format first line of input consists of 2 single space separated integers n , q - length of string s , number of queries respectively. the second line contains string s itself. the following q lines describe queries in form p c, p , c separated single space. constraints 4 ≤ n ≤ 75000 4 ≤ q ≤ 75000 output format output q l...

php - Perform partial search on MySQL table when exact match may be available -

i running following sql statement php script: select phone, coalesce(preferredname, popularname) distilled_contacts phone :phone limit 6 as obvious, statement returns first 6 matches against table in question. value i'm binding :phone variable goes this: $search = '%'.$search.'%'; where, $search string of numerals. wildcard characters ensure search on, 918 , return every record phone field contains 918 : 9180078961 9879189872 0098976918 918 ... my problem happens if there exist entry value matches search string exactly, in case 918 (the 4th item in list above). since there's limit 6 , first 6 entries retrieved may or may not contain 1 exact match. there way ensure results contain record exact match, on top of resulting list, should 1 available? you use order ensure exact match on top: order case when phone = :phone 1 else 2 end

r - why does rbind need a loop to create a data frame and not just a vector of matrixes -

for (i in 1:5) { dat <- rbind(dat, read.csv(files_full[i])) works, dat <- rbind(dat, read.csv(files_full[1:5])) doesn't: error in file(file, "rt") : invalid 'description' argument files_full returns this: [1] "diet_data/andy.csv" "diet_data/david.csv" "diet_data/john.csv" [4] "diet_data/mike.csv" "diet_data/steve.csv" from exercise: https://github.com/rdpeng/practice_assignment/blob/master/practice_assignment.rmd rbind() meant bind it's parameters, not elements contained in lists inside of parameters. example dat <- rbind(read.csv(files_full[1]), read.csv(files_full[2], read.csv(files_full[3]) would work. if want turn list parameter, use do.call dat <- do.call("rbind", vectorize(read.csv, simplify = false)(files_full)) here used vectorize() allow read.csv return list when given vector of file names.

c++ - How to store type information, gathered from a constructor, at the class level to use in casting -

i trying write class can store , use type information in without need template parameter. i want write this: class example { public: template<typename t> example(t* ptr) : ptr(ptr) { // typedef t enclosedtype; want avaialable @ class level. } void operator()() { if(ptr == null) return; (*(enclosedtype*)ptr)(); // can cast pointer , call () operator if class has one. } private: void* ptr; } i not asking how write is_functor() class. i want know how type information in constructor , store @ class level. if impossible, different solution appreciated. i consider , valid question, however, there no general solution beside using template parameter @ class level. tried achieve in question -- using typedef inside function , access in whole class -- not possible. type erasure only if impose restrictions onto constructor parameters, there alternatives. in respect, here example of type e...

design - Making state transitions using xilinx -

i trying write asynchronous digital system fast clock. inputs determined 2 switches , button allow entering inputs.each input determines allows passing state. used internal clock b8 of digilent basys2 board. seem second state correctly can't other states. behavioral simulation gave expected results. here implementation, entity states port ( x : in std_logic; y : in std_logic; clock : in std_logic; input : in std_logic); end states; architecture behavioral of state signal ff : std_logic_vector (2 downto 0):="000"; begin process(clock) begin if(rising_edge(clock)) if(input='1') ff(0)<= (((ff(1)) , (ff(2)) , (not x) , y) or (ff(0))); ff(1)<= (((not ff(0)) , (not ff(1)) , (ff(2)) , x , (not y)); ff(2)<= (((not ff(0)) , (not ff(1)) , (not ff(2)) , x , y) or ((not ff(0)) , (ff(1)) , (not ff(2)) , (not x) , (not y))); z <= (((not ff(0)) , (ff(1...

java - Best way to access MS SQL DB behind a firewall -

i have multi-tenant app needing access customer-provided database residing behind firewall, without requiring user open ports, etc. if write ourselves, we're thinking path our app customer's database be: some sort of broker/proxy-capable data abstraction layer (hibernate, jpa, etc) jms communicate software somewhere behind customer firewall the server side of #1 jdbc customer's database is better approach running jdbc on ssh or vpn? can recommend existing open-source solutions might want? thanks! :) the easiest way use ssl connection , can use data access technology: jdbc jpa you need configure secure connection url: <property name="hibernate.connection.url"> jdbc:sqlserver://system:port;databasename=mydb;integratedsecurity=true;encrypt=true;trustservercertificate=true </property>

how to improve performance to run faster (python) -

right now, program takes more 10mins lol try display possible words (if words in file) can created given letters. in file, has more 4000+ words how make program run faster using recursion, , not using libraries because i'm new it. if user input letters: b d o s y then possible words in file create: b d boy boys the code: words = set() def found(word, file): ## reads through file , tries ## match given word in line. open(file, 'r') rf: line in rf.readlines(): if line.strip() == word: return true return false def scramble(r_letters, s_letters): ## output every possible combination of word. ## each recursive call moves letter ## r_letters (remaining letters) ## s_letters (scrambled letters) if s_letters: words.add(s_letters) in range(len(r_letters)): scramble(r_letters[:i] + r_letters[i+1:], s_letters + r_letters[i]) thesarus = input("enter name of file contai...

How to debug to find where a value is changing in C#/ASP.Net -

a project inherited uses dynamiccontrolsplaceholder . within placeholder, code adds controls render out to <table> <-- htmltable <tr> <-- htmltablerow <td> <-- htmltablecell question <-- literalcontrol </td> ... </tr> ... </table> the dynamiccontrolsplaceholder correctly stores structure in viewstate , correctly restores structure (though <td> has literalcontrol empty text property rather "question"). some time later, in system.web.ui.page.loadallstate() system.web.ui.control.loadviewstaterecursive(object savedstate) system.web.ui.control.loadchildviewstatebyindex(system.collections.arraylist childstate) system.web.ui.control.loadviewstaterecursive(object savedstate) system.web.ui.control.loadchildviewstatebyindex(system.collections.arraylist childstate) ... (lots of recursive calls) ... system.web.ui.htmlcontrols.htmlcontainercontro...

Travis CI : How to allow failures with a customized environment variable? -

following this answer , wrote travis configuration file : language: php php: - 5.3 - 5.4 - 5.5 - 5.6 - 7 - hhvm - nightly branches: only: - master - /^\d+\.\d+\.\d+$/ matrix: fast_finish: true include: - php: 5.3 env: deps="low" - php: 5.5 env: symfony_version=2.3.* - php: 5.5 env: symfony_version=2.4.* - php: 5.5 env: symfony_version=2.5.* - php: 5.5 env: symfony_version=2.6.* - php: 5.5 env: symfony_version=2.7.* - php: 5.5 env: symfony_version=2.8.*@dev test_group=canfail allow_failures: - php: nightly - env: test_group=canfail before_script: - composer self-update - if [ "$symfony_version" != "" ]; composer require --dev --no-update symfony/symfony=$symfony_version; fi - if [ "$deps" = "low" ]; composer update --...

network programming - I am running DPDK packet Gen application. The application does not find any ports by itself and even If I try to add one it doesnt work? -

http://pktgen.readthedocs.org/en/latest/running.html pktgen dpdk application. screenshot in link shows how ports configured. me doesnt configure @ all. looking beginner first, may know, pktgen application use dpkd framework, thus, should have bind @ least 1 nic dpdk. check documentation dpdk: dpdk building instructions . should see nic correctly bound command: # path/to/dpdk/tools/dpdk_nic_bind.py --status then, can run pktgen . ports want use specified -p option (it's specific pktgen option it's after -- ). it's port mask, instance, if want first port (port 0) can use -p 0x1 . then, -m option permit choose core handle dpdk port. syntax not obvious, suggest read doc of pktgen option: pktgen command line options . example, short, option -m "[1:3].0 " says want cpu core 1 handle "rx port 0", , cpu core 3 handle "tx port 0". a simple command line pktgen , if use 1 port running on 2 cores be: ./app/pktgen -c 0x7 -n 3 -...

c# - Parallelizing a large amount of Bitmap.Clone operations -

i have dictionary of lists of objects, , each list need load bitmap using associated key, , each object in list, calculate transform, clone bitmap using transform, , save result. amount of objects in each list varies 60,000 1 sometimes, , doing serially take forever. so, tried parallelizing each loop in each list, unfortunately, bitmap class holds global lock, , so, avoid exception, have place lock on cloning , saving code, defeats point of using parallel loop in first place, cloning , saving time-consuming part of process. there way can subimage of bitmap in multiple threads? it turns out real answer, me @ least, drop gdi+, , use magick.net , better designed this. works perfectly, multithreading , expected speedup.

c# - Auto-increment readable number MVC -

for primary key in model, use guid wanted human readable in case wanted refer - created ticketnumber field. need field autoincrement , here code have: ticket.ticketnumber = db.tickets.max(t => t.ticketnumber) + 1; it not crashing not working either. ticket numbers coming out 0.

java - Android - How to put a item click in ListView with Hashmap and List -

in app, use asynctask named getimagetask image url int given user. example : url = " http://example.com/image.php?index= " + int i put image in imageview , in "doinbackground" , create 2 hashmap add element in 2 list. the first display list of index in listview when click in button "onclickindex" . the second 1 save image index given because want element of listview image when user click on ( onclickindex ). but i'm blocked on part because can't bitmap in second list index , don't know ? mainactivity.java public class mainactivity extends actionbaractivity { private edittext mynumber; private imageview myimage; private listview myindexlist; private arraylist<hashmap<string,string>> list = new arraylist<>(); private arraylist<hashmap<integer,bitmap>> list2 = new arraylist<>(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); se...

gruntjs - Rename a folder with Grunt or Node.JS -

is possible rename folder without whole process of making new directory, copy files new directory, remove old directory? this process takes several minutes complete, forced use batch script rename folders, i'd prefer handled grunt. looking through node docs appears there no way rename folders similar way 'mv' or 'rename' commands work. the use-case faster deployment workflow grunt on intranet site. i'd minimal down time, 2 minutes of downtime copy files not ideal. i stage website on server in www/test. i rename www/prod www/archived then rename www/test www/prod making new site live. using grunt-shell solved problem, have warn future developers platform shell commands meant for, in case windows. shell: { options: { stderr: false }, 'archivetodelete': { command: 'rename <%= yeoman.winserver %>\archived delete-this' }, 'livetoarchive': { ...

c++ - Template tricks with const char* as a non-type parameter -

i aware passing directly const char* template non-type parameter erroneous, since 2 identical string literals defined in 2 different translation units may have different addresses (although of time compilers use same address). there trick 1 may use, see code below: #include <iostream> template<const char* msg> void display() { std::cout << msg << std::endl; } // need have external linkage // there no multiple definitions extern const char str1[] = "test 1"; // (1) // why constexpr enough? have external linkage? constexpr char str2[] = "test 2"; // (2) // why doesn't work? extern const char* str3 = "test 3"; // (3) doesn't work // using c_ptr_char = const char* const; // (4) doesn't work either extern constexpr c_ptr_char str4 = "test 4"; int main() { display<str1>(); // (1') display<str2>(); // (2') // display<str3>(); // (3') doesn't...

java - Printing an ArrayList in HTML and matching each item with an input box -

i'm working on piece of code have arraylist of items. i'm putting on webpage using html, , want print items in list input field next each item, user can type in quantity - kind of shopping cart. how go doing purely in html document? doing within java code itself, understand bad practice, , don't know how retrieve number type in - how that? would better off doing jsp? if so, can give me advice how go doing that? thanks in advance. here code have been working far. int counter = 1; out.println("<html><body><br><br>"); (gear g : gear) { out.println(counter + ". " + g.tostring() + "&nbsp; &nbsp; &nbsp; &nbsp; <input type=\"text\" name=\"" + counter + "\">" + "<br>"); counter++; } out.println("<br><br><br> <input type=\"submit\" value=\"enter\" name=\"en\" </html></body>...

ruby on rails - PDF Print view not the same between development and production environments using wkhtmltopdf/wicked_pdf -

i using wkhtmltopdf/wicked_pdf generate pdf view in rails on heroku. running mac os x locally. here versions: - ruby 2.1.3 (both) - rails 4.0.3 (both) - wkhtmltopdf-binary-edge, 0.12.2.1 (local) - wkhtmltopdf-amd64, 0.12.2.1 (production) - wicked_pdf, 0.11.0 (both) the issue having some of css code rendering correctly on both local environment , production while other css code appears ignored. code used repeat table headers , prevent rows being split on 2 pages. see below: .table-break { page-break-inside:auto !important; } .row-break { page-break-inside:avoid !important; page-break-after:auto !important; } .head-break { display:table-header-group !important; } here 2 images depicting discrepancy: local: https://docs.google.com/a/digiquatics.com/file/d/0b321e2h8q00czwlmcfryaxrrsek/edit production: https://drive.google.com/file/d/0b321e2h8q00cndi1vfl3ntdzzlu/view thank in advance!

Force SourceTree ignore line endings in git files -

there many posts still resolution not clear or isn't working me. problem seems known.. i checked out project in unix , git status shows no differences. settings here: bash-3.2$ git config core.autocrlf false bash-3.2$ git config core.whitespace cr-at-eol but use sourcetree (pointing same unix code base through nfs mount) conveniences. settings above attributes same. sourcetree shows bunch of differences in based on purely line endings. what straightforward solution this? how come sourcetree has no settings in ui around this?

php - Simple controller with Magento 1.8.0 -

i newbie in magento world, , want create simple controller described here . when put browser getting 404 error. try find solution in web didn't. can me please? if need peace of code me. thanks! p.s. module active, check in admin dashboard. directory structure should follows: app/code/local/magentotutorial/helloworld/controllers/indexcontroller.php app/code/local/magentotutorial/helloworld/etc/config.xml app/code/local/magentotutorial/helloworld/etc/config.xml): <?xml version="1.0"?> <config> <modules> <magentotutorial_helloworld> <version>0.1.0</version> </magentotutorial_helloworld> </modules> <frontend> <routers> <helloworld> <use>standard</use> <args> <module>magentotutorial_helloworld</module> <frontname>hel...

java - Selenium getText() not working on htmlunitdriver -

i looked around , couldn't find specific answer helped me figure out what's happening in code. i'm running selenium webdriver test using htmlunitdriver . i'm uploading picture on photobucket learning purposes. i've used firefoxdriver , worked fine. tried use htmlunitdriver , ide says code working (i changed firefoxdriver htmlunitdriver) whenever check picture album don't see picture. first guess headless browser not waiting picture upload , leaves, added ugly sleeps check onto , still doesn't work! here's code driver.get("http://s394.photobucket.com/upload/links"); thread.sleep(3000); driver.findelement(by.id("urlinput")).sendkeys("photo_link"); driver.findelement(by.id("uploadbtn")).click(); thread.sleep(3000); string text = driver.findelement(by.classname("progresscount")).gettext(); driver.findelement(by.id("goalbum")).click(); driver.close(); the gette...

plot - R - plotting specific columns as x with two rows as the lines -

Image
here small sample of data: gene_name ctrl_lsm1_ratio_t0 ctrl_lsm1_ratio_t1 ctrl_lsm1_ratio_t2 22 abp140 -0.262682 -0.303352 -0.223626 246 ari1 -0.163952 -0.374765 -0.321876 454 bph1 -0.517519 -0.524553 -0.747609 513 bur6 0.645573 0.217433 0.390403 588 cdc20 -0.264072 -0.665268 -0.594191 ctrl_lsm1_ratio_t3 ctrl_lsm1_stat_t0 ctrl_lsm1_stat_t1 ctrl_lsm1_stat_t2 22 -0.421704 no no no 246 -0.692391 no no no 454 -0.793595 no no yes 513 0.200799 yes no no 588 -0.523884 no yes yes ctrl_lsm1_stat_t3 systematic_name 22 yes yor239w 246...

cgi - What is the best way to create a web interface to an interactive perl script? -

i have interactive perl shell script asks user input , accordingly choice script returns set of options choose from. now, have demand create web interface it. no more black terminals blinking prompt our users. wondering best way pull off minimum changes original script? how keep script running , wait user input? best way send user input script , return it? or should refactor script use cgi? want hear general direction should take. know basic of perl , cgi. if using cgi these days might using modern , fast plack . since plack wrap cgi style application can use cgi application "inside" plack modern features, pluggable middleware, etc., alongside olde-fashioned 1990's traditions. depending on how complex application there's number of small frameworks , helper modules can make working plack easier. converting console application use web interface might easier if use squatting or kelp .

Problems formatting a string - Python 2.7.3 -

i'm coming across little weirdness str.format() method , wondered if there might workaround. here basic example of problem facing: 'something {first.alpha} {last}'.format(**{'first.alpha':'then', 'last':'else'}) i expect return: "something else" but instead error: keyerror: 'first' i'm aware there other approaches formatting string, until approach seemed perfect fit needed. the following example works perfectly, important 'first.alpha' key exists. 'something {first} {last}'.format(**{'first':'then', 'last':'else'}) is there way might still able use str.format() method , contain fullstops within key? the way use named arguments in format this >>> 'something {first_alpha} {last}'.format(first_alpha = 'then', last = 'else') 'something else' i wouldn't use first.alpha because thinks first has ...

in app purchase - Android/Google Play: do I really need my OWN server to manage inapp billing subscriptions? -

in google play doc , written "to verify purchase, app passes purchase token , other details backend servers, verifies them directly google play using google play developer api." my question : need own server implement inapp subscriptions in android app ? is there way implement subscriptions without own server ? (using google play inapp billing api directly app) thanks ! answer own question : no need have own server implement inapp subscriptions. own server allows add level of security don't care security in specific case (no problem if 1% of people bypass inapp process). an own server allows perform additional level of checking 'boolean verifydeveloperpayload(purchase p)' method. return 'true' in cases set default in google example. to implemeent subscriptions call : mhelper.launchsubscriptionpurchaseflow(this, sku_premium, rc_request, mpurchasefinishedlistener); instead of : mhelper.launchpurchaseflow(this, sku_premium, rc_req...

antlr - Porting ANTLR3 to ANTLR4 symbol to token replacement -

what appropriate translation antlr3 antlr4 syntax? tokens { and, or } with antlr3 used following replace & token and and_or : '&' -> , | '|' -> or ; how declare in antlr4? there no rewrite rules in antlr4, closest this: and_or : , | or ; , : '&'; or : '|';

java - Making two threads to continue running in background -

i'm writing android app involves 1 audiotrack , 1 audiorecord. run in 2 different threads, , both of them need continue run , not being killed when low memory/cpu if app running in background. searched , know use asynctask (just in music streaming app). however, i'm no sure how because thread runs audiotrack first created (once button on main activity pressed), thread create thread runs audiorecord (by creating runnable). i searched , know use asynctask (just in music streaming app) no. issue not threads, process. both of them need continue run , not being killed when low memory/cpu if app running in background strictly speaking, not possible. closest use service in turn uses startforeground() indicate has foreground priority. minimize probability android terminate process due low memory conditions, not eliminate it. also, please note need cpu powered on perform audio tasks. that, in turn, require wakelock . going hammer user's battery, point ...

c - stat(), fstat(), lstat(), and fopen(); how to write TOCTOU protected system independent code -

i've been dealing problem few weeks updating 20 year code needs system independent (work on both linux , windows). involves time-of-check, time-of-use (toctou) issues. made thread here , didn't go far, , after ruminating on while , searching deeper problem, think understand question bit better. maybe can ask bit better too... from i've read, code needs check if file exists, if accessible, open file, operations , close file. seems best way call lstat() , call fopen() , call fstat() (to rule out toctou), , operations , closing file. however, i've been lead believe lstat() , fstat() posix defined, not c standard defined, ruling out use system agnostic program, in same way open() shouldn't used cross-compatibility. how implement this? if at first post , can see developer 20 years ago used c preprocessor cut code cross-compatible parts, if did that, wouldn't know replace lstat() or fstat() (their windows counterparts). edit: added abreviated ...

c# - Is there a way to use one Timer for multiple events? -

i in c# .net 3.5 happens when timer elapses , event handler performed ? timer cease exist ? can register several events in different time on 1 timer, expecting them fire 1 after ? you can set timer fire off event once or continue (timer.autoreset property). yes, can register several different event handlers on single timer, don't know there way of knowing order fire. if matters you, set single handler, , have handler call others. if trying call different handler, each time timer goes off, suggest setting single handler keeps enum indicating function call , incrementing each time gets called timer. call same handler "iterate" through list of parameters, once on each interval elapsed, have array or list of parameters , handler increase counter or consume list. using system.timers; public class mytimeddelete { private static list<int> listofids=null; private static system.timers.timer mytimer=null; public static void addidtoqueue(int id) {...

r - read.table cut off a long row into half. how to reorganize the cvs file -

c <- read.table("sid-110-20130826t164704.csv", sep = ',', fill=true, ) so use above code read 300 csv files. , files this 65792,1,round-5,72797,140,yellow,75397,192,red,75497,194,crash 86267,1,round6,92767,130,yellow,94702,168,brake,95457,178,go,95807,185,red,96057,190,brake,97307,200,crash 108092,1,round-7,116157,130,yellow,117907,165,red 120108,1,round-8,130173,130,yellow,130772,142,brake,133173,152,red 137027,1,round-9,147097,130,yellow,148197,152,brake,148597,160,red as can see second longer other line (for each row third element supposed have round#) , when read.table r cuts line in half, below copied first 5 columns r 9 86267 1 round-6 92767 130 10 95807 185 red 96057 190 11 108092 1 round-7 116157 130 12 120108 1 round-8 130173 130 is there way edit row 1 line instead of being split? you can prime data.frame width sp...

Shifting binary bits left in Java -

i having bit of trouble shifting of string in java. have stringbuilder called finalbinary contains string of binary bits, "00110101" , trying shift left 5 times, so; input: 00110101 output: 10100110 i have been reading bitinversion on oracle website , of forums on here, having no luck :( appreciate help, thankyou guys! :) what describing rotating not shifting. not rotating bits manipulating string of char s happen represent binary. "abcdefg" => "efgabcd" far computer concerned. public static string rotatechars(string str, int count) { count % = str.length(); return str.substring(count) + string.substring(0, count); }

angularjs - ReferenceError: module is not defined (angular js unit testing with Jasmine) -

i found lot of questions this, answers didn't work me. i have small controller in angular js. works fine, , wanted start testing. i downloaded jasmine standalone here . put controller in "src" folder, , js file in "specs", following instructions provided here . edited specrunner.html including files. didn't work. after looking solutions "module not defined" error, included angular-mocs.js reference in html , in karma.conf.js file, making sure before tests. still doesn't work. anyone knows can wrong? ok, found problem. still had use npm install angular . stupid me...

What's the best way to create a confirmatin modal window in asp.net mvc? -

what best way create confirmation modal window in asp.net mvc 4? currently have: if (viewbag.deleteisvisible) { <button onclick= "if(confirm('are sure want delete?')) location.href='@url.action("delete", "home", new { id = model.id })'; else return false;" >delete</button> } but don't care old school looking javascript box. hoping have more control , make little more rich content having display box confirmation window c# has. there supported mvc framework this? haven't had luck finding something. as code mentioned above, did stuff using inline click event. in point of you can use jquery better control. <button id="btndelete">delete</button> <script> $('#btndelete').click(function(){ if(confirm('are sure want delete?')) location.href='@url.action("delete", "home", new { id = model.id })'; else return...

ios - Multiple UITableView in one ViewController -

why not triggered after else ? -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { if (tableview == self.tabfourcontacts) { static nsstring *cellidentifier = @"contactcell"; contactcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; if ([self.contactsarray[indexpath.row] hasprefix:@"tel_"]){ cell.labelcontact.text = [self.contactsarray[indexpath.row] stringbyreplacingoccurrencesofstring:@"tel_" withstring:@""]; cell.iconcontact.image = [uiimage imagenamed:@"ic_tab4_contacts_phone.png"]; } ... if ([self.contactsarray[indexpath.row] hasprefix:@"addr_"]){ cell.labelcontact.text = [self.contactsarray[indexpath.row] stringbyreplacingoccurrencesofstring:@"addr_" withstring:@""]; cell.iconcontact.image = [uiimage imagenamed:@"ic_tab4_contacts_addres...

reactjs - React.JS - Manage content of contenteditable div as React components -

Image
i'm looking methods of managing elements of contenteditable react components. exploring facebook's source via react devtools extension reveals wrote contenteditable comment editor seems managed react. you can see in components tree updating conteneditable triggers updates components tree children of contenteditable . facebook released draft.js - https://facebook.github.io/draft-js/

How to view Parent of branch git -

i created branch existing branch, in wisdom cannot remember branch name was. know find out name of branch branch created from? looking @ git docs have given answer quicker stack overflow, while you're here, try this: git log --graph --decorate it print commit history while showing branch topology got are. if want see history branches can add --all flag well.

java - HttpUrlConnection Forbidden access to Google Shortener URL -

i have implemented class short url long url: public class urlshortener { private final static string tag = "urlshortener"; private final static string address = "https://www.googleapis.com/urlshortener/v1/url?key=api_key"; static jsonobject jobj = null; static string json = ""; private string longurl; public urlshortener(string longurl) { this.longurl = longurl; } //public jsonobject getjsonfromurl(string address,string longurl) { public jsonobject getjsonfromurl() { url url; httpurlconnection urlconnection = null; // making http request try { //define connection url = new url(urlshortener.address); urlconnection = (httpurlconnection)url.openconnection(); urlconnection.setdooutput(true); urlconnection.setdoinput(true); urlconnection.setusecaches(false); urlconnection.setrequestproperty("content-type", "application/json"); urlconnection.se...

php - RegExp to find specific string with random characters in between -

i'm not hopeful possible. i'm looking string "base64_decode" in php files (yes clean site has been hacked). problem hacker has "hidden" string so: 'ba'.'se'.(32*2).'_d'.'eco'.'de' or 'b'.'as'.'e6'.'4_d'.'ec'.'ode'; and few other ways. therefore search string "decode" or "base" ignoring characters in between each letter. understand cpu intensive (especially when have few hundred mb of files go through (yes, hide code in other files gif image). is possible? i know sucuri online website, if have other suggestion of tools scan files , discover other hacks i'm interested. (?:b[^a-za-z]*?a[^a-za-z]*?s[^a-za-z]*?e)|(?:d[^a-za-z]*?e[^a-za-z]*?c[^a-za-z]*?o[^a-za-z]*?d[^a-za-z]*?e) you can try this.see demo. https://regex101.com/r/pg1ku1/17

cassandra - Bigdata analysis in nosql -

i'm trying migrate our postgres database containing millions of clicks (few years click history) more performing system. our current analytic queries, running on postgres taking forever complete , degrades performance of whole database. i've been investigating possible solutions , i've decided closely investigate 2 options: hbase hadoop (mapreduce) cassandra spark i working nosql before, never used analytical purposes. @ first bit disapointed how little analytical query options databases provide (missing groupby, count, ...). after reading many articles , presentations i've found out, need design schema according how intend read data , storage layer separated query layer. adds more redundant data, in world of nosql not issue. eventually i've found 1 nice grails plugin cassandra-orm , internally encapsulates orderby feature in cassandra counters counters . i'm still worried howto make design extendable. queries, come in future, have no clue today, ho...

java - Android studio expected class or package -

hello guys trying acces class works asynctasks, strangely annoying error maybe can me, error shows on serverrequest.storenaryste(); here code: ................................................................................ uzsisakyti.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { global.naryste = trukme +" "+ "rad" +" "+ kaina.gettext().tostring(); naris(); } }); private void naris() { serverrequests serverrequest = new serverrequests(this); serverrequest.storenaryste(); } serverrequest class : public class storenaryste extends asynctask<void, void, void> { @override protected void doinbackground(void... params) { arraylist<namevaluepair> datatosend = new arraylist<>(); datatosend.add(new basicnamevaluepair("pastas",global.elpastas )); ...