Posts

Showing posts from May, 2011

bash - How can I subtract timestamp results from `date` in one line of shell? -

i can generate 2 timestamps so: date +"%s" -d "$(curl -s --head http://google.com | grep ^date: | sed 's/date: //g')" // result: 1417800327 date +"%s" // result: 1417800325 how can subtract them 1 line? echo "$((1417800327-1417800325))" // result: 2 but want closer to: echo "$(( (date +"%s" -d "$(curl -s --head http://google.com | grep ^date: | sed 's/date: //g')") - (date +"%s")))" try doing : lang=c echo $(( $(date +%s) - $(date -d "$(curl -s --head http://google.com 2>&1 | awk -f'date: ' '/^date:/{print $2}')" +%s) )) or splitted multi-lines readability : lang=c echo $(( $(date +%s) - $( date -d "$(curl -s --head http://google.com | awk -f'date: ' '/^date:/{print $2}' )" +%s) ))

c++ - Newbie here: Different results on PC and MAC. Why? -

this question has answer here: parameter evaluation order before function calling in c [duplicate] 7 answers i trying learn basics of c/c++ right now. going through course on lynda.com my questions deals sequence of code chapter 4 "macro caveats course c/c++ essential training". have followed setup procedures xcode , eclipse setup correctly on mac , eclipse on pc. when run code on mac , pc different results. trying understand why happening , can same result on both. here code: // working.c bill weinman <http://bw.org/> #include <stdio.h> #define max(a, b) ( (a) > (b) ? (a) : (b) ) int increment() { static int = 42; += 5; printf("increment returns %d\n", i); return i; } int main( int argc, char ** argv ) { int x = 50; printf("max of %d , %d %d\n", x, increment(), max(x, increment())); pr

html - Using <br/> versus <p></p> versus CSS for form fields, what is the current accepted best practice for desktop, mobile, and accessibility? -

question: should avoid using <br/> break lines in favor of wrapping content in <p></p> ? when ok use <br/> (if ever)? they both work fine in call typical desktop browsers, 1 or other work better accessibility features , mobile devices? what current recommended best practice? (it seems moving target.) for example, when doing stuff this: using <br/> separate label input <label for="txtusername">username</label><br/> <input type="text" id="txtusername" autocomplete="off" maxlength="50" spellcheck="false"/> using <p></p> separate label input <p><label for="txtusername">username</label></p> <p><input type="text" id="txtusername" autocomplete="off" maxlength="50" spellcheck="false"/></p> i've searched around bit , the

python - Changing text of label does not work -

i have problem following python script. later, catch data barcode scanner , display text label. whenever text should changed label (highlighted line), program crashes. absolute beginner python , can not explain that. comment out line, program works. from tkinter import * import pyhook class application(frame): def __init__(self): frame.__init__(self) self.master.title("sc4nn0r") self.variable = "start variable" self.master.geometry("363x200") self.master.resizable(0,0) self.master.rowconfigure( 0, weight = 1) self.master.columnconfigure( 0, weight = 1 ) self.grid( sticky = w+e+n+s ) self.label4string = stringvar() self.label4 = label(self, textvariable=self.label4string) self.label4.grid( row = 2, column = 1, columnspan = 2, sticky = w+e+n+s) self.label4string.set("variable1") self.string = '' hook = pyhook.hookma

jquery - Pushing variable to an existing function with javascript -

so, lets have function this (function($){ $.fn.test = function(opts){ var _object = $(this), _opts = $.extend({}, $.fn.test.defaults, opts), _callback = _opts.objects[1].callback /* code here */ _callback() /* calling callback */ } $.fn.test.defaults = { /* not important */ } }) that's how initialise function $('.element').test({ option: 0, /* not important */ variable: 1, /* not important */ objects: [ { "object" : ".element2", "callback" : false }, { "object" : ".element3", /* object № 2 */ "callback" : function(){ /* >>> {this part} <<< */ console.log (this) } }, ] so on {this part} returns data of object №2, callback function run on _object element $.fn.test output data of $('.element') . c

iOS CMake and XCode 6 "no such product type for 'iphoneos'" -

when generate library project , try compile get: target specifies product type 'com.apple.product-type.tool', there's no such product type 'iphoneos' platform from understand product type available on mac os , not ios, correct? how possible fix it? cannot find clue.

asp.net - Session Ends Automatically -

about application: build application in .net have installed on 5 sub domains. example client1.mydomain.com, client2.mydomain.com . uploaded application on shared server. issues: found, sometime user session end without reason. try figure out. support team told me can use maximum of 150 mb in pool. application using 70-80 mb, though 5 sub domains using 70*5 = 350 mb, , that's why poll getting reset/recycling & session ends automatically. shifted app on vps. configuration 2gb ram, 40gb space, windows 2008 r2, iis 7.5. issues still same. i found lots of suggestion, looks me experimental my thoughts , query: guess need set maximum pool size. if correct, can set pool size through "memory based maximums", question is, if uncheck maximum pool size default. , maximized pool size value can set ? can suggest me check , how can resolve issues ? thanks please refer article. http://technet.microsoft.com/en-us/library/cc745955.aspx there idletimeou

How do I read a formatted file in Python? -

i need read data file formatted so: jamestown 20 rocky mountain 34 illinois st 28 ball st 51 tulsa 7 bowling green 34 i need python read 1 line @ time , both team names ("jamestown" , "rocky mountain") , both scores ("20" , "34"). how go doing this? tried making code see if read team name, whatever reason, doesn't work. onespace = false char in fileline: if char == ' ': if onespace: team1 = team1[:-1] return else: onespace = true team1 = team1 + char else: team1 = team1 + char onespace = false import re ll=[] line in file.readlines(): ll.append(re.findall(r"(.*?)\s{2,}(\d+)",line) print ll https://regex101.com/r/wv5tp1/12

checkbox - How to Grab multiple values from checkboxes with Jquery -

i have form <form class='lostkittieform'> <label class="kittiecolor"><input type="checkbox" value="black">black</label> <label class="kittiecolor"><input type="checkbox" value="brown">brown</label> <label class="kittiecolor"><input type="checkbox" value="white">white</label> <label class="kittiecolor"><input type="checkbox" value="gray">gray</label> <label class="kittiecolor"><input type="checkbox" value="orange">orange</label> <label class="kittiecolor"><input type="checkbox" value="multicolored">multicolored</label> <input type="submit"> </form> my jquery code trying grab values checked reason it's grabbing

c++ - Is there a difference in runtime if a heavy calculations function is in the conditional part of the loop? -

is there difference in runtime if heavy calculations in conditional part of loop? for example: int i,n; for(i=1;i<=[call complex function on n];i++) ... or int i,n,foo; foo=[call complex function on n]; for(i=1;i<=foo;i++) ... which 1 more efficient? loop make calculation once or each iteration? yes, there "performance hit" functions provided in conditional part of for loop unless function const , compiler can reduce down constant value. compiler need call function each iteration. i highly recommend placing result of function constant temporary variable before entering loop. example: const unsigned int limit = my_vector.size(); (unsigned int = 0; < limit; ++i) { // iterate on vector }

How to return null to a user defined class in c++ -

i have defined queue class works card class have created, function method return supposed return card when called, if there no card should return null. problem keep getting errors when try null , null , , '\0' . for '\0' char card error, null long card error, strange part null not recognized keyword , ignored. i wondering if have define null in cards class somehow, or if different issue altogether. here's code using queue class, in case needed: class queue{ card cards[52]; int first; int last; int count; public: queue(); void insert(card insert); card remove(); int getsize(); }; queue::queue(){ first = last = count = 0; } card queue::remove(){ if(count == 0) return null; card temp = cards[last]; last++; count--; if (last > 0) last = 51; return temp; } edit: class queue{ card *cards; } queue::queue(){ cards = new card[52]; } card queue::remove(){ if(count ==

java - How do I access a property from log4j.properties in a JUnit test? -

i'm writing unit test validate logging functionality checking log file. started log path hard coded in test case, i'd rather use entry log4j.appender.file.file in log4j.properties file, in case changes. there way access programmatically inside junit code? and in case wondering: functionality i'm testing in private s, can't check return values. you can access programmatically using following: fileappender appender = (fileappender) logmanager.getrootlogger().getappender("file"); file file = new file(appender.getfile());

c - why array shows garbage value when only one format specifier used? -

i trying print value of array in c-language.i using 3 format specifier 1 value of array , problem don't understand how other 2 values coming in output . here code: int arr[6] = {3,4,42,2,77,8}; printf("%d %d %d ",arr[2]); output : 42 3 4 according c standard if there insufficient arguments format, behavior undefined. in call of printf printf("%d %d %d ",arr[2]); the arguments exhausted after first format specjfjer. function call has undefined behaviour , output can contain garbage. you shall write printf( "%d ", arr[2] ); or example printf( "%d %d %d ", arr[2], arr[3], arr[4] );

html - Contenteditable Spacebar Click Does Not Register -

i'm adding content editable each element "data-edit" attribute this. $element.find("[edit]").prop("contenteditable", "true"); i have 1 specific element in when edit text, spacebar not register , cant add white space between letters. attribute on element looks this <a href="#tabs-element-tab-1" class="ui-tabs-anchor" data-edit contenteditable="true" spellcheck="false">1</a> is there known bug contenteditable can cause this?

javascript - AngularJS form $valid set to true before validation completes -

i displaying validation symbol in left nav of page indicate whether form valid or not. when load page form's $valid attribute set true, changes false (as should given retrieved input data). result validation symbol flickering valid invalid. there way prevent this? validation symbol tied valid attribute on $scope, gets set within watch. there logic added watch check if form hasn't finished initializing or validating? thanks! here current watch code. valid attribute goes undefined true false after couple different watch cycles. $scope.$watch( 'sections.' + section.sectionname + '.sectionform.$valid', function( valid ) { section.valid = valid; }, true); and html display validation symbol: <span ng-class="{ 'fa fa-check': section.valid, 'fa fa-warning': !section.valid}"> </span> i think problem $watch function. first time set "section.valid" undefined. don't need watch manually. each f

android - What kind of font I should use for TextView that can support all languages? -

i have textview can display text in languages ( end-users input text). i wondering font should use? in article: http://www.google.com/design/spec/style/typography.html#typography-roboto-noto google says: to support languages worldwide, google recommends using roboto languages use latin, greek, , cyrillic scripts , noto other languages. if understand correctly. there no single font file (roboto|noto) can support languages. anyone know font can use? should default font (android decides) choice? thanks! android you. read paragraph before cited paragraph: since ice cream sandwich release, roboto has been standard typeface on android. since froyo, noto has been standard typeface on android languages not covered roboto. so don't change font/typeface used , fine. remember that, design site not android, web, chrome os etc google's unified/cross platform design, hence wording.

swing - Java: Add MouseListener to custom JComponent -

if create new class inherits jcomponent, paintcomponent(graphics g) method override, painting circle using g, should modify in order mouselistener trigger when click inside bounds of component? because in constructor of component added setbounds(...) , added mouselistener, fires every time click anywhere inside container in custom component , not when click inside it. i not want check in mouseclicked() method whether event happened inside component or not, want called when click inside. here's code: public class node extends jcomponent { private int x, y, radius; public node(int xx, int yy, int r) { x = xx; y = yy; radius = r; this.setbounds(new rectangle(x - r, y - r, 2 * r, 2 * r)); setpreferredsize(new dimension(2 * r, 2 * r)); } public void paintcomponent(graphics g) { super.paintcomponent(g); graphics2d gr = (graphics2d) g; gr.setcolor(color.black); gr.drawoval(x - radius, y -

My Favicon isn't showing up on my local server -

i'm working on local server , trying add simple favicon. have searched high , low on these forums, , tried everything. i'm not sure going wrong. this code have inserted head of code: <link href="http://www.canwise.com/favicon.ico" rel="shortcut icon" type="image/x-icon"/> my favicon image in same folder html file page. haven't put in images folder. i can't life of figure out i'm doing wrong? i'm working else's coded files homepage file not called "index.html" it's called "application.html.erb" have it? also, other html files stored in different folders. put favicon image in same folder html. any suggestions? please help. i'm new coding. i pretty sure work if remove "shortcut" text rel tag. should this: rel="icon" think "shortcut" text proprietary old ie browsers. if doesn't work check paths. test using relative path instead of full pat

git - How to get all commit messages in a repo by one author? -

how can retrieve list of commit messages in git repo given commit author? git log --all --author <author regex> easy work out reading the documentation . note it's regex, characters may need escaped.

ruby on rails - Override Spree Admin views with Deface -

i'm trying add few lines spree admin. file override: backend/app/views/spree/admin/orders/_shipment.html.erb i want add here: <tr class="show-tracking total"> <td colspan="5" class="tracking-value"> <% if shipment.tracking.present? %> <strong><%= spree.t(:tracking) %>:</strong> <%= shipment.tracking %> <% else %> <%= spree.t(:no_tracking_present) %> <% end %> </td> </tr> my override is: <!-- insert_after '.tracking-value' --> </br> <strong><%= spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %></br> <% if shipment.date_delivered? %> <strong><%= spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br> <% end %> located in app/overrides/spree/admin/orders/shipment

linux - Can't increment a 0-padded number past 8 in busybox sh -

this code using save files camera , name them 0001 onward. camera running busybox, , has ash shell inside. code based on previous answer charles duffy here . #!/bin/sh # snapshot script cd /mnt/0/foto sleep 1 set -- *.jpg # put sorted list of picture namefiles on argv ( number of files on list can requested echo $# ) while [ $# -gt 1 ]; # long there's more one... shift # ...some rows shifted until 1 remains

python - Django use value of template variable as part of another variable name -

i have loop inside template: {% in 1234|make_list %} i obtain inside loop: {{ form.answer_{{ }} }} i aware above line not valid (it raises templatesyntaxerror), know if there way use value of part other variable name. first, need custom template filter mimic getattr() functionality, see: performing getattr() style lookup in django template then, need add template filter string concatenation: {% load getattribute %} {% in 1234|make_list %} {% "answer_"|add:i answer %} {{ form|getattribute:answer }} {% endwith %} {% endfor %}

How do I completely uninstall git from my Linux Machine -

i had installed git downloading tar ball , doing following steps ./configure --prefix=/scratch/custom/git make make install but after running these commands, still see git created under /usr/local below bash-4.1$ whereis git git: /usr/bin/git /usr/local/git /usr/share/man/man1/git.1.gz i remove , reinstall again how do same? if make unistall doesn't work, mentioned here, uninstalling on linux , try make install again, capturing output. then go through of install commands , manually remove installed files. also, 'make -n` may determine of installed files.

python - Tkinter showerror appears again when return is bound -

i have used root.bind("<return>",enter) calls function enter when return key (enter) pressed. function enter reads input field , might call tkmessagebox.showerror(header,text) depending on input. pressing return key both press ok on error , make tkmessagebox.showerror(header,text) appear again, despite next line after tkmessagebox.showerror(header,text) inputfield.delete(0,end). this code: enter(): showerror("error","wrong input") streckkodentry.delete(0,end) this solves it: enter(): disable() showerror("error","wrong input") enable() streckkodentry.delete(0,end) where disable() removes binding , enable() puts back this problem occur on machine debian 7.0 not windows machine. ideas how solve without adding disable/enable each showerror? i found problem! had still defined binding bind_all rather bind . in windows not matter since error message blocks bind_all binding, error me

Validating a linked field in Parsley.js -

this question asked "jackrugile" on github can't located answer if ever given. i'm reposting here because having exact same issue: when using validation constraints linked other fields (equal to, greater than, less than, before date, after date, etc.), whatever triggers validation call on 1 field should automatically called on other. applicable triggers other submit (focusin, focusout, keydown, keyup, etc.) for example, if have field called "small number" , field called "large number", add data-greaterthan attribute "large number" input make sure larger. fill out field follows: small number: 12 large number: 7 this validation fails , error shows on on "large number" field. then, fix error, instead of making "large number" larger 12, make "small number" less 7. state of form now: small number: 5 large number: 7 however, though should pass because within validation rules, not remove error becaus

sass - Combine multiple CSS Preprocessors -

we have hundreds of .less files in production, start incorporating .scss files well. would need make own file type in order compile mutliple types of css preprocessor files or there way this: @import 'less-styles.less'; @import 'scss-styles.scss'; @import 'stylus-styles.styl'; //potentially whereby produces single css file in order. because of valid css code valid less code, compile scss , stylus files first css , import that. sass scss-styles.scss scss-styles.css than in less code: @import (less) scss-styles.css the less keyword above does: less: treat file less file, no matter file extension the above means can extend , mixin css selectors scss-styles.css file in less code. notice variables , mixins from scss-styles.css file not available (re)use in less. if need variables , mixins too, solution seems to convert scss less . see also: https://github.com/bassjobsen/grunt-scss2less you should able same stylus (.styl) f

javascript - Totalling an ExtJS editable grid's input fields -

this question regards extjs 3 editable grids. have need total input fields of 1 column of editable grid. there the store's sum method data in input fields not in store; instance might make entry in input field , click button on toolbar. the "traditional" way in case seems to set appropriate listener , commit content of input field store, can convoluted , seems downright unnecessary if result of clicking toolbar button re-directed elsewhere anyway. there solution? an alternative gather input fields using oft-overlooked ext.query functionality; following second column of grid ('.x-grid-col-0' first column): var qtyfields = ext.query('.x-grid3-col-1 input', mygrid.getview().mainbody.dom); var total = 0; var qty; (var i=0, n=qtyfields.length; i<n; i++) { qty = parsefloat(qtyfields[i].value); total += isnan(qty) ? 0 : qty; }

php - Not able to access mysql using script -

i getting following error when trying access mysql table : access denied user 'root'@'localhost' (using password: no) but, can login root when using mysql in command line. that normal behaviour. set root password database on can't access without password. why reports: access denied user 'root@localhost' (using password: no ) obviously when give password -p switch succeed.

javascript - moment.js gives invalid date in firefox, but not in chrome -

i'm having strange issue moment.js. wrote function convert time utc german time format, , seemed work fine in chrome. tried firefox , here got invalid date. moment.locale("de"); $('#from').datepicker({ format: "dd. mmmm yyyy" }); $('#from').on('change',function() { var = moment($('#from').val(), "dd. mmmm yyyy").format("llll"); var b = moment(a).add(7,'days'); var localtime = moment.utc(b).todate(); localtime = moment(localtime).format('dd. mmmm yyyy'); $('#to').val(localtime); }); $('#to').datepicker({ format:'dd.mmmm yyyy' }); $('#sendbtn').on('click',function(){ /... var = moment(fromfield.value).format(); var = moment(tofield.value).format(); /... $('#calendar').fullcalendar( 'gotodate', ); geteventdate(from,to,persons.value); } }); function getevent

Computational Operator in Math -

can't seem figure out "<<" operator is: 11<< 2 44 1<<1 2 10<<2 40 the shift operators, bitwise shift value on left number of bits on right: the << shifts left , adds zeros @ right end. the >> shifts right , adds either 0s, if value unsigned type, or extends top bit (to preserve sign) if signed type. thus,2 << 4 32 , -8 >> 3 -1. reference: http://www-numi.fnal.gov/offline_software/srt_public_context/webdocs/companion/cxx_crib/shift.html

language design - is javascript's `return` really a *keyword*? -

this snip ran without complain on both nodejs , browser: this.return = function ( x ) { return x }; console.log ( this.return(1) ); i expecting fail hard syntax error. i meant, can understand why this['return'] works.. though return lexer keyword? is javascript context-sensitive language? added : point lexer not have t_return token, uses t_string instead. isn't? return reserved keyword , reserved keywords can used property accessors without issue, it's bad practice so. reserved keywords may not used names variables, functions, methods, or identifiers arrays , objects, because ecmascript specifies special behavior them: the source text ecmascript scripts gets scanned left right , converted sequence of input elements tokens, control characters, line terminators, comments or white space. ecmascript defines keywords , literals , has rules automatic insertion of semicolons end statements. reserved words apply identifiers (vs. identif

javascript - Using navigator.plugins to determine Java version -

the following javascript code inform browser's enabled plugins (yeah, know doesn't work on ie, ie there's deployjava): if ((navigator.plugins) && (navigator.plugins.length)) { (var bb = 0, l = navigator.plugins.length; bb < l; bb++) { var vv = navigator.plugins[bb].name + "<br>"; document.write(vv); } } i have java 6.22 installed relevant line written page this: java(tm) platform se 6 u22 my question is: how can complement above code returns major version (6) , update (22) found in (or anyone's) browser? i think best way work regular expression, not it. i think easiest (read: hackiest) solution this: var plugin_name = navigator.plugins[bb].name if (plugin_name.tolowercase().indexof("java") != -1) { var parts = plugin_name.split(" ").reverse(); // if plugin has update if(plugin_name.match(/u[0-9]+/)) { // grab end of plugin name , remove non num

pointers - C++ copy constructor issue with parent/child classes -

i've run problem copy constructors...i assume there basic answer , i'm missing obvious - maybe i'm doing entirely wrong - haven't been able figure out. basically, have parent class , child class. parent class contains vector of pointers (different) base class object. child class wants instead store pointers objects derived base object. here's pseudocode sample, if helps: // base classes class itemrev { ... } class item { protected: vector<itemrev *> m_revptrvec; } item::item(const item &inputitemobj) { // copy contents of input object's item rev pointer vector vector<itemrev *>::const_iterator veciter = (inputitemobj.m_revptrvec).begin(); while (veciter != (inputitemobj.m_revptrvec).end()) { (this->m_revptrvec).push_back(new itemrev(**veciter)); } } ========= // derived classes class jdi_itemrev : public itemrev { ... } class jdi_item : public item { ... } jdi_item::jdi_item(const jdi_item &itemobj)

c++ - How to set environment variable using setenv -

i trying set env variables using setenv function. unfortunately doesn't work expected. int setnewenvvariable(const std::string *varname, const std::string *value) { setenv(varname->c_str(), value->c_str(), true); return this->var_added; } it seems work when wants. can change (replace) variable, doesn't changes. cannot add new variable @ all. have tried use putenv. didn't i have found when doesn't change existed variable. when try add new variable nonexistent yet. after doesn't add new variable , in addition doesn't change existed variable ,but before trying add new variable worked. i mean before trying add new var accepts changing of existent example path, after passing nonexistent variable path2323 , stops accept changing existed vars. edit i have checked return value 0 , errno 0........ wrong ?

joomla2.5 - Adding jquery plugin to joomla 2 -

i trying add country selector front page of site users able select country , land on specific page. have not been able find joomla extension this, found jquery plugin this, not sure how or there way add joomla site. the jquery plugin there multiple ways that: http://extensions.joomla.org/extension/jquery-easy install plugin include jquery in b. http://dabrook.org/blog/two-ways-to-include-jquery-in-your-document joomla template file (don't forget jquery.noconflict()) and @ , modify article country picker (put js code in). or develop plugin that. (for more experienced user)

java - How can I compare POJOs by their fields reflectively -

i looking unit testing framework, can use compare pojos don't override equals , hascode methods. had @ junit, test ng , mockito don't seem solve purpose. for example consider code below : public class carbean { private string brand; private string color; public carbean (){ } public carbean (string brand, string color){ this.brand= brand; this.color= color; } /** * @return brand */ public string getbrand() { return brand; } /** * @param brand set */ public void setbrand(string brand) { this.brand= brand; } /** * @return color */ public string getcolor() { return color; } /** * @param color set */ public void setcolor(string color) { this.color= color; } } the pojo carbean represents real world car. has 2 parameters, brand , color. now, suppose have 2 car objects below : carbean car1 = new carbean("

node.js - Difference between value of 'this' in client-side vs server-side javascript -

writing few nodejs test programs , running few unexpected quirks. in browser when console.log(this); , not in function, window.object. know nodejs has global object when console.log(this) empty object. when ask value of 'this' inside function created undefined . expected reference current function (myclass, in case) going on here? see following nodejs program: 'use strict'; var log = console.log; log(this); //empty object function myclass() { log (this); //undefined this.variable = 3; //exception, cannot set property 'test' of undefined } myclass(); thanks actually, node.js behaves correctly here, because you're not constructing class, calling it's constructor without this context. create new instance of class should use new operator: new myclass(); the difference in behavior caused strict mode , because in strict mode, due security reasons, this is not referencing global object default .

sql - how to filter a table that having exactly the specified values in tsql -

i need filter table exact values. have googled day now, wonder if guys can me i have table this: id | group id | tax id ------------------------- 1 | 1 | 1 2 | 2 | 1 3 | 2 | 2 4 | 3 | 2 5 | 3 | 3 6 | 3 | 4 7 | 4 | 1 8 | 4 | 4 9 | 5 | 2 10 | 5 | 4 11 | 6 | 3 12 | 6 | 4 i need group id when tax ids 2,3, , 4, group id 3. if put tax_id in (2,3,4) these tax groups 3,5,6. want tax group 3 only. hope not duplicate question, since not find when google it. you need group by clause on group_id column , having clause count distinct tax_id equal 3 tax id 2 or 3 or 4 not exists take care of condition group should contain given set if elements , not additional elements sql fiddle select [group_id] table1 t [tax_id] in (2,3,4) , not exists ( select 1 table1 e t.group_id = e.group_id , t

cloudant - How to combine multiple CouchDB queries into a single request? -

i'm trying query documents in cloudant.com database (couchdb). 2 following query requests work fine separately: { "selector": { "some_field": "value_1" } } { "selector": { "some_field": "value_2" } } cloudant's documentation seems indicate should able combine 2 queries single http request follows: { "selector": { "$or": [ { "some_field": "value_1" }, { "some_field": "value_2" } ] } } but when try receive following response: {"error":"no_usable_index", "reason":"there no operator in selector can used index."} can tell me need work? there doesn't seem way achieve cloudant query @ moment. however, can use view query instead using index created cloudant query. assuming index in design document named ae97413b0892b3738572e05b2101cdd303701bb8 : curl -x post \ 'https

java - Automatically create a 2D array simulations map -

so i'm working on agent based simulation , i'm going use 2d array 500x5000 or 1000x1000. actual simulation consist of walls make rooms. problem don't want manually insert each wall because take long. is there way can create simple 2d image of map , have program read image , insert walls 2d array based on image. regards

postgresql - Why does calling random() inside of a case statement produce unexpected results? -

https://gist.github.com/anonymous/2463d5a8ee2849a6e1f5 query 1 not produce expected results. however, queries 2 , 3 do. why moving call random() outside of case statement matter? consider first expression: select (case when round(random()*999999) + 1 between 000001 , 400000 1 when round(random()*999999) + 1 between 400001 , 999998 2 when round(random()*999999) + 1 between 999999 , 999999 3 else 4 end) generate_series(1, 8000000) presumably, thinking value "4" should never selected. but, problem random() being called separately each when clause. so, chance fails each clause independent: about 60% of time random number not match "1". about 40% of time random number not match "2". about 99.9999% of time random number not match "3" (i apologize if number of nines off, value practically 1). that means 24% of time (60% * 40% * 99.9999%), value "4" appear. in actua

if condition for value within parentheses or not python -

i know there has been many questions need small step. trying figure out way see if particular value within parenthesis or not. need store values within parenthesis negative integers otherwise positive integers. using function gives me error values not in parenthesis. def extract(string, start='(', stop=')'): return string[string.index(start)+1:string.index(stop)] please help. if want remove parentheses if present , return string representation of number without parentheses, strip() them: >>> = '(-23)' >>> b = '43' >>> a.strip('(').strip(')') '-23' >>> b.strip('(').strip(')') '43' alternatively, if want actual integers , they're stored without signs: in [1]: def extract(s): ...: if s.startswith('(') , s.endswith(')'): ...: return -int(s[1:-1]) ...: return int(s) ...: in [2]: extract(

java - Android - Center View in Other View inside Layout -

Image
hi having trouble centering text view in image view. want kinda have vertically centered , stay vertically centered if the font size changes. and here have in xml don't care if need change relative layout kind doesn't matter me want able center this. heres xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context="com.spencer.app.profileactivity" android:id="@+id/layout"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" and

c - read from disk and EINTR -

is necessary check errno == eintr if read massive amounts of data? use pread() function read. in time have never seen eintr returned, have seen code online explicitely checks it. so necessary check eintr , maybe repeat call? eintr returned when system call interrupted result of process receiving signal. if process blocked in kernel, waiting read complete, , signal caught, may wake kernel; depends on if operation interruptable. sleeping i/o routine woken , expected return eintr user-space. just before kernel returns user space, checks pending signals. if signal pending, take action associated signal. possible actions include: dispatching signal signal handler, killing process, or ignoring signal. assuming not kill process and/or signal handler returns normally, system call return eintr. if not expecting this, typically want try action again, can used way gracefully abort i/o operation. example, alarm(2) can used implement timeout, sigalrm delivered if i/o not com

coding style - Maintaining Maximum Line Length When Using Tabs Instead of Spaces? -

style guides various languages recommend maximum line length range of 80–100 characters readability , comprehension. my question is, how people using tabs indentation comply line length limits? because, if length of tab set 2 in editor, same code over 80 characters long in else's editor tab length set 3/4/6/8. some suggest mentally see tab length @ 8 characters. isn't realistic , won't let me focus on programming i'd have check every other line. so, how (if use tabs in code) it? almost languages have convention tab size. projects have convention tabs size well, usually (though not always) same language's tab size. example, ruby 2, python & php 4, c 8, etc. sticking project's tab length, or language tab size if there no obvious project tab size, far sane thing do, since people use, except perhaps few. ability set different tab size largest advantage of using tabs instead of spaces, , if user wants deviate standard, that's fine, t

java - Setting database records into jtextfield -

the problem of code can't set data database onto jtextfield. every time run code, says stackoverflowerror. how fix error? here's code public class dataconnect extends databasegui { private connection datacon; private statement datastmt; private resultset datars; private string name, address; int age; public dataconnect(){ try{ class.forname("com.mysql.jdbc.driver"); datacon = drivermanager.getconnection("jdbc:mysql://localhost:3306/studentrec","root",""); datastmt = datacon.createstatement(); datars = datastmt.executequery("select * studentrecords"); }catch(exception exc){ system.out.println(exc.getmessage()); } } public void setdata(){ try{ datars.next(); name = datars.getstring("name"); age = datars.getint("age"); address = dat

Eclipse Kepler not recognizing C++ header files -

(ignore actual code, it's copied glfw website , i'm sure it'll pain working well...) i've been trying link glfw c++ eclipse project. eclipse won't recognize header file - after adding folder project using "properties -> c/c++ general -> preprocessor include paths, macros etc." try inlucde in cpp file , "no such file or directory" error. screenshot: http://i.imgur.com/a0qu2wq.png not sure if proper way it, fixed issue including folder not "properties -> c/c++ general -> preprocessor include paths, macros etc." "properties -> c/c++ build -> gcc c++ compiler -> includes"

html - How would I make a <div> automatically make a new line judged on the input? -

what mean is, possible make div when type stuff div, automatically makes new line each new line in code detects? example, want this: <div> hello, world! how doing today? </div> which return hello, world! how doing today? which in reality requires <br> or something. don't want have put millions of them make simple lines. code put before outputs this: hello, world! how doing today? i want automatic new line judged on code's enters. possible? use css white-space property. <div style="white-space:pre"> hello, world! how doing today? </div> note preserve white space, including multiple spaces (such indent). if want collapse white space still use newline characters indicate line breaking, can use pre-line value, though option not supported in ie7 (if matters you). see live example: http://jsfiddle.net/vyme6xs8/1/

How to apply JavaScript changes in Firebug? -

i playing around javascript code in firebug , changes take effect in page. when there code inside jquery's $.ready() function. some kind of refreshing page without losing of has been edited. there way that? page changes made via firebug or via javascript not persist 1 page load another. each time page loaded, original html, css , javascript parsed , loaded (from cache or server). prior changes not there. the way dynamic page change still present after refresh save changed state persistent location , rebuilt appropriate page content state each time page loaded. but, if make change page , store state in cookie, in local storage or on server, can have javascript runs each time page loads gets state wherever stored , applies appropriate change page. if you're saving state on server (on behalf of particular user), have serve modify page contents before served browser.

java - This line is giving a nullpointer and I have no idea why -

i'm trying add buttons these panels, can check if they're clicked. i'm still new java , how taught how it. right i'm making big panel , adding 48 new panels onto , adding buttons on each of panels, can make action event. if there way me check if clicked panel that, have no idea how. i'm getting nullpointerexception on line "panel[x].add(click[x]);" package catchthemouse; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class catchthemouse extends jframe implements actionlistener, mouselistener{ final int rows = 8; final int cols = 6; final int gap = 2; final int max_panels = rows * cols; int clicks; int hits; int percentage = 0; int width; int height; int panelx; int panely; int whichpanel = (int)(math.random() * 47 + 1); jbutton[] click = new jbutton[max_panels]; jlabel grats = new jlabel(""); jlabel spot = new jlabel("x"); jpanel[] pan

Browserify - add html5shiv to bundle.js -

i trying use browserify - bundling 'html5shiv.js' doesn't seem working. here package.json file { "name": "node_sports_lineup", "version": "0.0.1", "private": true, "scripts": { "start": "node main.js", "test": "mocha tests" }, "dependencies": { "body-parser": "~1.0.0", "cookie-parser": "~1.0.1", "debug": "~0.7.4", "ejs": "*", "express": "^3.17.5", "express-generator": "^4.9.0", "express-session": "*", "jade": "*", "mongodb": "*", "mongoskin": "*", "monk": "*", "morgan": "~1.0.0", "serve-favicon": "~2.1.3", "passport":

ios - [__NSCFArray objectForKey:]: unrecognized selector sent to instance when fetching from Core Data -

i getting error [__nscfarray objectforkey:]: unrecognized selector sent instance when trying fetch data core data . i relatively new ios programming , don't quite understand error trying tell me. set exception breakpoint figure out line giving me problem , line of code: if let fetchresults = managedobjectcontext!.executefetchrequest(fetchrequest, error: nil) as? [user] { why getting error , how resolve it? related way save core data ? did change receive json server, process in background , save changes managedobjectcontext in main thread. func getuser(userid: string) -> user? { let fetchrequest = nsfetchrequest(entityname: "user") fetchrequest.predicate = nspredicate(format: "userid == %@", userid) fetchrequest.fetchlimit = 1 if let fetchresults = managedobjectcontext!.executefetchrequest(fetchrequest, error: nil) as? [user] { if !fetchresults.isempty { return fetchresults[0] } else {

Domain directs to nginx default page instead of my root -

here server setup /etc/nginx/sites-available/example.com server { listen 80; server_name example.com www.example.com root /root/sites/example.com; index index.html; } server { listen 80; server_name subdomain.example.com www.subdomain.example.com; location /static { alias /var/www/subdomain.example.com/static; } location / { proxy_set_header host $host; proxy_pass http://127.0.0.1:5000; } } subdomain.example.com working fine. when go example.com show nginx default welcome page. note: deleted /etc/nginx/sites-enabled/default need fix it. you missed ; after server name. should be: server_name example.com www.example.com;