Posts

Showing posts from May, 2015

R: Sorting data.frame by a column and conditionally deleting of rows -

i've got data.frame in r sample data looks this: dat <- data.frame(name=c("name1","name1","name1","name1","name2","name2","name2","name2") , survey_year =c(1947,1958,1978,1987,1963,1991,2004,1993), reference_year=c(1934,1947,1974,1947,1944,1987,1993,1987), value=c(10,15,13,20,-2,7,12,-19)) dat name survey_year reference_year value 1 name1 1947 1934 10 2 name1 1958 1947 15 3 name1 1978 1974 13 4 name1 1987 1947 20 5 name2 1963 1944 -2 6 name2 1991 1987 7 7 name2 2004 1993 12 8 name2 1993 1987 -19 how sort first reference_year (from lowest highest): name survey_year reference_year value 1 name1 1947 1934 10 2 name1 1958 1947 15 3 name1 1987

Is "GMT" an Abbreviation in Java TimeZone and if So is it OK to use it? -

according javadoc timezone... id - id timezone, either abbreviation such "pst", full name such "america/los_angeles", or custom id such "gmt-8:00". note support of abbreviations jdk 1.1.x compatibility , full names should used. the important point being... an abbreviation such "pst" , note support of abbreviations jdk 1.1.x compatibility , full names should used. does mean "gmt-0:00" ok "gmt" should avoided or "gmt" not considered abbreviation? similar other question trying make more specific. just looked @ source code. if read correctly, gettimezone(string id) calls private method called parsecustomtimezone, checks if id starts gmt , returns null otherwise in case gettimezone falls default timezone gmt+ 0. things utc, pst, etc. supported in zoneinfo, sun internal class. can list available timezones javadoc mentions. here's bits of code relevant in timezone: public static sync

json - Usage of StreamReader in C# -

i want read file data.json , convert string. my code one: string json = null; using (streamreader sr = new streamreader("data.json")) { json = sr.readtoend(); } but visual studio tells me streamreader not expect string constructor argument. how can tell streamreader want read file data.json? actually streamreader supports constructor accepts file path platforms, not all. anyway - use file.readalltext : string json = file.readalltext("data.json"); it creates streamreader internally ( link source ): using (var sr = new streamreader(path, encoding)) return sr.readtoend(); update: can pass stream streamreader . use filestream open stream reading file, , pass streamreader : string json = null; using (var stream = new filestream("data.json", filemode.open)) using (var reader = new streamreader(stream)) json = reader.readtoend();

javascript - Iframe content loading before css with Firefox -

i've problem iframe, load content dynamically , compile html javascript. works fine browsers, firefox have small lag between html loading , css loading. display iframe content @ first (raw html), , few seconds later css displaying. is firefox issue, or specific operation of browser ? , want know if there solutions resolve ? i've found during researches, , think same problem : http://www.phpied.com/when-is-a-stylesheet-really-loaded/ , : https://support.mozilla.org/fr/questions/970521 could solution if use fade after document ready. if have browser detection can add class body .ff firefox. #main-content { display: none; } $(document).ready(function() { $('#main-content').fadein(); }); or use browser detection jquery http://api.jquery.com/jquery.browser/ if ( $.browser.webkit ) { alert( "this webkit!" ); }

c# - Graphics not cleared XNA (Monogame) after switching screen -

we optimizing our first xna game, ran in problem: there screenmanager manages screens. every time 'push' new screen remove (null) old screen, graphics should removed memory. seems not working, old graphics remain in background. using code remove previous screen: private screen removescreen() { screen screen = (screen)gamescreens.peek(); onscreenchange -= screen.screenchange; game.components.remove(screen); screen.contentmanager.unload (); return gamescreens.pop(); } we have done research, , came across possible solution give every screen own contentmanager. when switch screens , nullify our old screen run contentmanager.unload() before nullify it. unfortunately not working (old graphics remain being drawn, weird flickering graphics). clarify problem made small youtube video, can see home screen, when go setting screen can see old homescreen while should removed: http://youtu.be/ii0qd6pusa8 i hope can us. are clear

Makefile variable autocompletion in bash -

let's makefile like: dir :=# foobar: ls ${dir} when type mak[tab] f[tab] it gives correctly make foobar but make foobar d[tab] doesn't magic make foobar dir= so question is: there way autocomplete makefile variables (aside targets) in bash? this answer far complete. grep variables in makefile use make -p print makefile database : # gnu make 3.81 # copyright (c) 2006 free software foundation, inc. # free software; see source copying conditions. # there no warranty; not merchantability or fitness # particular purpose. # program built x86_64-pc-linux-gnu # make data base, printed on mon oct 13 13:36:12 2014 # variables # automatic <d = $(patsubst %/,%,$(dir $<)) # automatic ?f = $(notdir $?) # environment desktop_session = kde-plasma # ... # makefile (from `makefile', line 1) dir := we looking lines starting # makefile (from 'makefile', line xy) , extract name of following variable: $ make -p | sed -n '/# m

sql - Qt Mobile MySQL development pattern -

i want create mobile application using qt project. application must data online remote mysql database. right follow these steps? download qt windows wp8, qt linux android , qt mac ios. compile mysql plugin on these 3 platforms. (as example compile on ubuntu android). code rest of app , compile targeted platform. finally, targeted platform requires mysql driver, how can force user have mysql driver on end user platform (android, ios, wp8)? if there solution problem, i'd hear them too. web service...etc.

java - When using field grouping in storm, is there a limit to known field values or a timeout? -

i use field grouping apache storm, works well. but if have infinite number of field values, means storm has keep track of infinite number of values in bolts! otherwise, values go wrong bolt , destroy caching technique. i suppose there cache somewhere in bolt expiration system or/and limitation on number of field values check bolt field grouping. possible tune / overwrite it? you don't need cache nothing, fieldsgrouping uses mod hash function determine task send tuple, can sure processed in correct task.

modulo - How to use a very long integer to compute a value in C++? -

i need compute (n*(2n+1)*(n+1)*(3(n^2)+3n+1))/30 modulo m where: - 30 & m can non co-prime - n can have values 10^10 (too big long long int ) - m can have value 10000 i have tried this: long long int tp1; double k; k=n; k=k*((2*n)+1); k=k*(n+1); k=k*((3*n*n)+(3*n)-1); tp1=fmod(k/30,m); as noted molbdnilo , can calculations modulo number. to expand idea: (x * y) mod m same ((x mod m) * (y mod m)) mod m (x + y) mod m same ((x mod m) + (y mod m)) mod m however (x / y) mod m not same ((x mod m) / (y mod m)) mod m therefore, have calculate n*(2n+1)*(n+1)*(3(n^2)+3n+1) mod (30 * m) , , divide 30. p.s. assumed division operation means same in c++, "divide rounding down".

osgi - gogoshell own commands piping -

i'm trying use gogo-shell add console commands example i'm create commands add , show public void add(commandsession commandsession, int i) { list<integer> il = commandsession.get("list"); if (il == null) { il = new arraylist<integer>(); il.add(i); commandsession.put("list",il) } else { il.add(i) } } public void show(commandsession commandsession) { list<integer> il = commandsession.get("list"); il.foreach(system.out::println); } and when use them like add 1 | add 2 | add 3 | add 4 | show i'm geting like null pointer exception or 1 3 4 2 i think happens because pipes (add) runs in parallel. how can write command piping sequential. pipelines in gogo (like in bash) expect consume data standard input , produce data on standard output. each element in pipeline runs concurrently, separate thread. the 'add' command in example not consume

java - Timeout http request? Android -

i have below code, goes url , pulls xml page; returning calling page; bound listview. the problem have connection refused, or connection takes while establish. app isn't bringing data 40+ seconds sometimes, waiting successful connection made. my question is, given below code, how time out httpconnection if has been trying more 3 seconds? this way, if cannot make successful connection, move onto next url; opposed staying on current 1 time. any advice helpful! thanks! code: package com.example.directrssread; import java.io.ioexception; import java.io.stringreader; import java.io.unsupportedencodingexception; import javax.xml.parsers.documentbuilder; import javax.xml.parsers.documentbuilderfactory; import javax.xml.parsers.parserconfigurationexception; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.methods.httpget; import org.apache.http.impl.client.defaul

sql server - How to get total value from Calculate Member MDX -

Image
i wanted store total weekly variance(1.238.232,00) . because there different value on mtd , wtd. my calculated member is "[variance(by plan qty) absolute ]" = abs(plant qty - actual qty) "[weekly variance (by plan qty) absolute ]" = sum(wtd([date].[calender].currentmember),[measure].[variance(by plan qty) absolute]) the value wanted 1.238.232,00 (like picture below) if change value mtd value became 40.500,00. can store total "weekly variance (byplan qty) absolute " based plant,material ,and month year picture below?

sublimetext3 - using font "Consolas" under ubuntu in Sublime_text3 -

i'm used programing in sublime_text in windows platform, using consolas font. recently, change system ubuntu, copy "consolas file "c:\windows\fonts\" linux "/etc/fonts", , set sublime_text font's setting, works, looks different before. no italic please tell me how handle it, sublime_text default font acceptable, any thx lot there separate .ttf files consolas regular, bold, bold italic, , italic on windows. use them on ubuntu, you'll need copy 4 files /etc/fonts .

php - How to calculate the number of days between two dates starting from B.C.5000? -

would have function before christ date , taking account gregorian , julian calendar. have found solutions a.d. dates have not found 1 b.c. , solution requires lot of manual calculation. there elegant way in php have missed? existing built in function mean. http://www.timeanddate.com/date/duration.html i rewrote original calendar.php function , add in own solution. thanks.

meteor - How do you use the mrt:natural package in an app? -

i have installed http://atmospherejs.com/mrt/natural 'meteor add mrt:natural' (i using meteor 0.9.1). seems installed ok, 'usage' says call : natural = natural this doesn't work when applied on server or client side. i'm sure must obvious can't see else having problem... yes, pretty new meteor. this package doesn't seem maintained ( last update 6 jun 2013 ). there's no need be, since it's simple wrapper npm package, can loaded in better way. add npm package app with meteor add meteorhacks:npm and create packages.json file natural specified per documentation . you'll able require natural meteor.npmrequire('natural'); .

jax ws - IBM Websphere application server 7 JAX-WS client WSSE UsernameToken -

i'm consuming web service using jax-ws on ibm websphere application server 7. setting ws message level security while passing soap message. usernametoken xmlns:wsu not passed correctly provider end. there configuration need on websphere server? soap message printed in app log, wsse:usernametoken wsu:id="xxxx" xmlns:wsu ="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" web service provider received soap message, wsse:usernametoken wsu:id="xxxx" xmlns:wsse ="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" don't know how soap message ws security header overridden. i found issue , resolved. namespace of wsse & wsu should apply correctly. wsse = " http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd " wsu = " http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd "

c# - WP8 Get current App Version -

i'm trying app current version value via code. on msdn shown use property id of class windows.applicationmodel.package: http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.package.id.aspx unfortunately seems property "id" not implemented in wp (it throws "not implemented exception") is api supported on wp8 or maybe wp8.1? works "store apps" (released)? have used already? i know can parse wmappmanifest.xml value, need accomplish external assembly (a custom .dll), not app assembly. thanks f you'll able version this: string version = xdocument.load("wmappmanifest.xml") .root.element("app").attribute("version").value; a better reference this: getting application version windows phone 8

c - strange Behavior of sdcc compiler for 8051 -

i used keil programming 8051 microcontrollers. reason have code in sdcc, today facing strange behavior in compiler. using code blocks ide 12.11 , sdcc 3.4 version. i compiling simple piece of code. #include <mcs51/8051.h> #include "serial.h" unsigned char digits[5]={0}; void main(void) { serial_init(-13); digits[2]='a'; serial_send(digits[2]); serial_send('a'); while(1) { } } and here defination of serial_send function. void serial_send(unsigned char dat){ while(!ti); ti = 0; sbuf = dat; } the problem that, according code should print 'a' character 2 times on terminal printing 1 time. problem in global veriable digits[] array. the function work constant value not variable bassed argument. i posting question here because think problem c language trick, unable figure out. i tried re-installing compiler , ide both problem remains same. body please explain why happening. have tried

reporting services - #Error in rdlc report -

i have stored procedure return dataset rdlc. particular field i'm looking when executed in sql not return null or empty values. when report rendered, value returned #error. my expression =iif(isnothing(fields!minscorevalue.value),0,fields!minscorevalue.value) minscorevalue function returned value. datatype of return value of function int. datatype in data table(xsd) corresponding field system.int32 i made mistake of using 1 data set report , changing data set minscorevalue field later never updated code behind use new stored procedure.

codenameone - How to handle downloads in web component in codename one -

i wrote sample servlet can serve giving option download pdf file. want download pdf file in cn1 app through webbrowser component. later want view pdf in browser itself. if possible can share sample example. use util.downloadtofilesystem api giving path generate app home filesystemstorage class. once download complete can use display.execute path.

visual studio 2013 - Why does TFS build is not running tests as if it don't exist? -

i have added tfs build our project, , configured run automated tests in project, , reason build ignoring tests if don't exist! in order figure out created solution basic project origin code , test project well. i've added these tfs , configured equal build solution, , guess what? executed tests! it's same tests original. copy of it. the main difference between these 2 solutions original code big solution many projects, of projects in kind of solution directory (and tests project - it's inside solution directory well). the difference between tfs build definition is output location of build set single directory (i tried perproject , worked) , in original code it's defined "asconfigured" because have build tasks copying dlls , such. has encountered problem? ideas? thanks tfs test dlls in binaries output folder location. need configure 'build tasks copying dlls' ensure test dlls copied location. test assembly file specific

javascript - Lo-Dash - help me understand why _.pick doesn't work the way I expect -

this works: mycollection.prototype.select = function (properties) { var self = this; return { where: function (conditions) { return _.chain(self.arrayofobjects) .where(conditions) .map(function (result) { return _.pick(result, properties); }) .value(); } }; }; it allows me query collection so: var people = collection .select(['id', 'firstname']) .where({lastname: 'mars', city: 'chicago'}); i expected able write code this, though: mycollection.prototype.select = function (properties) { var self = this; return { where: function (conditions) { return _.chain(self.arrayofobjects) .where(conditions) .pick(properties); .value(); } }; }; lo-dash documentation specifies _.pick callback "[callback] (function|…string|string[]): function called per iteration or proper

matplotlib - python gridspec, trouble sharing x and y axis -

i'm doing multi panel plot using gridspec, i'm having few issues. want each row share different y axis , each column share different x axis. or, in other words, share x per row , share y per column. want add label each of these axis. here example of i'm talking along code made (minus axis labels want): sample axis sharing http://matplotlib.org/_images/subplots_demo_04.png # row , column sharing f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex='col', sharey='row') ax1.plot(x, y) ax1.set_title('sharing x per column, y per row') ax2.scatter(x, y) ax3.scatter(x, 2 * y ** 2 - 1, color='r') ax4.plot(x, 2 * y ** 2 - 1, color='r') however can't use implementation because using subplot2grid need choose specific positions , dimensions of each plot. i've tried using sharex=ax1 , sharey = ax1 in subplot2grid call no avail. here relevant portion of code: ax1 = plt.subplot2grid((8,8), (2,0), colspan=2, rowspan=2) ax2 =

node.js - Is there a way to know that nodeunit has finished all tests? -

i need run code after nodeunit passed tests. i'm testing firebase wrappers , firebase reference blocks exiting nodeunit after test run. i looking hook or callback run after unit tests passed. can terminate firebase process in order nodeunit able exit. didn't found right way it. there temporary solution: //put *last* test clear if needed: exports.last_test = function(test){ //do_clear_all_things_if_needed(); settimeout(process.exit, 500); // exit in 500 milli-seconds test.done(); } in case, used make sure db connection or network connect killed way. reason works because nodeunit run tests in series. it's not best, not way, let test exit . for nodeunit 0.9.0

Android: OTG Storage notification conflicts with radio c -

i working on ongoing service listens usb interface connection radio. when such connection found, service updates notification reflect said connectivity; when connection lost (such through unplug event, or radio being turned off), service update notification reflect said dis-connectivity. service writes database when detects change, other applications can utilize information. this service works on usb ports aren't configured otg storage. however, when usb port otg storage enabled used, run issues service notification doesn't update properly, though database being correctly written to. believe because radio connecting functions otg storage device, , once connection said radio made, otg storage notification occurs, , may losing notification context. further, if disconnect radio before otg storage able mount, service notification , database correctly update. for example, if connected radio , otg storage has mounted, if disconnect said radio, otg storage unmount service noti

asp.net mvc - on jquery submit data is being passed only once -

Image
function loadeditdialog(tag,event) { event.preventdefault(); var $loading = $('<img src="../../images/ajaxloading.gif" alt="loading" class="ui-loading-icon">'); var $url = $(tag).attr('href'); // var $url = $('<div> <input type="text" /></div>'); var $title = $(tag).attr('title'); var $dialog = $('<div></div>'); // var $dialog = $('#diag'); $dialog.empty(); $dialog .append($loading) .load($url) .dialog({ autoopen: false , title: "edit" , width: "310px" , modal: true , minheight: 50 , show: 'fade' , hide: 'fade' , buttons: { "cancel": funct

Variable in Erlang -

i have simple erlang program: -module(test). -export([start/0]). code = "z00887". start() -> io:fwrite(code). and have follows 2 errors: c:/erl6.1/dev/test.erl:4: syntax error before: code c:/erl6.1/dev/test.erl:5: variable 'code' unbound could please me correctly using variables in code. you defining variable global module, not allowed. remember, "variables" in erlang "symbols", there no concept of "global" constant across functions or processes. closest thing in erlang macro defined in module, if value needed in 1 place , want name must done within function definition. also, not use io:fwrite/1 or io:format/1. problem possible inclusion of escape characters in string passing. example, causes error: code = "wee~!", io:format(code). , not caught compiler. the common thing define variable within function: -module(foo). -export([start/0]). start() -> code = "z00887", io

jquery function does not work after creating an element -

this question has answer here: event binding on dynamically created elements? 18 answers i want add function after create input element. didn't work. code. <p id="pp"> <input type="button" onclick="add();" value="add template"/><br> photo: <input type="file" id="choosefiles" name="photo[]" class="inputfile"><br> </p> <script type="text/javascript"> function add(){ var text = document.createtextnode("photo: "); var input = document.createelement("input"); input.type="file"; input.name="photo[]"; input.class="inputfile"; }; $(".inputfile").change(function (e) { (var = 0; < e.originalevent.srcel

ruby on rails - POW is showing previous gemset path -

so having issues pow loading rails application. when try visit http://app.dev url following error: bundler::gemnotfound: not find minitest-5.4.1 in of sources /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.7.2/lib/bundler/spec_set.rb:92:in `block in materialize' i updated ruby 2.1.2 , created new gemset app, , set rvm use gemset in application folder. however, pow still trying use default 2.0.0@global gemset? according pow/rvm documentations, have tried placing .powrc file in application root, still cannot pow use proper gemset. i can access app file in rails console, no errors. think strictly pow having issue thanks i ended restarting pow server, , resolved issue touch ~/.pow/restart.txt

c# - LINQ generic function for find in a enumerable -

i need create method generic enumerable of type t finds inside using in term specify public static object findinlist<t>(t[] list, string searchterm, string seachindex) { string normalized1 = regex.replace(seachindex, @"\s", ""); var sel = (from l in list normalized1.equals([the item want compare]) select l).firstordefault(); return sel ; } i need because want create generic method search item in array can customize in way (below code in original way) [...] string normalized1 = regex.replace(seachindex, @"\s", ""); sel = (from l in list normalized1.equals(l.ordine) select l).firstordefault(); [...] [edit] servy answer. full index of answer add here how call method func<xxx, string> keyselector = delegate(xxx b) { return b.xx; }; var return = findinlist<xxx>(list, keyselector, seachindex); where xxx type of list , xx property want compare search

c# - Is there a way to ignore get-only properties in Json.NET without using JsonIgnore attributes? -

is there way ignore get-only properties using json.net serializer without using jsonignore attributes? for example, have class these properties: public keys hotkey { get; set; } public keys keycode { { return hotkey & keys.keycode; } } public keys modifierskeys { { return hotkey & keys.modifiers; } } public bool control { { return (hotkey & keys.control) == keys.control; } } public bool shift { { return (hotkey & keys.shift) == keys.shift; } } public bool alt { { return (hotkey & keys.alt) == keys.alt; } } public modifiers modifiersenum { { modifiers modifiers = modifiers.none; if (alt) modifiers |= modifiers.alt; if (control) modifiers |= modifiers.c

How to control concurrency in SQL Server SELECT queries? -

how control concurrency in sql server select queries? here problem, these sql queries below going execute @ same time should not take same record. how handle this? session 1: begin tran declare @id int select top 1 @id = id dbo.table_1 update dbo.table_1 set is_taken = 1 id = @id commit tran session 2: begin tran declare @id int select top 1 @id = id dbo.table_1 update dbo.table_1 set is_taken = 1 id = @id commit tran as mentioned in comments, sql server takes care of isolation, hence can run update without select: update top (1) dbo.table_1 set is_taken = 1 i guess meant have condition on select avoid updating same record each time: update top (1) dbo.table_1 set is_taken = 1 output inserted.id @id is_taken != 1

java - How to upload Android app to the market? -

hey i'am trying aupload app android market, have developer account , paid th 25$ , every thing when click upload app after reaches 100% message "you need use sdk version number of 19 or lower." how solve problem, or explain me problem. here manifest: <uses-sdk android:minsdkversion="8" android:targetsdkversion="18" android:maxsdkversion="21" /> remove maxsdkversion , keep targetsdkversion 21

Kendo AngularJS DatePicker custom validation -

how custom validation working kendo angular directive datepicker ? want implement following example using angular directive version of datepicker : kendoui datepicker validation when multiple date fields on page any appreciated.

javascript - document.body.style.backgroundImage does not works -

i have problem document.body.style.backgroundimage tag. woking on local not on server. <a href="roztoky.php" onclick = "document.body.style.backgroundimage = 'url(../img/roztoky.png)';"> on local, backgound switched no problem, on server backgroud cames few seconds , overwrited defalut but if call that: <a href="_section/roztoky.php" onclick = "document.getelementbyid('frame').style.backgroundimage = 'url(img/roztoky.png)';" target="a"> it works ... any ideas? use jquery demo: change <a id="a" href="roztoky.php" onclick = "document.body.style.backgroundimage = 'url(../img/roztoky.png)';"> top $('#a').on('click', function() { $('body').css('background-image', 'url(/img/roztoky.png)'); }); and <a id="b" href="_section/roztoky.php" onclick = "document

maven - Handling javascript aggregation in production vs development environment -

i use yuicompressor-maven-plugin compress , aggregate java scripts / css in our project. refer final java script/ css in required jsps. works fine in production. however, creates problem in development because everytime make change individual js / css, forced rebuild changes reflect. whats best way organize in development able make changes individual files , see them reflecting immediately, while in production can take advantage of aggregation ? probably depends on setup. use jawr compression , can enable/disable given environment. enabled on prod, pages link 1 huge js , 1 huge css file, compressed. disabled on local , dev, pages return links each of individual js , css files, uncompressed.

Object Error in Outlook Function -

i writing function prints out folder name in debug window. reason when call function object required error. have set object unsure wrong. appreciated. thanks! function email_function(fldr outlook.folder) debug.print fldr end function sub email() set objoutlook = createobject("outlook.application") set objnspace = objoutlook.getnamespace("mapi") set start_fldr = objnspace.getdefaultfolder(olfolderinbox) debug.print start_fldr if not start_fldr nothing email_function (start_fldr) end if end sub wrong syntax. call email_function(fldr) 'or email_function fldr original code in question: sub email() dim objoutlook application dim objnspace namespace dim start_fldr folder dim fldr folder set objoutlook = application set objnspace = objoutlook.getnamespace("mapi") set start_fldr = objnspace.getdefaultfolder(olfolderinbox) set fldr = start_fl

android - How to use custom proguard.jar in Gradle build? -

i trying run proguard on app includes unity 3d. proguard fails trying process unity-classes.jar, , workaround build proguard myself patch applied (see this link bug report). so, have own custom proguard.jar now, how can android plugin use it? eclipse matter of replacing proguard.jar in android sdk directory, doesn't work anymore android studio/gradle. in fact, can delete proguard files tools/proguard/lib/, , still runs! how can android studio/gradle use custom built proguard.jar? i solved placing custom proguard.jar in directory named "proguard" in root folder (not project root folder) , setup gradle file this: buildscript { repositories { flatdir { dirs 'proguard' } mavencentral() } dependencies { classpath 'proguard.io:proguard:5.0' classpath 'com.android.tools.build:gradle:0.12.+' } }

exception - Handling an WebException in C# -

i have code: public static string httpget(string uri) { system.net.webrequest req = system.net.webrequest.create(uri); system.net.webresponse resp = req.getresponse(); system.io.streamreader sr = new system.io.streamreader(resp.getresponsestream()); return sr.readtoend().trim(); } try { setinterval(() => { string r = httpget("http://www.example.com/some.php?username= z&status=on"); }, 10000); } catch (webexception) { messagebox.show("no network!"); } what setinterval() in retry run code every 10000 milliseconds. if not connected internet, gives me webexception error. seems can't handle it. catching exception still gives me same error. there way 'do nothing' when error occurs? p.s new c#. edit: here's code setinterval: public static idisposable setinterval(action method, int delayinmilliseconds) {

c# - Flexible paragraph counting -

i've looked through this question, , i've tried modifying answer, i'm still stumped. i need count paragraphs in string. however, paragraphs can separated number of newline characters (1-n newlines), start or without tabs (0-n tabs), , empty lines contain empty characters shouldn't counted (this part that's tripping me up). example document: first paragraph. second paragraph. <tab>the third. <tab> <tab> <tab> <tab>the fourth. fifth. any appreciated. you can split on tab , newline, , remove empty lines text.split(new string[] { environment.newline, "\t", "\n" }, stringsplitoptions.removeemptyentries) .where(x => x.trim() != "") see demo: https://dotnetfiddle.net/y79qjg

c - getting an error about char* in using strcmp(char*,char*) -

i'm getting error: $ gcc -wall -g translate.c support.c scanner.c -o translate support.c: in function ‘translate’: support.c:148:13: warning: passing argument 1 of ‘strcmp’ incompatible pointer type [enabled default] comparenum = strcmp(dict[i], token); ^ in file included /usr/include/stdio.h:29:0, support.c:1: /usr/include/string.h:28:6: note: expected ‘const char *’ argument of type ‘char **’ int _exfun(strcmp,(const char *, const char *)); ^ and here function translate() int translate(char* token, char** dict[], int dictlength) { int = 0; int comparenum; for(i=0;i<dictlength;i++) { if(i % 2 == 0) { comparenum = strcmp(dict[i], token); ++i; if(comparenum == 1) { return i; } } } return 0; } for reason i'm passing in dict[i], array of strings i'm trying compare each element of array strin

jquery - How to read dynamically generated HTML table row's td value? -

Image
in application need enter input values in input controls (textboxes). then, insert these values in table row, here checking redundant empno values. delete button generated dynamically along id while inserting row of table. now need delete row when delete button clicked how select row of selected delete button ? , remove table ? demo on jsfiddle $("#btninsert").click(function () { var eno = $("#txtempno").val(); var ename = $("#txtempname").val(); var sal = $("#txtsalary").val(); var deptno = $("#txtdeptno").val(); var rowcnt = $("#tblbody tr").size(); if (eno == "" && ename == "" && sal == "" && deptno == "") { alert("enter values"); } else { if (rowcnt == 0) { $("<tr><

html - Align link left of div -

(i'll make 1 riddle since project private @ moment ;) ) i have navigation bar. contains 5 links. each 1 has padding: 1% ; , margin-right: 1%; , displayed display: inline-block; . they encased in separate navigation div. trying align text (not padding!) in first link left side of div. i.e. first link, first link, aligns left of containing div. thanks in advance. edit: link page: www.lennardboehnke.com to align text of first link left of container (while retaining padding hover effect) can use first-child pseudo selector select first a , apply negative left margin equal amount of left padding offset it. css: body { margin: 0; padding: 0; font-family: helvetica, sans-serif; font-weight: 100; font-size: 1em; line-height: 1.5; } .content { width: 70%; margin: 0 auto; color: #818181; text-align: justify; } .nav { width: 100%; margin: 5% 0; padding: 0; } .nav { text-decoration: none; color: cornflo

Angularjs state resolve before controller -

i know question gets asked lot, , have read bunch of stackoverflow questions on topic nothing seems fix issue. please show me how being idiot. using angular 1.3.0. here state: .state('app.admin.cards.edit', { url: '/edit/:cardid', views: { cards: { templateurl: 'tpl/cards.edit.html', controller: 'admincardeditctrl', resolve: { data: ['$stateparams', 'admincardservice', function ($stateparams, admincardservice) { var cardid = $stateparams.cardid; admincardservice.getcard(cardid).then(function (data) { return data; }); } ] } } }, access: { auth: true, admin: true } }) here controller: .controller('admincardeditctrl', ['$scope', '$window', 'admincardservice', 'data', function ($scope, $window, admincardservice, data) { console.log(data); } ); here part o

Nagios check_smb_status.sh -

i having little issue here plugin. when run locally on samba server machine works fine: ./check_smb_status.sh total users/process:21 total machines:16 total files:67 |total users/process=21 total machines=16 total files=67 but when run nrpe plugin nagios server it's output not correct: ./check_nrpe -h -t 500 -c check_smb_status total users/process:0 total machines:0 total files:68 |total users/process=0 total machines=0 total files=67 here source of check_smb_status.sh: #!/bin/bash # # program : check_smb_status # : # purpose : nagios plugin return number of user/processes smb # : server, total machines connected , number of files open. # : # parameters : --help # : --version # : # returns : standard nagios status_* codes defined in utils.sh # : # notes : #============:============================================================== # 1.0 : may/08/2011 # progpath=`/bin/echo $0

sql - How to get name of column for use in SELECT clause -

i have table in access db has columns each of 12 months of year. columns have names of "1" "12". say, names of columns number of month represents. columns contain numbers data, , need sum columns months remaining in year. example, right we're in september, i'd need select clause sum values in columns (months) 9 through 12. must able dynamically sum relevant months, next month (oct) sep excluded , 10 through 12 summed. how can reference name of column in select clause able perform test on it. need following: iif(table1.[1].columnname >= month(now), table1.[1], 0) + iif(table1.[2].columnname >= month(now), table1.[2], 0) ... + iif(table1.[12].columnname >= month(now), table1.[12], 0) this 1 approach, but, in passing, if there's better way this, please let me know well. i've seen other posts on discuss returning column names table. not need here. need return column name , perform tests on within select clause. thanks. edit und

c++ - Modify mirroring_partner_instance name in sys.database_mirroring -

i have issue correctly failing on mirror database. when connected principal database (dbx) (mirroring enabled , set up) , fail on principal database (shutting down sql server simulate crash), can no longer send queries without failure. expected since previous connection lost. i close out connections , handles , re-establish new connection, using same connection string, , re-connect mirror database (dby, principal database). my connection string follows: driver={sql native client};server=dbx;failover_partner=dby;database=db;uid=uid;pwd=pwd;network=dbmssocn; from doing research, have learned failover_partner parameter in connection worthless. used when principal server down , new connection being made first time. reason, failover_partner overwritten internally when connection established principal , mirroring_partner_instance found in sys.database_mirroring table used instead. when specify failover_partner dby, after establish connection, query thinks failover partner is, , r

sharepoint - InfoPath 2013 unable to change table to repeating table -

i'm trying create table repeating row in infopath 2013 (editing sharepoint 2013 custom list in case matters). i'm unable post screenshot of table show you, 2-row, 2-column table text in first row, date/time field in 1st column of 2nd row, , text field in 2nd column. when trying create repeating table, i'm getting prompt says "infopath cannot automatically create field or group in section containing control. set binding, select field or group in store control's data:" (i post screenshot of too, reputation low) any ideas why happening? i'm having trouble finding out how repeating controls work in infopath , how create them.

css - Abolsute Vertically center does not work in FireFox -

i have following code in css .box { position: relative; min-height: 113px; overflow: hidden; border: 1px solid #ccc; } .box img { position: absolute; bottom: 0; top: 0; left: 0; right: 0; margin: auto; min-width: 202px; width: 100%; height:auto; } <div class="box">image goes here</div> for reason works chrome, safari , ie.... in firefox image not center in "box" container. does firefox not support method? fiddle

android - Google Cloud Messaging Authentication Error (401) -

i using python-gcm push notification backend server. i can send push notifications android application local computers. works expected. however, when run server following error: gcmauthenticationexception: there error authenticating sender account the server whitelisted (i added ipv4, ipv6, 0.0.0.0/0 make sure). api key right, copied config file. what else can reason not working? i had similar problem , way got work add 0.0.0.0/0 whitelist.

php - Get the property of an item in array -

im trying values of array, dont know why cant, can me? how array start: $userstable = {"userstats": [{ "type": "user", "name": "john stripes", "roll": "moderator", "entries": [..... im doing var_dump($userstable) , can acces first level, im stuck, returns "trying property of non-object". at first level, returns: array(1) { [0]=> object(stdclass)#90 (5) { ["type"]=> string(4) "user" ["name"]=> string(12) "john stripes" ["roll"]=> string(9) "moderator" ["entries"]=> array(191) { [0]=> object(stdclass)#91 (9) { ... im trying in , return $userstable->userstats->name thanks help! userstats array, not object. if want access objects in array, must use index in array, e.g. this: $userstable->userstats[0]-&g

postgresql - SQL statements to replace specific cell data -

i want update data in specific cell. have googled , know need use update, of examples seeing show how change data in batches not single cell , don't want mess up. so here example of answer table; id | answer | user | location 1 | ans 1 | usr1 | loc 1 2 | ans 2 | usr2 | loc 2 3 | ans 3 | usr3 | loc 3 4 | ans 4 | usr4 | loc 4 so if wanted change user usr3 usr2 in record 3, how write that? thanks! update answer set user = 'usr2' id = 3;

activerecord - rails 4 scope through multiple has_one associations -

i trying activerecord association through 2 layers of has_one associations , cannot quite figure out. i have 3 models: class dialog < activerecord::base belongs_to :contact end class contact < activerecord::base has_many :dialogs belongs_to :location end class location < activerecord::base has_many :contacts end i create scope in dialog model allows me pass in id of location , dialogs created contacts given location... like: dialog.from_location(location.first.id) i can non-activerecord array of desired result using select: dialog.all.select{|s| s.contact.location_id == location.first.id } but need return activerecord array other scopes or class methods can called on result. have tried using joins , includes, confused after reading rails guides on how use them. can me figure out how construct scope or class method accomplish this? thanks in advance you can define scopes follows: class dialog < activerecord::base belongs_to :conta

Trying to connect iOS app to dropbox, where do i get the app key this error refers to? -

[error] dropboxsdk: unable link; app isn't registered correct url scheme (db-insert_app_key) on dropbox website states: "in url schemes enter db-app_key (replacing app_key key generated when created app)." not sure key or how it, please??

canjs - Routing Conventions in Can.js -

so i’m looking make routes within super cool can.js application. aiming this… #!claims claimscontroller - lists claims #!claims/:id claimcontroller - views single claim #!claims/new claimcontroller - creates new claim #!claims/:id/pdf - nothing, claimcontroller handle #!admin admincontroller - loads administrative panel menu #!admin/users - nothing, admincontroller handle #!admin/settings - nothing, admincontroller handle so how might this? “claims route”: function() { load('claimscontroller'); }, “claims/:id route”: function() { load('claimcontroller'); }, “admin”: function() { load(‘admincontroller’); }, cool beans, we’re off. if sends link like... http://myapp#!claims/1/pdf nothing happens! ok, let’s add route. “claims/:id/pdf route”: function() { load('claimcontroller'); }, great. link works. here, router’s job load controller. controller recognize pdf action wanted, , show correct vi

Pass queryset to overridden django admin template -

is possible me pass results of queryset change_list.html when i'm overriding it? for example: i've overridden admin template change_list , want add dropdown in list view shows available users user model. queryset users = user.objects.all() {'user': users} #something along lines of rendering change_list.html change_list.html {% u in users %} {{ u.name }} {% endfor %} yes is. (everything possible.) try override admin class transmit queryset overridden template.

JSF selectBooleanCheckbox value in DataTable is allways false -

when click on button invokes method filtering selected items, every items selected parameter false though checkbox checked. it's value of selectboolean checkbox allways false. don't realize problem. why won't set values true? i have jsf page datatable: <h:datatable value="#{productmanagedbean.showproducts()}" var="item"> <h:column> <f:facet name="header"> <h:outputtext value="select"/> </f:facet> <h:selectbooleancheckbox value="#{item.selected}"></h:selectbooleancheckbox> </h:column> <h:column> <f:facet name="header"> <h:outputtext value="image"/> </f:facet> <div class="container-images-product-list"> <h:graphicimage value='#{item.product.image}' class="images-product-list" /> </div> <h:form> <h:commandbutton val

entity framework - Why create a method within a model that creates a list object -

i found example in question. wonder wat purpose served method question(). seems when question object created answer property created list object of answer[s]. this first time have seen technique, new programmer, benefit pattern? public class question { public question() { this.answers = new list<answer>(); } public int questionid { get; set; } public string title { get; set; } public virtual icollection<answer> answers { get; set; } } public class answer { public int answerid { get; set; } public string text { get; set; } } i find pattern useful make consumption of object easier. i.e., creating answers list in constructor, ensured answers never null. makes easier work question object. so, in code consumes question object, can this foreach (answer in question.answers) { ... } without having first check if questions.answers null: if (question.answers != null) { foreach (answer in question.answers) { .

powershell - How can I clone a GroupOfNames Active Directory Object? -

i'm writing script take 1 groupofnames object , create second group first groups members. seems simple piece of code: $obj = get-adobject -server "$server" -searchbase $searchbase -filter "name -eq '$groupname'" -properties member new-adobject -server "$server" -path $searchbase -type 'groupofnames' -name "$newgroupname" -otherattributes @{'member'= ($($obj.member))} when run $obj gets created , can display both groupofnames information, list of members. when calls new-adobject cmdlet, following error: new-adobject : unable contact server. may because server not exist, down, or not have active directory web services running. i've tried multiple variations of code , fail similar errors. interestingly, if loop through list of members , add them group 1 @ time, works, takes way long (an hour+ vs seconds). try this, casts results of first query, adpropertyvaluecollection , string array(un

sql server - SQL linking by Rank() Over -

i have calculate days when container out of facility, each time container arrives has different primary key same id. same container can leave , arrive multiple times of course have count days between closest departure , arrival. i've been trying using rank() on function counting departures , arrivals: select distinct *, datediff(day,c_out.time_out, c_in.time_in) days (select container_id , time_out , rank() on (partition container_id, order time_out) leave_no containers departure_type='truck' --edit2 ************************************ ) c_out inner join (select container_id incoming_id , time_in ,rank () on (partition container_id, order time_in) arrive_no containers) c_in on c_out.container_id=c_in.incoming_id c_out.leave_no=c_in.arrive_no+1 the idea here match leaves entries: if container left n-th time, next arrival n+1 but result receive like container_id time_out leave_no incoming_id time_in arrive_no days abc123 2014-04