Posts

Showing posts from August, 2012

How to change the template path dynamically in Django 1.8 -

i want add mobile version site, need change template path dynamically mobile template dir or desktop dir. as template_dirs deprecated since version 1.8, tried change dirs option of djangotemplates backend, didn't work. as had same challenge post code here. using get_flavor django_mobile detect show , wanted use standard admin directories (as installed) django_admin_bootstrapped , regular django admin. in addition wanted interfere loader admin pages , not regular pages - in latter case loader nothing. so works me: import os.path django.template.loaders.base import loader django.template.loader import loaderorigin django.template import templatedoesnotexist django_mobile import get_flavour class myloader(loader): is_usable = true #this line necessary make work def load_template_source(self, template_name, template_dirs=none): path_split = template_name.split("/") if not u'admin' in path_split: raise

javascript - Align Table Header and Table Body from Two Different Tables -

Image
hi using table header , table body 2 different tables create scrollable table fixed header. can found jfiddle link. but cell width header , body varies how align columns together? want header , body column have same width. my table presented below. below header file codes <!doctype html> <html> <head> <title>title of document</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="layout.css"> <script src="jquery-1.11.3.min.js"></script> <script type='text/javascript' src='scroll.js'></script> </head> <body> <header> <a href="/datacentre/admin/index.php" title="return homepage" id="logo"> <img src="/datacentre/images/cagd_logo.jpg" alt

r - converting hours:minutes with unevern column lengths - zeros -

i trying convert data.frame amount of time in format hours:minutes. i found post useful , simple code approach of using posixlt field type. r: convert hours:minutes:seconds however each column represents month's worth of days. columns uneven. when try code below following several other posts, zeros in 1 column fewer row values. the code below. note when run, zeros feb has fewer data values in rows. rdf <- data.frame(jan=c("9:59","10:02","10:04"), feb=c("9:59","10:02",""), mar=c("9:59","10:02","10:04"),stringsasfactors = false) (i in 1:3) { res <- as.posixlt(paste(sys.date(), rdf[,i])) rdf[,i] <- res$hour + res$min/60 } thank suggestions fix issue. i'm open more efficient approach well. best, leah you try using package lubridate . here converting data row row hour-minute format (using hm ), extracting hours, , adding minutes

javascript - Insert YouTube player with JQuery HTML -

Image
i'm done mini-project have put lot of work into! thing need put youtube link player html , don't how start. so i'm doing take information api have youtube link ready example https://youtu.be/mh2ebpxhols , need shown in html youtube player. problem don't know how start it. this how site looks right now: as see there youtube trailer link @ bottom haven't got "level" yet , need it! basically trailer movie i'm searching , want under poster, somewhere there can myself. problem need know how make youtube player understand youtube link. right i'm using in html <div id="trailer"></div> js: $('#trailer').html("trailer: " + data.trailer); and have no css trailer yet. so want know, how can make link understand , fill html youtube player? from understand want id link , use fill html youtube iframe . can using replace . var videoid = data.trailer.replace("https://youtu.be/"

JavaScript JSON array undefined -

i trying read in tilemap in json format. here's tilemap: var obj = { "height": 20, "layers": [{ "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

ssl - Upgraded OpenSSL - How do I get Apache HTTPD to Use? -

i had need upgrade old server. server fulfills specific purpose , such has not been kept date. recent push ssl utilize sha256 needed upgrade few packages. short background the server rhel3 (yes, correct). i downloaded , built openssl 0.9.8q , ensured instance of openssl on server (moving old instance backup directory). downloaded , built curl 7.15.5 ./configure --with-ssl=/usr/local/ssl - pointing with-ssl new openssl directory. once curl built tested connection resource requiring sha256 using curl. connection test successful using curl. on problem , question i downloaded httpd 2.0.59 , built --enable-ssl , --enable-so , tests did not work. i tried d/l & build httpd 2.0.63 having trouble getting 2.0.63 working @ all. took mod_ssl built 2.0.63 , put 2.0.59 directory...no luck either. i feel missing element connects httpd newly installed openssl. need ensure mod_ssl using new version of openssl on server? i understand quite few releases behind htt

php - Obtain record from MySQL strip tags then update -

i have field (description) in mysql database (poi). wish use php , strip_tags remove html records in database. want update result same description field in database. i have no problem obtain string , stripping html, can't seem work out how update database result. // check connection if(mysqli_connect_errno()) { echo "connection failed: " . mysqli_connect_errno(); exit(); } $sql_article = "select description poi"; $result = $mysqli->query($sql_article); // iterates through mysql results while ($row = $result->fetch_array()) { $description_no_html = strip_tags($row['description']); printf("%s<br />\n", $description_no_html); } ideally each row have unique id column can use specify row update using prepared statement: $sql_article = "select id, description poi"; $result = $mysqli->query($sql_article); $stmt = $mysqli->prepare("update poi set description = ? id = ?"); // iterates

java real diference of time from greenwich to my latitude and longitude -

i want know real diference of time greenwich latitude , longitude. example: in la coruna, spain, , want know actual time difference between position , meridian of greenwich. in places i've looked indicates time difference +1 hour, need real difference of time, example 0 hours, 45 minutes , 25 seconds or, know distance in kilometers or meters. tell me can learn this? thank you.

java - How to extend / edit Netbeans' auto-generated REST services? -

i new automatic generation of rest services code database in netbeans 8. disclaimer: after discussion (in comments), realized should warn avoid question if not familiar automatic generation of rest service db in netbeans ( https://netbeans.org/kb/docs/websvc/rest.html ). that's because need know going on , put hands in order edit them. don't provide non-working code here, rather want know should in order edit such services. provide example of obtain. i did automatic code generation of rest services db , obtained entity classes , service " facade " classes. need extend / edit services , don't know put hands. for instance, consider following scenario. have student , he/she passed many exams. db perspective, student-exam 1 many relationship. when test rest api , perform id of student, resulting json not contain collection of exams associated student, expected. , how should change auto-generated service code in order obtain exams collection wi

How to create the Apache Cordova App with a cloud Backend like news and info App? -

i'm trying create cloud backend update news , info on app please me out documentation or guide me on topic. it depend on cloud end choose use. visual studio have integrated connected service experience azure mobile service grab free trial, right click on project, select "add > connected service..." , select azure mobile service add in.

python - Why do these base converters give different answers? -

Image
i have written python program convert numbers positive integer base another. print("base converter") math import log print("this converter uses 0-9, followed a-z, followed a-z, giving individual characters 0 - 61.") print("if there digits greater 61, each digit placed in pair of vertical lines, eg. 4|a|c|x|63|2|h|144|h.") def baseconvert(number, startbase, endbase): try: # make sure parameters in right format n = int(str(startbase)) + int(str(endbase)) except valueerror: return "bad base input" startbase, endbase = int(startbase), int(endbase) letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a','b','c','d',&

java - ServletRequest (how to get RequestMethod)? -

i have servletrequest, client machine sent. how know 1 is: get post update or delete ? if using spring mvc , comunication protocol http, don't need use servletrequest, can use directly httpservletrequest in method this: public modelandview index(httpservletresponse response, httpservletrequest request) but if need use servletrequest , sure comunication protocol http can cast servletrequest httlservletrequest , use getmethod() shriram said.

parsing - Smart design of a math parser? -

what smartest way design math parser? mean function takes math string (like: "2 + 3 / 2 + (2 * 5)") , returns calculated value? did write 1 in vb6 ages ago ended being way bloated , not portable (or smart matter...). general ideas, psuedo code or real code appreciated. a pretty approach involve 2 steps. first step involves converting expression infix postfix (e.g. via dijkstra's shunting yard ) notation. once that's done, it's pretty trivial write postfix evaluator .

java - ImageIO cannot resolve to a type -

just simple programming question. import java.awt.image.bufferedimage; import java.io.file; import java.io.ioexception; public class readthepic { public static void main(string[] args){ bufferedimage img = null; try { img = imageio.read(new file("strawberry.jpg")); } catch (ioexception e) { } } } error: imageio cannot resolved type. why?thanks import javax.imageio.imageio; imageio not accessible due restriction on requiered library you forgot import class. add import javax.imageio.imageio after other imports , should work.

angularjs - ui-select clearing input after selection -

is there allow typed input cleared after displayed option selected? currently, user has erase typed , type new in , want erased after select something. have. <ui-select multiple close-on-select="false" ng-model="vm.model.childusers"> <ui-select-match placeholder="select...">{{$item.fullname}}</ui-select-match> <ui-select-choices repeat="user.userprofileid user in vm.availableusers | filter: $select.search">{{user.fullname}}</ui-select-choices> </ui-select>

Using a usb digital scale in vb.net -

i developing fedex shipping application , trying scale read either dynamically or when user ships. need trying connect , data usb scale in vb.net. know how serialport have no idea usb. how go this? this serialport code tried getting port name read usb, kept saying "port name not contain com/com in it". private sub testscale() dim data string serialport1.close() serialport1.portname = "com1" serialport1.baudrate = 9600 serialport1.parity = io.ports.parity.odd serialport1.databits = 7 serialport1.stopbits = io.ports.stopbits.two serialport1.open() serialport1.write("w" & vbcr) data = serialport1.readexisting txtoutput.text = data serialport1.close() end sub i able achieve wanted using site: http://www.bumderland.com/dev/usbhidscale.html . using hidlibrary.dll , converting c# code vb.net.

Windows dev center Apps with same name -

i've 2 apps same name, 1 in phone , other 1 in desktop. now, created universal app. tab version have small number of users, need upload new universal package phone version app. but problem app name automatically reserved tab version, , package name also. i'm not able associate application phone build in store(because app name not reserved this, there no package name or package id in store) how can resolve issue without changing name of phone build? note: dev center not showing delete option particular name.

spring security webSecurity.ignoring() -

i using spring security via spring boot. have 2 kinds of rest services. public/** --> every 1 can access , use these services secure/** --> authenticated users can use. @slf4j @configuration @enablewebsecurity public class websecurityconfig extends websecurityconfigureradapter { @override public void configure(websecurity websecurity) throws exception { websecurity.ignoring().antmatchers("/public/**"); } @override protected void configure(httpsecurity http) throws exception { http.addfilterbefore(requestheaderauthenticationfilter(authenticationmanager()), basicauthenticationfilter.class) .authorizerequests().antmatchers("/secure/**").fullyauthenticated(); } @bean public requestheaderauthenticationfilter requestheaderauthenticationfilter( final authenticationmanager authenticationmanager) { requestheaderauthenticationfilter filter = new requestheaderauthenticationfilter(); filter.setauthentication

javascript - Cannot retrieve the HTML Dom object -

i using ie11 since companys standard browser. i working on solution catch paste event when pasting screen dump web application. far after have pasted image change size. preferable before don't jumping application. i have create jsfiddle can see entire test application: http://jsfiddle.net/e5f5glan/3/ do when running jsfiddle: make screen shot put marker in red square press ctrl + v now intention pasted image should become 100px x 100px in size. doesn't. the problem not getting hold of dom object can set style/size of image. the significant part @ end of javascript (i guess...): var image_container = document.getelementbyid('pastearea'); var image = image_container.getelementsbytagname("img"); image[0].setattribute("style", "width: 100px; height: 100px"); first of all, imagined img element become part of array , should access img-element using image[0]. error "not possible setattribute reference undefined or nu

css - Angular Material <span flex/> in IE10 doesn't take up space -

i have following: <div layout="row"> <span>left side</span> <span flex/> <span>right side</span> </div> where middle <span flex/> push "right side" right. works great on chrome, safari, firefox, ie11 not ie10. the flex attribute angular material looks have added -ms specifics not working ie10. any suggestions? the simple solution i've ended replace <span> <div> . instead of: <div layout="row"> <span>left side</span> <span flex/> <span>right side</span> </div> use: <div layout="row"> <div>left side</div> <div flex/> <div>right side</div> </div> that's working great on ie10.

javascript - Add Class To Body On Homepage -

i'm trying add class body tag on homepage , it. however, it's not working. doing wring? <script type="text/javascript"> $(document).ready(function() { if(window.location.href===window.location.hostname) { $("body").addclass("home"); } }); </script> window.location.href never same window.location.hostname since former contain protocol part (e.g.: http://) latter doesn't.

linux - issue with environment...login to sqlplus -

so trying figure out simple issue know related environment setting....as can see oracle database (mcq) , running , when login server set , can login database sqlplus.... issue comes in when switch bash mode typing bash(default csh, when things work)....when switch bash , unset , set oracle_sid, home, path sqlplus can see "connected idle instance." message, means not connecting database.... the reason why unsetting , wanting work because of script trying write. not want relay on things have been set, on servers have env set oracle , on dont...so if work work on both env... hostname:oramcq 51> ps -ef|grep pmon oramcq 3810 1 0 aug14 ? 00:08:29 ora_pmon_mcq oramcq 121914 121660 0 13:55 pts/0 00:00:00 grep pmon hostname:oramcq 52> hostname:oramcq 52> env | grep ora dbms_type=ora oracle_sid=mcq oracle_base=/oracle oracle_home=/oracle/mcq/112_64 hostname:oramcq 53> hostname:oramcq 53> env | grep path path=/oracle/mcq/112_64/bin:/usr/lib

mysql - Wordpress users keep disappearing -

i have strangest problem, never encountered before. users disappearing. somehow being deleted no record of them in database remains. every couple of days 1 or 2 users disappear. user accounts created through woocommerce. [woocommerce-my-account] have idea?

openerp - How to set up kitchen printer in Odoo? -

i installed odoo version 9 locally. haven't found way configure order printer used point of sale module. appreciated, thanks you can set kitchen printer using pos_restaurant module. after installing app list can see 1 menu in pos >> configuration >> order printes in menu can setup printer

java - console input not working for netbeans ide 7.4 with scanner class -

i have netbeans project test classes junit-4.1 , want read in numbers console using scanner class. system.out.println... works fine but, when input in netbeans console, code execution stops scanner reads in. waiting forever... here code private int controllerbytetowhitecell() { scanner scanner = new scanner(system.in); system.out.println("please choose 1 of following options 1,2,3,4,5,10,11,12,13,14,15"); string cmd = scanner.nextline(); system.out.println("cmd = " + cmd); return integer.parseint(cmd); } running test/file on test file calls upper code lines, output in netbeans ide 7.4 console t e s t s ------------------------------------------ running deltaanalytics.ftir.hardware.jueke.controller.juekecommandservicetest getbytesarraytowhitecell please choose 1 of following options 1,2,3,4,5,10,11,12,13,14,15 11 after entering number 11 + carriage return, execution of code stops, no otuput next system.out.println appears if run

ios - AFHTTPRequestOperation setCacheResponseBlock Cannot convert value of type -

i’m using afhttprequestoperation in swift : let operation : afhttprequestoperation? = manager.get(requesturl, parameters: nil, success: { (operation:afhttprequestoperation!, responseobject:anyobject!) -> void in ... ... ... success(downloadeditems: responseobject) }, failure: { (operation: afhttprequestoperation!, error: nserror!) in failure(responsefromcache: responsefromcache, error: error); }) and i’m using setcacheresponseblock application specific purpose (etag etc.) operation!.setcacheresponseblock { (connection: nsurlconnection, cachedresponse: nscachedurlresponse) -> nscachedurlresponse in print("returns:200") responsefromcache = false return cachedresponse } everything ok until updating xcode new version xcode7.1. here problem, error when build application after update : cannot convert value of type '(nsurlconnection, nscachedurlresp

python - How to choose a random input from 7 given input? -

i'm creating lottery hack machine gets winning numbers of last 7 days , tries select winner the 7 , shuffle numbers of selection , print result. occurs @ random. #lottery hack print "welcome lottery hack machine!!!\n" today = int(raw_input( "please enter today's date: " )) if today<=31: print "please enter 4-digit prize winning lottery number last 7 days" y = raw_input( "enter 7 numbers separated commas: " ) input_list = y.split(',') numbers = [float(x.strip()) x in input_list] elif today>31: print "a month has 31 days ;p" you can use random.choice function this. returns random element sequence pass it. import random print "welcome lottery hack machine!!!\n" today = int(raw_input( "please enter today's date: " )) if today<=31: print "please enter 4-digit prize winning lottery number last 7 days" y = raw_input( "enter 7 numbers

android - AlertDialog youtube? -

Image
i want know if possible inflate youtube in alert dialog, but error in view view : android.view.inflateexception exception. inflate : dialogview = layoutinflater.from(context).inflate(r.layout.alert_label_editor_notif, null,false); xml <com.google.android.youtube.player.youtubeplayerview android:id="@+id/youtube_view" android:layout_width="match_parent" android:layout_height="fill_parent"/> don't create view that.the ways use youtube stan alone player api i have made tutorial @ this git hub link sample .

javascript - How to Group By Json Array -

i have array , want apply group column (key). have this. app.groupdtdata = function(data, column) { var generateddata=[]; $.each(data,function(i,dt){ // generateddata // if(jquery.inarray( "john", generateddata )) }); } i have push generateddata , check jquery.inarray ? you wouldn't use inarray need object hold result, not array. use in operator property in object. you column value item , check if exist in result. if doesn't exist, add new array name. add item array , lastly return result: app.groupdtdata = function(data, column) { var generateddata = {}; $.each(data, function(i, dt) { var key = dt[column]; if (!(key in generateddata)) { generateddata[key] = []; } generateddata[key].push(dt); }); return generateddata; }; demo: function group(data, column) { var generateddata = {}; $.each(data, function(i, dt) { var key = dt[column]; if (!(key in generateddata)) { gene

meteor - How to only subscribe to database updates (without fetching)? -

i have large database , want send actual data updates client. not want each client fetch whole set of data done natively meteor's pub/subs. tried ground:db still fetched data. how can achieve this? to achieve can observechanges on whole collection , channel changes ( added , changed , removed ) each publication handler . a rough application : var pubhandlers = [] meteor.publish('changes stream', function handlepublication() { pubhandlers.push(this) this.onstop(() => pubhandlers.splice(pubhandlers.indexof(this), 1) ) this.ready() }) mycollection.find().observechanges({ added : function docadded(id, doc) { for(let pubhandler of pubhandlers) { pubhandler.added('my collection', id, doc) } }, changed : function docchanged(id, fields) { for(let pubhandler of pubhandlers) { pubhandler.changed('my collection', id, fields) } }, removed : function docremoved(id) { for(let pubhandler of p

ios - The use of private keyword in Swift and their use in protocols? -

i'm building ios app want make protocol (which understanding equivalent of java interfaces) model, use unit testing purposes. in java typically want encapsulate values in model , make them accessible through getters , setters only. how can ensure encapsulation in swift protocols, can't use private keyword properties. my model setup this: class model { private var property: int = 5 func getproperty() -> int { return property } func setproperty(newvalue: int) { self.property = newvalue } } and want protocol this: protocol modelprotocol { private var property: int { set } } my problem can't declare properties private, thing in swifts access control (i've read have private, internal , public) don't use private properties or there equivalent java's way of handling interfaces , private variables? (note: i'm using xcode 7 , swift 2.0 if matters) i don't think can have private propertie

linux - Requires substitute arguments to perform a pearl script using bash -

requires substitute arguments perform perl script using bash. have script runs on gem this: ./script.pl "url" i needed substitute "url" substitute value of file using bash.thank you. ./script.pl "$( cat file )" or ./script.pl "$(< file )" or <file xargs ./script.pl or xargs -a file ./script.pl

ios - Gradient Mask is applied multiple times in reused prototype cell -

i have tableview, customer uitableviewcell class - created prototype cell in storyboard/builder. because cell linked storyboard prototype, reference follows (cellidentifier matches id on prototype cell): eventslisttableviewcell *cell = (eventslisttableviewcell *)[tableview dequeuereusablecellwithidentifier:cellidentifier]; as such, cell initialised , ready (i can't use "if (cell == nil{...} ") this fine, want add gradient layer cell, i'm doing within cellforrowatindex: gradientmask = [cagradientlayer layer]; gradientmask.frame = cell.eventimage.layer.bounds; gradientmask.startpoint = cgpointmake(0.5, 0.2); gradientmask.endpoint = cgpointmake(0.5, 1.0); gradientmask.colors = [nsarray arraywithobjects: (id)[[uicolor colorwithred:0.0f green:0.0f blue:1.0f alpha:0.0f] cgcolor], (id)[[uicolor colorwithred:0.0f green:0.0f blue:1.0f alpha:1.0f] cgcolor],nil]; [cell.eventimage.layer insertsublayer:gradientmask atin

html - Switch Number Input Spinners -

is there way flip functionality of number input spinners? example, pushing arrow on number input spinner increase field value , pushing down arrow decreases value. can switch them, pushing arrow decrease field value? (i making priority list curious, intuitive push arrow increase priority, lower value). <input type="number" /> thanks in advance!

javascript - Skipping levels of context binding -

i doing knockout.js tutorial (tutorial: single page applications, step 2) , have problems understand 1 thing. maybe code first: view: <!-- folders --> <ul class="folders" data-bind="foreach: folders"> <li data-bind="text: $data, css: { selected: $data == $root.chosenfolderid() }, click: $root.gotofolder"></li> </ul> <!-- mails grid --> <table class="mails" data-bind="with: chosenfolderdata"> <thead><tr><th>from</th><th>to</th><th>subject</th><th>date</th></tr></thead> <tbody data-bind="foreach: mails"> <tr> <td data-bind="text: from"></td> <td data-bind="text: to"></td> <td data-bind="text: subject"></td> <td data-bind=&

linux - run the script every 30 minutes bash -

i want run script every 30 minutes cron have problem code. in every 30 min have kill old script , run again. have somethink this, not working: cd /var/www/scripts pkill -f bot now="$(date +%y%m%d%h%m%s)" screen -s bot node mybot.js >> logi/logi_$now.txt you may not use screen running things in background in script. use ampersand ( & ) background process , nohup won't killed when cron script exits. remember subprocess pid in file. something this: kill -- "$(cat mybot.pid)" now="$(date +%y%m%d%h%m%s)" nohup node mybot.js >> "logi/logi_$now.txt" & echo $! > mybot.pid

ios - check if UICollectionView is on top (not-scrolled) or not -

i make animation scroll top of uicollectionview, if not on top already. is there way tell if uicollectionview scrolled top or not? thank you. if collectionview.contentoffset == cgpointzero can say, not scrolled @ all.

java - How to clear user data in android programmatically? -

hello new in android , followed tutorial explain how clear app data in android, when ever trying clear data getting error of null object reference. main.java public class mainactivity extends actionbaractivity { button b; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); b = (button)findviewbyid(r.id.start); adddatainappdir(); b.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { cleardataapplication.getinstance().clearapplicationdata(getbasecontext()); } }); } private void adddatainappdir() { sharedpreferences settings = getsharedpreferences("sample", 0); sharedpreferences.editor editor = settings.edit(); editor.putboolean(&quo

maven - Eclipse: The type org.hamcrest.core.CombinableMatcher$CombinableBothMatcher cannot be resolved. It is indirectly referenced from required .class files -

i working on unit testing spring mvc controller using testng , mockito . i've included hamcrest library in maven dependencies shown below. missing here? error shows when use following 2 methods: org.hamcrest.matchers.hassize; org.hamcrest.matchers.is; the following dependencies: <dependency> <groupid>org.testng</groupid> <artifactid>testng</artifactid> <version>6.9.4</version> <scope>test</scope> </dependency> <dependency> <groupid>org.mockito</groupid> <artifactid>mockito-core</artifactid> <version>1.10.8</version> <scope>test</scope> </dependency> <dependency> <groupid>org.hamcrest</groupid> <artifactid>hamcrest-library</artifactid> <version>1.3</version> <scope>test</scope> </dependency> update 1: the problem has been resolved changing ha

Jquery validation two inputs one is required listener -

Image
im looking validate 2 input fields. 1 required. code have works, trying validate after 1 of fields filled in. if i tab on field error goes away. rather error go away after user fills in info on said field. code: $('#talent_form').validate({ ignore:"", onfocusout: false, rules: { "talent_category": "required", "talent_description": "required", "city": "required", "first-name": "required", "last-name": "required", "email": { required: true, validemail: true }, "uploadedfile": { required: function(element) { return $("#text-link").val() == 0; } }, "text-link": { required: function(element) { return $("#uploadedfile").val() == 0; } } }, submitha

git - Using yiic to update application via github -

we have application written in yii 1.1, maintain , control aspects of application , servers. lives on variety of servers. maintain code base locally through git , publish our github repo. when roll out updates or bug fixes have go each box , update them 1 @ time. grows more , more time consuming more applications , servers deploy. we hoping streamline git pull process doing via admin section, remotely. thought tapping github webhooks feature don't want automatic. want control applications updates. next, thought using yiic command live in code base , can run shell git pull scripts. security of top priority in whole thing. do forsee security issues if create yiic class handle defined git commands layer of security tokens authenticate controller yiic commands? maybe has done similar , can shed insight approach , problems? i created admin screen let every user switch branch in there personal development environment (without access server). did using exec in php ,

aurelia - binding values to radio buttons -

i'm trying bind radio buttons 'checked' status boolean values in json object, it's not being set. template: ( jobreadinessitems array of "items") <tbody> <tr repeat.for="item of jobreadinessitems"> <td><input id="have" name="readiness" type="radio" checked.bind="item.have" /></td> <td><input id="need" name="readiness" type="radio" checked.bind="item.need" /></td> </tr> item (json): { have: false, need: true } cs public class jobreadinessitemdto { public bool have { get; set; } public bool need { get; set; } } however, if bind way shows values (but of course can't set it): checked.bind="item.have ? 'on' : 'off'" why display "on/off" not true/false? http://plnkr.co/edit/g5cw9i?p=preview have @ cheat-sheet in

scala regex filter wrapped elements -

i have input in form of strings following ellipse { attribute = foo ellipse { attribute = foo line { attribute = foo attribute = foo attribute = foo } line { attribute = foo attribute = foo } } } basically 2d-elements, able hold other 2d-elements inside them. task write regex, can seperate parent-elements children, can parsed seperately. in case of: rectangle1{ attribute = foo } ellipse1{ attribute = foo ellipse{ rectangle{ attribute = foo } } } i want able regex.findallin(string) , have rectangle1 , ellipse1 strings, can parse them. im no expert regexes made attempt, fails of course: i tried to: (?s)(?!((ellipse|point|line) \\{)).+ (ellipse|point|line) \\{.*\\} get ellipses or points or lines, which (?s)(?!((ellipse|point|line) \\{)).+(ellipse|point|line) \\{.*\\} include something, but (?s) (

php - FOSRestBundle parent/child resource error: Every parent controller must have `get{SINGULAR}Action($id)` method -

in this gist , have 3 controllers defined. want establish parent/child relationship between cah_annotation , standard_proposal resource. cannot find reason error: $ ./app/console debug:router [symfony\component\config\exception\fileloaderloadexception] every parent controller must have `get{singular}action($id)` method {singular} singular form of associated object in /var/www/html/cdpaccess/src/icc/proposalbundle/res ources/config/routing.yml (which being imported "/var/www/html/cdpaccess/app/config/routing.yml"). [invalidargumentexception] every parent controller must have `get{singular}action($id)` method {singular} singular form of associated object the weird thing is, if modify routing.yml , set parent resource on cah_annotation proposal: cah_annotation: parent: proposal it works fine. if delete proposal resource

php - MySQL get data older than 30 minutes and perform some tasks -

i trying make coupon system, got stuck something. want make function gets data coupon_session time (datetime) older 30 minutes. each of results, want fetch "code" row, , after want delete row. i've figured out how retrieve data, rest kinda hard me. guys bit? this code fetching > 30 min old rows: mysql_query("get * `coupon_session` timestampdiff(minute,time,now()) > 30"); the code fetch want is: select cs.code coupon_session cs time < date_sub(now(), interval 30 minute); deleting problem, because value of now() changes. have several choices, such as: get list of ids delete in application , delete (probably safest method). calculate "now" in application , use same value select , delete (also safe). calculate maximum time returned select , use subsequent delete.