Posts

Showing posts from May, 2014

d3.js - d3 directed graph, how it works -

i'm trying insert d3 directed graph( this one ) thorax( super type of backbone ) view. able still have questions on way working(d3 code). first create force layout passing nodes , edges var force = d3.layout.force() .nodes(nodes) .links(links) .size([width, height]) .linkdistance(150) .charge(-500) .on('tick', tick) does create graph actually? what these 2 lines do this.path = this.svg.append('svg:g').selectall('path'); this.circle = this.svg.append('svg:g').selectall('g'); append svg:g element svg element. ok it. selectall. don't it. paths there? created force layout? this.path = this.path.data(this.links); do? have no idea? then append paths. this.path.enter().append('svg:path') .attr('class', 'link') .style('marker-start', function (d) { return d.left ? 'url(#start-arrow)' : ''; }) .style('marker-end', function (d) { return d.right ? '

postgresql - Creating sequence of dates and inserting each date into query -

i need find data within first day of current month last day of current month. select count(*) q_aggr_data a.filial_='fil1' , a.operator_ 'unit%' , date_trunc('day',a.s_end_)='"+ date_to_search+ "' group a.s_name_,date_trunc('day',a.s_end_) date_to_searh here 01.09.2014,02.09.2014, 03.09.2014,...,30.09.2014 i've tried loop through i=0...30 , make 30 queries, takes long , extremely naive. days there no entry should return 0. i've seen how generate date sequences, can't head around on how inject days 1 one query by creating not series, set of 1 day ranges, timestamp data can joined range using >= < note in particular approach avoids functions on data (such truncating date) , because of permits use indexes assist query performance. if data looked this: create table my_data ("data_dt" timestamp) ; insert my_data ("data_dt") values (

sql - merge two queries with different where and different grouping into 1 -

sorry, asked question before , got answers realised made mistake query in question, if change question in original post make answers invalid i'm posting again right query time, please forgive me, hope acceptable. declare @temp table (measuredate, col1, col2, type) insert @temp select measuredate, col1, col2, 1 table1 col3 = 1 insert @temp select measuredate, col1, col2, 3 table1 col3 = 1 , col4 = 7000 select sum(col1) / sum(col2) percentage, measuredate, type @temp group measuredate, type i 2 inserts temp table, 2nd insert same columns same table, different type, sum(col1) / sum(col2) on temp table return result need per measuredate , type. there way merge these inserts , selects 1 statement don't use temp table , single select table1? or if still need temp table, merge selects 1 select instead of 2 separate selects? stored procedure works fine is, looking way shorten it. thanks. sure can. might start combining 2 queries inserts using union all (this va

python - Django decorator from middleware with different args per view function -

i have sso middleware in django project, need pass argument. in views.py file have different view functions decorated decorator_from_middleware_with_args have different arguments: sso_decorator = decorator_from_middleware_with_args(ssomiddleware) @sso_decorator(true): def index(): ... @sso_decorator(false): def view(): ... and here middleware class: class ssomiddleware: def __init__(self, some_arg=false): self.some_arg = some_arg def process_request(self, request): print self.some_arg when access index view via url, output in console is: some argument: false argument: true i have 2 questions here: why process_request function executed twice? why have different argument?

php - isset($_Post) not getting values from Mail Form -

so i'm trying send values contact form (contact.php) file send_form_email.php. reason i'm not getting values contact.php. i'd appreciate help! here's form code contact.php file: <form role="form" id="contactform" name="contactform" enctype='multipart/form-data' method="post" action="send_form_email.php"> <div class="form-group"> <label for="inputfname" style="color: #ecc444; text-shadow: 2px 2px #414141;">first name:</label> <input type="text" class="form-control" id="inputfname" placeholder="enter first name" maxlength="50" size="30"> </div> <div class="form-group"> <label for="inputlname" style="color: #ecc444; text-shadow: 2px 2px #414141;">last name:</label> <input type="text&quo

javascript - React component not re-rendering on state change -

i have react class that's going api content. i've confirmed data coming back, it's not re-rendering: var dealslist = react.createclass({ getinitialstate: function() { return { deals: [] }; }, componentdidmount: function() { this.loaddealsfromserver(); }, loaddealsfromserver: function() { var newdeals = []; chrome.runtime.sendmessage({ action: "finddeals", personid: this.props.person.id }, function(deals) { newdeals = deals; }); this.setstate({ deals: newdeals }); }, render: function() { var dealnodes = this.state.deals.map(function(deal, index) { return ( <deal deal={deal} key={index} /> ); }); return ( <div classname="deals"> <table> <thead> <tr> <td>name</td> <td>amount</td> <td>stage</td> <td>probability<

if statement - Open Specific RDP connection using "IF" or "GOTO" in Batch file -

i have tried multiple things , fails. having log in various terminal service rdp , want able control them .bat. following latest failed attempt. when run it, opens both connections. @echo off rem sets parameter network id. set /p server = "server> " set user = "user" set pass = "password" if "%server%" =="233" ( goto 233 ) else if "%server%" =="234" ( goto 234 ) rem rdp connection server 234 :234 cmdkey /generic:termsrv/rdc234 /user:%user% /pass:%pass% mstsc /v:rdc234 rem rdp connection server 233 :233 cmdkey /generic:termsrv/rdc233 /user:%user% /pass:%pass% mstsc /v:rdc233 pause @echo off rem sets parameter network id. set /p server="server> " set "user=user" set "pass=password" if "%server%"=="233" goto valid if "%server%"=="234" goto valid echo invalid server "%server%" specified goto end :val

pip - Configuring Sublime Text 3 for Python on Mac -

i've seen questions similar haven't found workable answer. i'm looking learn more python coding, i've been coding lot ruby, use python 3rd party modules don't seem have ruby equivalent. rvm , gems made 3rd party easy work with, there equivalent python? i've installed python through macports , homebrew, , have tried install 3rd party modules through macports ('sudo port install') , pip. although modules seem install successfully, can't non-standard modules run in sublime text. on sublime text side, managed python build creating new build system based on suggestions here "shell_cmd": "$project_path/vi_sys_pkgs/bin/python3 -u \"$file\"", "path": "$project_path/vi_sys_pkgs/bin", "file_regex": "^[ ]*file \"(...*?)\", line ([0-9]*)", "selector": "source.python" and using sublime-repl package. i've read virtualenv common way utilize 3rd party mo

httpconnection - Java HttpUrlConnection throws Connection Refused -

i know there several question regarding topic did't find answer in of them. i'm trying open connection local server keep getting connection refused. i have server running , tested connection browser , google app called postman , works. it's failing when opening connection if there nothing connect to. or maybe blocking connection? tested firewall , antivirus down, no luck. testing in postman url returns user should... if replace url " http://www.google.com " works fine. here code: import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import java.net.httpurlconnection; import java.net.malformedurlexception; import java.net.url; /** * * @author gabriel */ public class httpconnection { public httpconnection() { } public void makerequest() throws malformedurlexception, ioexception { string url = "http://localhost:8000/users/1"; url obj = new url(url); httpurlconnecti

vb.net - Error: Oledb transaction is completed, it is no longer available; -

Image
this question title matches other not scenario, here getting data form table , based on it, updating table b , inserting record in table c, make grouped these queries transaction in run time getting error, seems correct, worked on same scenario in c#.net , working fine first time trying apply in vb.net getting error appreciated the error in following line cmd = new oledbcommand(sql, con1, transaction) this code unnecessary: if con1.state con1.close() con1.open() your connection con1 associated transaction has closed transaction has ended.

c - Flex And Bison, detecting macro statements (newbie) -

i want teach flex & bison detect macro definitions in pure c. i'am adding function existing parser form here . parser good, lacks macro functionality. did add #include , pragma macros detection, selection macroses have problems, code in parser: macro_selection_variants : macro_compound_statement | include_statement | pragma_statement | macro_selection_statement | statement ; macro_selection_statement : macro_ifdef identifier macro_selection_variants macro_endif | macro_ifdef identifier macro_selection_variants macro_else macro_selection_variants macro_endif | macro_ifndef identifier macro_selection_variants macro_endif | macro_ifndef identifier macro_selection_variants macro_else macro_selection_variants macro_endif ; statement declared so: statement : labeled_statement | compound_statement | expression_statement | selection_statement | iteration_statement | jump_statement ; and

html - Change order of nav items in responsive design -

i using cascade framework , have simple header logo, select, , link external site. my fiddle here the layout if fine in desktop mode. in responsive mode, looks like: --------------------------------------------- company name --------------------------------------------- volvo --------------------------------------------- menu here --------------------------------------------- whereas i'd following in responsive mode: --------------------------------------------- company name menu here --------------------------------------------- volvo --------------------------------------------- these answers suggest using flexbox or jquery. can't use flexbox because need ie8 support. i'd rather not have resort jquery since seems should rather straight forward css solution. answer on page shows ton of css i've been trying adapt use case , didn't fix issue either. how using absolute positioning? .menuhere { position:absolute;

database - strange MySQL join query results with aggregate functions -

Image
i wrote following join query report using aggregate functions select users.id, sum(orders.totalcost) bought, count(comment.id) commentscount, count(topics.id) topicscount, count(users_login.id) logincount, count(users_download.id) downloadscount users left join orders on users.id=orders.userid , orders.paystatus=1 left join comment on users.id=comment.userid left join topics on users.id=topics.userid left join users_login on users.id=users_login.userid left join users_download on users.id=users_download.userid group users.id order bought desc but don't know why following output? the result of aggregate functions multiplied each other!!! i don't know why? for example last row expected following result 821 | 48000 | 63 | 0 | 10 | 10 the result of executing explain query shown below one reason type of result using left joins users table , result set may contains duplicate rows each user getting count more expec

virtual machine - Vagrant box doesn't start (Connection timeout) -

i try start vagrant box on windows 8.1 (64 bit) system doesn't work. i'm using setup on 2 mashines without problems. this get: $ vagrant bringing machine 'default' 'virtualbox' provider... ==> default: importing base box 'puphpet/ubuntu1404-x64'... ==> default: matching mac address nat networking... ==> default: checking if box 'puphpet/ubuntu1404-x64' date... ==> default: setting name of vm: vagrant-lamp_default_1411285570202_20465 ==> default: clearing set network interfaces... ==> default: preparing network interfaces based on configuration... default: adapter 1: nat default: adapter 2: hostonly ==> default: forwarding ports... default: 80 => 8080 (adapter 1) default: 22 => 2222 (adapter 1) ==> default: running 'pre-boot' vm customizations... ==> default: booting vm... ==> default: waiting machine boot. may take few minutes... default: ssh address: 127.0.0.1:2222 defau

Select2 "No Matches found" on XPAGES partial update -

i have downloaded demos.nsf , try learn select2 http://www.bootstrap4xpages.com/bs4xp/demos.nsf/select2.xsp everything run have found problem select2 didn't trigger xpages server side event when return "no matches found" here how produce problem : i have input hidden , computed text binding document datasource i have button partial update computed text that input hidden used select2 scriptblock run xpages type name (e.g. patrick) , select name click button , computed text display selected name type keyword "qqqqqqq" , select2 results "no matches found" click button again, , computed text "blank" redo number 6 dan 7 again, , computed text still "blank" , didn't display "patrick" name how solve problem ? here code : <xp:inputhidden id="inputhidden1" value="#{document1.coba}"/> <xp:scriptblock id="scriptblock4"> <xp:this.value><![cdata[

c++ - Adding Chars to a Stringstream -

i trying add numbers char array stringstream object. code is: char[50] buffer = '<15>'; stringstream str; int page; str << buffer[1]+buffer[2]; str >> page; page should hold integer value of 15, instead holds value 102. idea wrong code? change str << buffer[1]+buffer[2]; to str << buffer[1] << buffer[2]; the way code written, add characters '1' , '5', equal 49 , 53 respectively, 102 , output stream.

Efficiently access most recently accessed MongoDB entries? -

i'm making service similar requirements url shortener; need store bunch of unique hashes , corresponding strings. tricky part need order them access date can retrieve last 10 accessed entries (and next 10 after that, etc.) everything i've come far grossly inefficient. what's best way store queue this? one solution: add accessed_at field update when url accessed. index it, can find urls sorted accessed_at field. you alternately use capped collection holds accessed urls; each time url accessed, insert capped collection. give rolling window of recent accesses. won't deduplicate, though, if url particularly popular, show in list multiple times.

javascript - set groupt of radion value jquery -

i have group ooa radion buttons defined so <input type="radio" name="required[status]" id="status" value="1">yes </label> <input type="radio" name="required[status]" id="status_1" value="0"> no </label> <input type="radio" name="required[status]" id="status_2" value="2">maybe </label> this stores value 0,1,2 in field status in db later, value db 1, how use jquery check appropriate radio button? if trying check radio button element value can jquery attribute selector. click me you can element value this: $('[value=value_from_db]').prop("checked", true);

abstract syntax tree - Python AST module can not detect "if" or "for" -

i trying restrict user-provided script, following visitor: class syntaxchecker(ast.nodevisitor): def check(self, syntax): tree = ast.parse(syntax) print(ast.dump(tree), syntax) self.visit(tree) def visit_call(self, node): print('called call', ast.dump(node)) if isinstance(node.func, ast.call) , node.func.id not in allowed_functions: raise codeerror("%s not allowed function!"%node.func.id) elif isinstance(node.func, ast.attribute) , node.func.value.id not in allowed_classes: raise codeerror('{0} not calling allowed class'.format(node.func.value.id)) elif isinstance(node.func, ast.name) , node.func.id in allowed_classes: raise codeerror('you not allowed instantiate class, {0}'.format(node.func.id)) else: ast.nodevisitor.generic_visit(self, node) def visit_assign(self, node): print('called assign', ast.dump(n

Remove element from Array Java -

i making tiny little program should able select random element put array using random of course (for practice purposes) , when element in array has been chosen @ random. want remove element in array, how remove element in array easiest way? its thing want know. got else sorted. it's removing element has chosen (the random takes random number between 0 , amount of elements in array, if chooses 0, take first element in array, , on) you can use arraylist support remove or add function, resizable array.

XBee AT communication between PC and Arduino -

i need send data (an integer) arduino c program on pc. know connection fine, because x-ctu works perfectly. need in @ mode don't know how start. if you're using xbee modules in @ mode, isn't different you'd have direct serial cable connection between arduino , pc. sample programs demonstrating serial communications both platforms. having connection working x-ctu excellent starting point, since have confirmed radio modules communicating correctly. on pc, might want @ open source xbee host library on github. includes sample program called "xbee_term" demonstrates simple serial terminal using xbee in @ mode. has layered api allow easy use of xbee modules in api mode -- need use if pc going communicate multiple arduino nodes running in @ mode. as sending int , can use sprintf() format string send on wireless link, , strtol() convert int on pc end.

c++ - Not able to use the loaded Image data properly -

i load image raw data , use qimage::format_monolsb format while loading. try write file, , image in b&w mono color format. ok. what way image out of in color format ? eg: if want color while portions particular color, how do ? i tried create qimage using qimage::format_argb32_premultiplied , , used painter draw 1 got above using pen/brush. not seem work. suspect there compatibility issue between formats. colorimage = qimage(qrect(0, 0, w, h), qimage::format_argb32_premultiplied); _painter.begin(&blockimage); _painter.setpen(qt::blue); _painter.drawimage(qrect(0, 0, w, h), blockimage, aboveimage); _painter.end(); i tried change loading code use color format (format_argb32_premultiplied ), not seem work either. no image in output. you're drawing blockimage on blockimage . think want paint on colorimage instead: _painter.begin(&colorimage); anyway, use qimage::converttoformat , pass in color table instead.

sql server - How can I update the data in a base SQL table based on data in another table? -

i have table use store data. table populated when user clicks save on grid on client system. here made simple example. table called tablea. client screen shows 5 rows , when user clicks save translated 5 inserts: create table [dbo].[tablea] ( [ida] int identity (1, 1) not null, [valuea] char(10) not null ) insert tablea values (1, 'one') insert tablea values (2, 'two') insert tablea values (3, 'three') insert tablea values (4, 'four') insert tablea values (5, 'five') go now user on client changes data in grid , read latest data temp table. here simulate tableb create table [dbo].[tableb] ( [idb] int identity (1, 1) not null, [valueb] char(10) not null ) insert tableb values (1, 'one') insert tableb values (3, 'newthree') insert tableb values (4, 'newfour') insert tableb values (5, 'five') go can suggest how can use new data in tableb update rows in table

Cordova modifying plist -

i have following plugin.xml <platform name="ios"> <config-file target="*-info.plist" parent="/*"> <key>uistatusbarhidden</key> <string>yes</string> <true/> <key>uiviewcontrollerbasedstatusbarappearance</key> <false/> <key>uifilesharingenabled</key> <true/> </config-file> </platform> i'm trying modify ios app's plist has following: uistatusbarhidden set yes uistatusbarhidden set yes uiviewcontrollerbasedstatusbarappearance set no the above code doesn't seem work. ideas should doing?

scala - throw Throwable within \/.fromTryCatch - and align method types correctly -

i have following existing method: def test: \/[throwable, person] = { \/.fromtrycatch { //existing logic has potential throw exception (from calls .toint) etc //now via following comprehension want combine throwable return type \/[throwable,person] { p <- q.firstoption.\/>(new throwable("can't find record person id = " + id)) } yield p } } which produces following error: type mismatch; found : scalaz.\/[throwable,person] (which expands to) scalaz.\/[throwable,person] required:person how align return type of for-comprehension type of def test ? fromtrycatch expects value evaluates person , may throw exception. so don't need wrap exception in \/ , can throw exception in fromtrycatch block , caught , wrapped automatically. alternatively can drop fromtrycatch , since you're materializing exceptions in \/[throwable, person] , e.g. def test : \/[throwable,person] = { p <- q.firstoption.\/>(new thro

json - Trying to get data from URL returns data is nil in objective c -

i currentley trying retrieve data link: http://steamcommunity.com/market/priceoverview/?country=us&currency=3&appid=730&market_hash_name=%e2%98%85%20bayonet i want data link outputs when go , click it. here current code: nsdata *data = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:@"http://steamcommunity.com/market/priceoverview/?country=us&currency=3&appid=730&market_hash_name=★%20bayonet"]]; nsdictionary *test = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; nslog(@"%@", test[@"lowest_price"]); but currentley returns error: *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'data parameter nil' i think has star involved in url string, have solution this? your original url, in example code, malformed. first, here's code works: #import <foundation/foundation.h> int main(int argc, char *argv[]) {

java - Using answer in if -

java new me, , ran problem. code: string answer; system.out.println("choose day"); answer = tastatur.nextline(); if(svar.equals("saturday")) system.out.println("saturday"); basically, want use answer in if statement. not work, , don't understand why. help? you looking @ wrong variable. if( answer.equals("saturday") ){ system.out.println("saturday") } what's logic? reading user entering answer variable. in code checking svar variable while should checking answer variable. if indeed user entered saturday, print on screen. else, not. equalsignorecase() better method use because saturday , saturday different in sense 1 has capitalized s , other not. equals() treat them different. you have said java new you. hope initializing tastatur variable as: bufferedreader tastatur = new bufferedreader(new inputstreamreader(system.in)); and using import java.io.* in program. as aside

java - Speed Up Hibernate Initialization -

i'm having java ee application runs on jboss 7. in order tdd, i'm setting embedded tests use arquillian embedded weld , h2 embedded database. this works fine, initial startup of hibernate takes considerable amount of time (5-10 seconds) , haven't included jpa entities yet. have tried use persisted oracle db instead avoid table creation, doesn't make of difference. the main problem seems hibernate goes through entities , validates , prepares crud methods, named queries , on. is there way tell hibernate lazily when needed (or not @ all)? of time, there subset of entities , queries involved in test case, i'd happily trade in execution time start-up time while implementing. any ideas? i know use subset of entities, it's difficult have relations other entities not needed in test context. or there easy way 'deactivate' such relations generate subsets of database? clarification it seams it's not clear problem is, i'll try clarify: i

html - Stop user-selection in Bootstrap navbar -

i prevent user-selection possible on boostrap navbar , such : http://getbootstrap.com/examples/navbar-fixed-top/ how stop user-selection ? i tried user-select: none; fails if ctrl-a. note : don't want stop user copy text on page, want provide better user experience avoiding selection of navbar elements. you this: bootply - demo .navbar { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; } more info: mozilla mdn user-select css-tricks user-select solution 2: disable user selection when press ctrl+a you set ::selection background color none bootply - demo div.navbar *::-moz-selection { background: none !important; } div.navbar *::selection { background: none !important; } .navbar { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; }

php - how to retrive customer orders in magento api V1 -

i using magento api v1. want retrieve specific customer orders. using order.list method. in method filter not working.it giving me complete order list. don't know mistaking. here code $client = new soapclient('http://magentohost/api/soap/?wsdl'); $session = $client->login('apiuser', 'apikey'); $filter = array('filter' => array(array('key=' => 'customer_id', 'value' => 210))); $result = $client->call($session, 'order.list',$filter); var_dump ($result); finally got way retrieve customer orders $client = new soapclient('http://magentohost/api/soap/?wsdl'); $session = $client->login('apiuser', 'apikey'); $customer_id = 210; $result = $client->call($session, 'order.list'); if($result) { foreach($result $val) { if($customer_id==$val['customer_id']) { $res[] = $val; } var_dump ($res); }

floating point - Are there errors in purely integer multiplication? -

i know there errors in floating point multiplication there errors in purely integer multiplication? let's i'm using python, how large of integers , b can compute a*b , answers right? wall? same addition? there no error in (correct) floating-point multiplication. rounding may occur, that’s not error, that’s defined behavior of arithmetic. colloquially called “rounding error”, not “error” in normal sense of word. there no error in (correct) integer multiplication. in languages, overflow may occur, that’s not error, that’s defined behavior of arithmetic*. in python in particular, overflow not occur integer multiplication**; result equal “mathematically exact” result, , silently promoted bignum if necessary. same holds true addition. [*] there languages overflow produces trap or throws exception; again, however, that’s defined behavior in languages. [**] long result isn’t large storage cannot allocated.

Java help: make image move across the screen -

i've been having trouble quite while trying make space shooter no avail, i'm trying make bullet move across screen in space invaders etc when player presses space bar bullet should appear player's x position , move right across screen. import java.awt.color; import java.awt.graphics; import java.awt.image; import java.awt.event.keyadapter; import java.awt.event.keyevent; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import javax.swing.imageicon; import javax.swing.jframe; public class game extends jframe{ boolean run = true; boolean fired = false; image player; image bullet; int playerx = 100; int playery = 200; int bulletx; int bullety; public game(){ //load images: imageicon playeri = new imageicon("c:/users/dan/workspace/shooterproject/bin/shooterproject/ship.png"); player = playeri.getimage(); imageicon bulleti = new imageicon("c:/users/dan/workspace/shooterproject/bin/shooterproject/bullet.png&

r - Using a loop in ggplot2 -

i trying create multiple boxplots in ggplot. need split continuous variables nominal variable (school). want omit single na's in data-frame dataso. want create boxplot every column , have name of column label. when use following code don't error message, no plots generated. ideas? for(i in 1:length(dataso)) { boxplot <- ggplot(na.omit (dataso), aes(school,i)) + geom_boxplot() + labs(x = "school", y = names(dataso[i])) } i able generate 1 boxplot using code: box2 <- ggplot(na.omit (dataso), aes(school, soirglobal)) box2 + geom_boxplot() + labs(x = "school", y = "soirglobal") i great boxplots 9 other variables in dataso dataso <- subset(datafull, age >= 18, select=c(age, school, race, soir1:soir9))

php - How do I distinguish between button clicks in a form? -

Image
so i'm creating database website , want create admin section allows add or delete table. here snapshot of want achieve... in php file have if($_post['delete_category']) correctly gets delete button clicks, i'm not sure how distinguish delete button clicked. i'm sure simple solution, i'm stuck. thanks! you can discern button submitted following markup (based on example fetched results db): <?php if(isset($_post['delete_category'])) { $id = $_post['delete_category']; // value="1" or value="3" goes in here echo $id; } ?> <form method="post" action=""> <table border="1"> <tr> <th>id</th><th>name</th><th>delete</th> </tr> <tr> <td>1</td> <td>senior pictures</td> <td><button typpe="submit&

google spreadsheet - Highlight cell if same value present in another sheet's cell -

Image
example - client has master list of client's hosted domains in sheet 1. client keeps list of actual record verified domains in use in sheet 2. what need highlight domains in sheet 2 match domains in sheet 1 using color, , highlight domains in sheet 2 different color if not appear in sheet 1. (domains in master list match record entered domains in sheet 1 appear in green, domains not match list appear in red) the column names on both sheets "domain". add helper columns in each, h, formulae like: =--countif(sheet1!b:b,b1) >0 copied down suit (assuming domains in columnb - change sheet1 suit actual sheet names). then apply conditional formatting rules of: =h1 and: =h1<>true to ranges b:b with colours suit. correction the above based on misreading question (i thought highlighting apply each sheet): instead please try, in h1 of sheet2 , copied down suit: =--countif(sheet1!b:b,b1) >0 and these 2 rules: whe

How to use Iterator/Iterable in Java? -

i want make iterator() method in prison class that, want make new class contain boolean hasnext() , prisoncell next() methods of iterator implement interface. package iterator; import java.util.iterator; public class driver { public static void main(string args[]) { prison prison= new prison(5); iterator<prisoncell> iter; prison.addcell(new prisoncell("a", 3)); prison.addcell(new prisoncell("b", 9)); prison.addcell(new prisoncell("c", 6)); iter= prison.iterator(); //i want make iterator() method in prison class while (iter.hasnext()) system.out.println(iter.next()); } /**output here be: name: a, numprisoners: 3 name: b, numprisoners: 9 name: c, numprisoners: 6 **/ } package iterator; public class prisoncell { //how implement iterable<> iterface here? private string name; private int numprisoners; public prisoncell(string name, int numprisoners) { this.name=

java - Concatenate multiple commands -

how can manipulate regular expression string onecmd = "([0-9]+\\.[tcm]{1}\\#.+\\#[wsn]{1})"; to avoid matching "100.m#testvalue#w100.m#testvalue#w" but allow matching 100.m#testvalue#w ? because in end want there can multiple commands separated | string regex = "^(" + onecmd + "$|" + onecmd + "\\|{1}" + onecmd + "$)"; so valid commands are: cmd cmd|cmd1|cmd2|... not ending '|' !! but first problem if concatenate 2 or more commands still valid. i think readable way first split on | , apply regex allows 1 match: ^[0-9]+\\.[tcm]#[^#]*#[wsn]$ if want find matches separated | and/or start/end of string, can positive lookahead assertions instead of ^ , $ anchors: (?<=^|\\|)[0-9]+\\.[tcm]#[^#]*#[wsn](?=$|\\|)

.htaccess - Rewrite Rule from Apache to Nginx -

can me rewriting this? have these rules: rewritecond %{http_user_agent} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|showyoubot|outbrain|pinterest [nc,or] rewritecond %{query_string} _escaped_fragment_ rewriterule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent))(.*) /api/prerender/$2 [p,l] and need rewritten nginx. basically, let's assume url http://example.com/?_escaped_fragment_=/item/123 should rewritten to http://example.com/api/prerender/?_escaped_fragment_=/item/123 i hope understand. try: location / { if ($http_user_agent ~* "baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|showyoubot|outbrain|pinterest") { rewrite ^/(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.p

java - ajaxform not submit the value if attachment is not available -

i beginner in java , go create 1 web application. submitting 1 form controller using ajaxform . there few elements , 1 of them type=file . my controller method following @requestmapping(value = { "/addreplies" }, method = { org.springframework.web.bind.annotation.requestmethod.post, org.springframework.web.bind.annotation.requestmethod.get } ) @responsebody public map<string,object> addreplies( @valid @modelattribute("replies") replies replies, bindingresult result, httpservletrequest request, httpservletresponse response,locale locale,principal principal, @requestparam(value = "filedata2",required=false) commonsmultipartfile filedata2[]) throws servletexception, ioexception { //perform opraton } this work if there attachment available in data otherwise not go method. if remove @requestparam(value = "filedata2",required=false) commonsmultipartfile f

android - searchManager.getSearchableInfo(getComponentName()) returns null only in test -

i have activity searchview under test, works expected tests fail. @override protected void setup() throws exception { super.setup(); intent intent = new intent(getinstrumentation().getcontext(),startactivity.class); startactivity(intent, null, null); } @smalltest public void testshouldcreatestartactivity() { assertnotnull(activity); } the test fails because of searchmanager.getsearchableinfo(activity.getcomponentname()) returning null. searchmanager searchmanager = (searchmanager) activity.getsystemservice(context.search_service); searchableinfo searchableinfo = searchmanager.getsearchableinfo(activity.getcomponentname()); very frustrating have working app code tests fail. i changed test class activityunittestcase activityinstrumentationtestcase2 , works. read more differences here : difference between activityunittestcase , activityinstrumentationtestcase2

c - pointer cast on embedded systems, byte pointer on 32bit variable via pointer cast -

i have read out bytes of uint32_t variable, , have seen kind of implementation colleague of mine. question is, if behaviour of code-example reliable on "nearly every" 32bit microcontroller. supposable work on every 32bit microcontroller or platform-specific behaviour relying on? p.s.: endianness of system shall not considered in example. uint8_t byte0=0; uint8_t byte1=0; uint8_t byte2=0; uint8_t byte3=0; uint8_t *byte_pointer; //byte_pointer uint32_t *bridge_pointer;//pointer_bridge between 32bit , 8 bit variable uint32_t var=0x00010203; bridge_pointer=&var; //bridge_pointer point var byte_pointer=(uint8_t *)(bridge_pointer); //let byte_pointer point bridge_pointer byte0=*(byte_pointer+0); //saves byte 0 byte1=*(byte_pointer+1); //saves byte 1 byte2=*(byte_pointer+2); //saves byte 2 byte3=*(byte_pointer+3); //saves byte 3 thanks in advance byte0=*(byte_pointer+0); //saves byte 0 this line (and following o

View optimization in postgresql -

Image
i have aggregate last 'reading' each table in single view in order optimize database access i've noticed executing many single queries cost less using view i'm wondering if there wrong in view or can optimized. here tables: create table hives( id character(20) not null, master character(20) default null::bpchar, owner integer, [...] constraint hives_pkey primary key (id), constraint hives_master_extk foreign key (master) references hives (id) match simple on update cascade on delete set null, constraint hives_owner_extk foreign key (owner) references users (id) match simple on update cascade on delete cascade ) create table dt_rain( hive character(20) not null, hiveconnection integer, instant timestamp time zone not null, rain integer, constraint dt_rain_pkey primary key (hive, instant), constraint dt_rain_hive_connections_extk foreign key (hiveconnection) references hives_connections (id) match simple