Posts

Showing posts from March, 2013

php - Multiple MySQL Queries in ONE While Ignoring Duplicate Matched IDs -

i asked question combine multiple mysql queries on same table one , received noteworthy answer @paul griffin . as stated in other question linked above, have multiple queries combined 1 query. these queries consist of exact matching , broad matching search terms. i searching through posts on wordpress website. keep things simple, i'm looking through following columns in posts table: post_title (article title), post_name (article url slug), , post_excerpt (article summary). just keep things simpler sake of question, let's have search term of "floor finish", , i'm searching through column post_title . as stated earlier, i'm looking exact matches , broad matches. so 3 searches placed: floor finish floor finish that produce query like: ( select `id`, `post_title` `tps_3_posts` `post_status` = 'publish' , `post_title` '%floor finish%' ) union ( select `id`, `post_title` `tps_3_posts` `post_status` = 'publish'

how to make a loop in less css -

i'm starting use preprocessor css in case less css. i'm trying achieve loop padding. example less.org modified .generate-pad(10); .generate-pad(@n, @i: 1) when (@i =< @n) { .padd-top-@{i} { padding-top: (@i * 100px / @n); } .generate-pad(@n, (@i + 1)); } outputs following when compiled .padd-top-1 { padding-top: 10px; } .padd-top-2 { padding-top: 20px; } .padd-top-3 { padding-top: 30px; } .padd-top-4 { padding-top: 40px; } .padd-top-5 { padding-top: 50px; } .padd-top-6 { padding-top: 60px; } .padd-top-7 { padding-top: 70px; } .padd-top-8 { padding-top: 80px; } .padd-top-9 { padding-top: 90px; } .padd-top-10 { padding-top: 100px; } but trying replace .pad-top-@{i} variable can call later. how can achieve if possible in less.

dynamic variable names in matlab -

i wish expand structure ( bac ) number of fields structure ( bt ). names of these fields contained in cell array ( adds ) strings. this have (and doesn't job, explaining post): for i=1:numel(adds) eval(genvarname('bac.',adds{i})) = eval(strcat('bt.',adds{i})); end i tried using sprintf , did not seem work me. feel confident 1 of knows how it, since feel should rather easy. the best way of doing use dynamic field names : for i=1:numel(adds) bac.(adds{i}) = bt.(adds{i}); end

SQL Server Reporting Services installed with errors -

i trying install sql server reporting services on 64 bit laptop. however other software packages has installed rs tool has not been installing. here posting error log installation has generated. please tell me going wrong. overall summary: final result: sql server installation failed. continue, investigate reason failure, correct problem, uninstall sql server, , rerun sql server setup. exit code (decimal): -2068052377 exit facility code: 1212 exit error code: 1639 exit message: sql server installation failed. continue, investigate reason failure, correct problem, uninstall sql server, , rerun sql server setup. start time: 2015-04-09 23:21:10 end time: 2015-04-09 23:25:55 requested action: install log failure: c:\program files\microsoft sql server\100\setup bootstrap\log\20150409_232028\sql_rs_cpu64_1.log exception link:

rabbitmq - Message Ordering Across Queues -

Image
i have scenario in rabbitmq setup i'm curious how solve. diagram below illustrates (exchanges , queues removed succinctness): scenario producer creates message a(1), received top consumer, begins processing message. producer creates message a(2), received bottom consumer (assuming both consumers on round-robin exchange). the bottom consumer publishes message b(2), put message b consumer's queue the poor slow top consumer finishes , emits message b(1). problem if assume b consumer cannot made idempotent, how ensure result of both b messages applied in correct order? i had thought of using timestamp applied initial publish of message a, , having consumer maintain timestamp of last change, rejecting timestamps before time, works if each message causes exact same kind of change , requires lot of tracking. other ideas how approach appreciated. thanks! i not sure specific rabbitmq here, idea timestamps sounds start if have single producer. the produ

excel - VLOOKUP #N/A error -

i'm wondering have done wrong #n/a error i have k21 show agent's name worked on ticket appeared in k20 . have agent names listed in b3:b18 . columns have: c total, d type , e subtotal. ticket numbers logged column f3 , g , h , on each agent k20 has =min(f3:xfd18) determine oldest ticket. k21 has =vlookup($k$20,b2:g18,3,false) show agent's name logged oldest ticket. i'm bit confused you're asking sounds might using formula wrong. if wanting return agent's name oldest ticket make sure columns in correct order (a-lookup value,b-agent name,c-other variable). using format can try k21=vlookup($k$20,a2:b18,2,false) ----where a2:a18 has value looking , 2 second column (b) , has agent's name.

run nutch 1.8 or 1.9 as a hadoop job -

if understand correctly, can not run nutch 1.8 , 1.9 hadoop job, because these versions not have crawl class serves wrapper crawl steps. means there no 1 class can specify in hadoop call run whole job. in nutch 1.7, used org.apache.nutch.crawl.crawl class. am missing something? 1 figure out way around this? your understanding wrong. should use script bin/crawl. in each step, should see corresponding class should call (in case want use outside crawl script). in addition, far know class quoted deprecated.

python 3.x - python3 interpret ascii string as unicode string -

i have text file, when opened, looks this: \xf0\x9f\x98\x81 \xf0\x9f\x98\x82 \xf0\x9f\x98\x83 \xf0\x9f\x98\x84 \xf0\x9f\x98\x85 the hexdump looks this: 0000000 5c 78 46 30 5c 78 39 46 5c 78 39 38 5c 78 38 31 0000010 0a 5c 78 46 30 5c 78 39 46 5c 78 39 38 5c 78 38 0000020 32 0a 5c 78 46 30 5c 78 39 46 5c 78 39 38 5c 78 0000030 38 33 0a 5c 78 46 30 5c 78 39 46 5c 78 39 38 5c 0000040 78 38 34 0a 5c 78 46 30 5c 78 39 46 5c 78 39 38 i trying print strings in python though unicode strings. following things fail: with open ("file") f: row in f: x = row.split() in x: print(i) print(bytes(i, encoding='utf-8')) print(bytes(i, encoding='utf-8').decode('unicode-escape')) prints \xf0\x9f\x98\x81 b'\\xf0\\x9f\\x98\\x81' ð \xf0\x9f\x98\x82 b'\\xf0\\x9f\\x98\\x82' ð \xf0\x9f\x98\x83 b'\\xf0\\x9f\\x98\\x83' ð \xf0\x9f\x98\x84 b'\\xf0\\x9f\\x98\\x84' ð \xf0\x9f\x98

java - i want to hide the first frame when the new frame window appear -

i want hide previous window frame when new window appear after pressing submit button,how hide previous window or close without pressing cross button enter code here public static void main(string[] args) { jframe frame = new jframe("project format creator"); jbutton btn5 = new jbutton("submit"); jpanel panel = new jpanel(new gridbaglayout()); gridbagconstraints cst = new gridbagconstraints(); cst.fill = gridbagconstraints.horizontal; cst.gridx = 0; cst.gridwidth = 1; cst.weightx = 0.1; cst.gridy = 8; //third row panel.add(btn5,cst); btn5.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { jframe frame1 = new jframe("project format creator"); frame1.setdefaultcloseoperation(jframe.exit_on_close); frame1.setsize(300,300);//int width int height frame

php - CodeIgniter Check if database is wrong -

i'm working on small application connects database , retrieves data tables. need display caller wasn't able connect specified host. how can accomplish that? i've tried use snippet doesnt work: define('error_str', 'error: '); # ... if ($this->db->_error_number() or $this->db->_error_message()) { die(error_str . $this->db->_error_number() . ': ' . $this->db->_error_message()); } in logs listed: error - 2015-04-09 15:18:19 --> severity: warning --> mysqli_connect(): (hy000/2005): unknown mysql server host 'localhosta' (2) but need check in runtime (after trying connect, obviously) if database config params wrong (host/user/password) , echo error msg caller. $this->db->_error_number() , $this->db->_error_message() not giving me error msgs. ideas? hope clear enough. thanks. edit: here's db config: $db['default']['hostname'] = 'localhost'; $db['default

java - Writing files to windows machine from Broker (Unix) -

i have requirement create/append file on windows machine websphere message broker toolkit v 7.0 (unix). unix user not have permissions access windows machine. wanted write java code can create or append file other credentials has access windows machine (not ftp , it's shared drive in same network different group). i found solutions client don't want use whatever constraints. creating nfs mount point , write mount point location. use samba framework. can suggest other ? thanks in advance. run websphere mq managed file transfer agent on windows host. broker can send files agent write them local filesystem on windows host. capability built modern versions of mq.

android - Visual Studio Cordova Hybrid App "release" vs "distribution" -

please explain difference between release vs distribution modes when running hybrid app project visual studio apache cordova in visual studio, in solution configurations drop-down have: debug release distribution from can see " release " pushes app usb-connected android device, while "distribution" compiles it, , displays empty command prompt screen adb.exe (but not push app device). i test "distribution" version. thanks! it's ios apps. before being submitted app store, ios apps have signed distribution certificate. distribution configuration uses distribution certificate instead of development certificate used debug , release builds. the distribution configuration seems have been removed in released rc, release taking place. documentation stated: when building debug or release configuration, visual studio remote agent selects first valid ios development signing identity installed on mac. when building distribution

How do I scan a text file for certain characters in java? -

i have take text file: ulric schwartz ullamcorper@quisque.ca fringilla donec pc urna convallis erat jesse conrad nunc@eunulla.edu magna praesent interdum incorporated et netus et ethan eaton cursus@nullam.co.uk sed consequat auctor institute posuere vulputate lacus griffin stephenson habitant@mattis.com purus sapien institute auctor non feugiat alan howell lorem@penatibusetmagnis.com mi limited non sollicitudin sawyer stokes ornare@utmiduis.com ut institute nibh phasellus nulla nigel sanford adipiscing@euerat.org lacus varius corp integer vitae nibh and scan email addresses, meaning @ followed atleast 3 characters, period, , atleast 2 more characters. understand how scan file: while(fscan.hasnext()) { //scan emails goes in here } but i'm not sure how scan email. have: import java.io.*; import java.util.scanner; public class lab11_emena { public static void main(string[] args) { scanner cscan = new scanner(system.in); system.out.printl

jquery - Alternatives to Sitemesh to help layout footers/headers in a Spring MVC app -

in our current project use sitemesh , planning change ui in bootstrap, there alternative sitemesh using angular js or using new technologies ? the reason me ask , on each request header , footer , center page reload, new technologies avoid reloading footer , header , center page reloads

database - Inserting and updating the records in coredata using iOS -

when ios mobile app launches first time, based on user clicks connecting server. let me explain in detail: initially connecting server, parse information , store array. so,am able insert array of elements in database. now app launches next time, base on user clicks able to different array of elements. now able retrieve records database , need check latest records has been inserted in database or not? please let know, how insert records not available in database. do use coredata magicalrecords? here code snippet of check if there record existing , saving data: uiapplication *application = [uiapplication sharedapplication]; __block uibackgroundtaskidentifier bgtask = [application beginbackgroundtaskwithexpirationhandler:^{ [application endbackgroundtask:bgtask]; bgtask = uibackgroundtaskinvalid; }]; [magicalrecord savewithblock:^(nsmanagedobjectcontext *localcontext) { chatmessage* chatmessage = [chatmessage mr_findfirstbyattribute:@"messagei

mysql - Determine if month of date falls on a quarter of date -

i need write sql determine if current month based on quarter specified date. if give '2015-04-09', function should determine if month equal 1, 4, 7, or 10. if give '2015-05-09', 2, 5, 8, 11. etc... it work best if entire solution self contained within select statement. i'm not quite sure how approach , couldn't find fit situation. don't care day or year, need verify month. it looks want know when expression true: (mod(extract(month sysdate()), 3)) = (mod(extract(month <input date>), 3))

mysql - Exclude duplicate values in one table and return the remaining -

i have table so: table: album_image(album_id, image_id) album_id image_id ---------------------------- 87 2326 87 2325 86 2325 85 5689 89 56 having 2 album id's (let's 87 , 86), want extract image_id not in 2 albums. so, example, if have album_id 87 , 86, should return image_id : 2326 how go doing query? as per requirement looks need find image either on album_id 86 or 87 not both, , done using group by , having count select image_id album_image album_id in (87,86) group image_id having count(*)=1 ;

excel - Stuck in infinite loop searching through text boxes -

my code searches through entire worksheet searching text box matches phrase entered. pressing yes goes next response phrase no copy current text box. problem not search through entire work sheet gets stuck looping through 1 worksheet until press no copy. new vba please thankful. sub findresponse() dim rstart range dim shp shape dim sfind string dim stemp string dim response dim obj new dataobject dim ws worksheet sfind = inputbox("search for?") if trim(sfind) = "" msgbox "nothing entered" exit sub end if set rstart = activecell each ws in worksheets each shp in activesheet.shapes shp stemp = shp.textframe.characters.text if instr(lcase(stemp), lcase(sfind)) <> 0 shp.select response = msgbox( _ prompt:=shp.name & vbcrlf & _ stemp & vbcrlf & vbcrlf & _ "yes see ot

ios - Unwind Segues are not calling "prepareForSegue" in my mother view -

mother view -> child view (push) when perform manual unwind segue mother view, mother view's "prepareforsegue" not hit. override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { println(segue.identifier) //unwind segues don't print! } @ibaction func unwindtotabbar(segue:uistoryboardsegue){ } the prepareforsegue unwind needs in child viewcontroller, because preparing return trip. destinationviewcontroller in case mother viewcontroller.

python - How to change record of object in Django's model instantly? -

i have class , objects, want when save new record, django checks if "is_it_true" false or true, if true change default value of "number" new value corresponded count of objects have "is_it_question" plus one; , if false, default of "number" remain defaut(100). should do? class typefourchoice(models.model): question_choice = models.foreignkey(typefour) is_it_question = models.booleanfield(default=false) number = models.positiveintegerfield(blank=false, default=100) word_or_words = models.charfield(default='', blank=false, max_length=20) timestamp = models.datetimefield(auto_now_add=true) def __str__(self): return "{}".format(self.question_choice) @classmethod def save(cls, *args, **kwargs): no = cls.objects.exclude(number=100).count() if no none: pass else: clss = cls.objects.get(???????) if clss.is_it_question:

nat - How can I get SNAT to work with ARP requests using iptables? -

problem statement have 2 nodes (n 1 , n 2 ) on separate networks. both connect separate interfaces on common node (n c ). need ping n 1 n 2 . reference : n 1 : ip address 172.1.1.96/24 n 2 : ip address 10.1.1.33/24 n c : lan1 10.1.1.1/24       lan2 172.1.1.1/24 ______________________________________________________________ |                                              /          n c          \                                                     | | n 1 <------>| switch 1 |<-------> | lan2 <--> lan1 | <-------> | switch 2 | <-------> n 2 | | _______________________\___________/__________________________ | attempts i've added routing rule n 1 send 10.1.1.0/24 packets 172.1.1.1 (n c ), , following iptables rule n c : iptables -t nat -a postrouting -s 172.1.1.96 -o lan1 -j snat --to 10.1.1.79 i send ping n 2 n 1 . n 2 receives ping , sends arp request. arp not answered n c causing n 2 not respond ping. question h

java - What's wrong with my logback syslog appender? -

Image
i'm trying logback syslog appender working, , i've got misconfigured. i've created small sample project think should log syslog, yet doesn't. i'm sure i'm missing stupid. here's appender logback.xml : <appender name="syslog" class="ch.qos.logback.classic.net.syslogappender"> <sysloghost>localhost</sysloghost> <facility>user</facility> <suffixpattern>[%thread] %logger %msg</suffixpattern> </appender> i've tried adding port (514) explicitly, and, no joy. on both systems i've tried on, i've verified syslog receiving input using logger "test message" , tailing either /var/log/messages or /var/log/system.log. what need change in order logback/slf4j logging syslog? nothing wrong code, problem system config. using provided test project, able make syslog appender work (ubuntu 14.10). here steps: edit /etc/syslog.conf , ensure have networ

html - on mouse enter implementation -

i have below code implemented on wordpress page. * { margin: 0; padding: 0; } .parent { width: 100%; margin: 10px auto; position: relative; } .child { position: absolute; top: 0; width: 100%; height: 100%; display: block; overflow: hidden; } .parent:hover .child { display: none; } p { padding: 1em; } <div class="parent"> <img src="http://www.fundraising123.org/files/u16/bigstock-test-word-on-white-keyboard-27134336.jpg" alt="" width="500px" height="auto" /> <div class="child"> <img src="http://maui.hawaii.edu/tlc/wp-content/uploads/sites/53/2013/11/testing.jpg" alt="" width="500px" height="auto" /> </div> </div> and interested make changes on : fade in when child appear instead of parent onmouseenter remain child after mouse left picture area , change parent next

python - How group by date in Django -

i have 2 dates. start_date = '2015/01/01' end_date = '2015/04/01' query return orders between 2 dates, need group month. so: data1: 2015/01/01 #start_date data2: 2015/02/01 data3: 2015/03/01 data4: 2015/04/01 #end_date i need chart data. you try itertools.groupby , careful django might cache generator list , consume it. from itertools import groupby groupby(orders, lambda order : order.date.month)

Excel - Count if a value is unique and a different value is greater than 1 -

i have list of identifiers, transaction amounts, , number of transactions @ amount. identifiers repeat if transaction amount differs, , need count of identifiers appear once, , number of transactions @ amount equal one. so if bob had 1 transaction @ $45.00 sally had 3 transactions @ $36.00, 1 transaction @ $22.00, , 2 transactions @ $50.00 john had 1 transaction @ $25.00 , 1 transaction @ $67.00 mark had 1 transaction @ $25.00 tom had 7 transactions @ $23.00 the count return two. to make answer easier follow, i've written example data out appear in excel, column letters , row numbers. given following table: b c 1 id amount count 2 bob 45 1 3 sally 36 3 4 sally 22 1 5 sally 50 2 6 john 25 1 7 john 67 1 8 mark 25 1 9 tom 23 7 this formula give count of rows id appears once , once in id column, , value in count column e

recursion - Grammar transformation for recursive descent -

i trying transform given grammar in order ready recursive descent. rules end are: seq --> constseq | operz z --> exprx | operx y --> exprx | operx x --> expr | exproperx | ε . what supposed z , y same? is of them eliminated? a bit hard without knowing software system used (and intelligence). if on left hand side non-terminals must unique (no or'ed rules y --> exprx , y --> operx ), purpose metainformation, maybe different semantic interpretation of generated ast. but yes, fine possibility loop reducing grammar. on other hand produced function y call z. (mind exprx | operx might same operx | exprx depending on specific grammar's symbols or type ll(1) .) also a --> x b , b -> x a redundant. one need loop on rules till no reduction possible. boolean checkrulesarethesame(rule rule1, rule rule2, context context) { context.setnonterminalsthesame(true, rule1.nonterminal, rule2.nonterminal); if (productions

python - Get all ips in PCAP file -

i have set of pcap files , need retrieve ips. found this link , have been using command. tshark_path + " -r " + infile + " -t fields -e ip.dst | sort | uniq the problem seems slow , returns looks this: 128.219.232.12,10.78.0.131 . question if there better way run quicker , more accurate. also noteworthy, code in python. take @ tshark statistics : tshark -r test.pcapng -q -z ip_hosts,tree

excel - Check if cells match in two columns and, if they do, copy a related value -

given column a of 100 names , b of numbers, column c contains subset of numbers how might populate column d matching name? match names in a , d next same number. example, a, b , c inputs , d desired output: ____a______b_______c_______d____ 1 |larry | 11111 | 22222 | bob | 2 |bob | 22222 | 44444 | steve | 3 |mike | 33333 | 55555 | jim | 4 |steve | 44444 | | | 5 |jim | 55555 | | | please try in d1 , copied down suit: =index(a:a,match(c1,b:b,0))

javascript - how to click a button using jQuery? -

here dom : <div class="form-actions"> <button class="btn btn-primary" type="submit">save device</button> </div> i want use jquery select button , click on it? tried using : jquery(".btn btn-primary").click() not working you trying select element both classes, therefore selector should .btn.btn-primary . $('.btn.btn-primary').click(); you trying select element class .btn-primary descendant of .btn element.

python - Can't write dataframe to excel after using groupby function in pandas -

import excel file dataframe: import pandas pd importexcelalldataflow =pd.read_excel("tmespatialfromcenter.xlsx") aa=importexcelalldataflow.groupby(['source', 'timeflowcontext']).size() i want write "aa" dataframe excel. used following code it. doesn't work. timespatialcount.to_excel(timespatialcount.xlsx, sheet_name='sheet1' header=false) could please tell me right way write this? thanks in advance. i want write "aa" dataframe excel. presumably means want write: aa.to_excel("timespatialcount.xlsx", sheet_name='sheet1' header=false) you write dataframe aa file "timespatialcount.xls" .

c# - Correct implementation of DAL with Entity Framework & Repository -

i'm having difficulty , confusion setting mvc/webapi project separate dal project. i have class library project titled "dashboard.data", generated code-first existing database. class library contains model classes repository. i've yet implement generic repository have far should still work. repository: namespace dashboard.data.repository { public class productrepository : iproductrepository, idisposable { private databasecontext _context; public productrepository() { _context = new databasecontext(); } public productrepository(databasecontext context) { this._context = context; } public async task<ienumerable<department>> getdepartmentlist() { return await _context.departments.tolistasync(); } protected void dispose(bool disposing) { if (disposing) if (_context != null)

html - IFrame: This content cannot be displayed in a frame; the error is still occurring after adding header -

i receiving error: protect security of information enter website, publisher of content not allow displayed in frame. want embed youtube video site , i've added tags <meta http-equiv="x-frame-options" content="allow"> but error still occurring. here entire code down added iframe tags. <!doctype html> <html lang="en"> <head> <link rel="shortcut icon" href="/img/favicon.jpg"> <meta charset="utf-8"> <meta http-equiv="x-frame-options" content="allow"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>dronedaddy</title> <!-- bootstrap core css --> <link href="css/bootstrap.min

Inputting a Json object into a mongodb using meteor -

i'm attempting insert api response mongo db, doesn't save individual fields. input here playerslist.insert(meteor.http.get("api call here")); here response call: {"hnub": { "id": 21098134, "name": "hnub", "profileiconid": 20, "revisiondate": 1428613578000, "summonerlevel": 30 }} is there simple way cleanly saving fields? the response of http call object content (string), data (javascript object if can parsed json), headers, , statuscode. recommend run code see actual response: console.log(meteor.http.get("api call here")); if turns out response includes parsed json under data field, accomplish want with: playerslist.insert(meteor.http.get("api call here").data); note, synchronous way of making api call work server. @ethaan points out, you'll need use callback client , you'll have overcome cross domain restrictions.

http - How to split header values? -

i'm parsing http headers. want split header values arrays makes sense. for example, cache-control: no-cache, no-store should return ['no-cache','no-store'] . http rfc2616 says: multiple message-header fields same field-name may present in message if , if entire field-value header field defined comma-separated list [i.e., #(values)]. it must possible combine multiple header fields 1 "field-name: field-value" pair, without changing semantics of message, appending each subsequent field-value first, each separated comma. order in header fields same field-name received therefore significant interpretation of combined field value, , proxy must not change order of these field values when message forwarded but i'm not sure if reverse true -- safe split on comma? i've found 1 example causes problems. user-agent string, example, is mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.101

c# - How to Deserialize JSON data? -

i new working json data. i reading data web service. query data sent following: [["b02001_001e","name","state"], ["4712651","alabama","01"], ["691189","alaska","02"], ["6246816","arizona","04"], ["18511620","florida","12"], ["9468815","georgia","13"], ["1333591","hawaii","15"], ["1526797","idaho","16"], ["3762322","puerto rico","72"]] is there way deserialize data in such way base object generated without me first defining object like? in above example object defined first row: ["b02001_001e","name","state"], in general web service return query data formatted 2 dimensional json array first row provides column names , subsequent rows provide data values.

c# - SqlException: Conversion failed when converting date and/or time from character string -

i error when using c# webform "adds" users credit card details. following code button "add credit card" on aspx.cs page protected void button1_click(object sender, eventargs e) { //declare , initialize connection object connect database sqlconnection conn = new sqlconnection( webconfigurationmanager.connectionstrings["defaultconnection"].connectionstring); sqlcommand cmd; //declare command object used send commands database. conn.open(); //open connection database cmd = conn.createcommand(); //create command object cmd.commandtext = "insert creditcard values ('" + txtccno.text + "', '" + txtfname.text + "', '" + txtmidinitial.text + "', '" + txtlname.text + "', '" + txtexpirationdate.text + "', '" + txttype.text + "', " + txtcvc.text + ", '"

java - Serve an already-gzipped response from a Servlet -

i have gzipped json resource in application want serve via servlet. browsers disagree on why, none of them load content. wrong code? public class myservlet extends httpservlet { @override protected void doget(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { resp.setstatus(200); inputstream in = <get input stream gzipped data>; resp.setintheader("content-length", in.available()); outputstream out = resp.getoutputstream(); out.write(ioutils.tobytearray(in)); out.close(); resp.setheader("content-encoding", "gzip"); resp.setheader("content-type", "application/json"); } } i think answer looking available in link in accepted answer in thread - serve gzipped content java servlets . this includes working example o'reilly site. however question need introducing cross curling concern , gzip contents

inheritance - Python : Wrapper class and constructor parameters -

i create simple wrapper class frozenset changes constructor arguments. here have come (as in java) : class edge(frozenset): def __init__(self, a, b): frozenset.__init__(self, {a, b}) i have edge(0,1) create frozenset({0,1}) . however, error: >>>edge(0,1) typeerror: edge expected @ 1 arguments, got 2 frozenset immutable, you'll need override __new__ method: class edge(frozenset): def __new__(cls, a, b): return super(edge, cls).__new__(cls, {a, b}) see here .

Programically convert a fixed width .dat file with a .fmt file into a .csv file using Python or Python/Pandas -

i'm trying learn python i'm stuck here, appreciated. i have 2 files. 1 .dat file no column headers fixed width containing multiple rows of data 1 .fmt file contains column headers, column length, , datatype .dat example: 10ifkdhghs34 12ifkdhghh35 53ifhdhgdf33 .fmt example: id,2,n name,8,c code,2,n desired output .csv: id,name,code 10,ifkdhghs,34 12,ifkdhghh,35 53,ifhdhgdf,33 first, i'd parse format file. with open("format_file.fmt") f: # csv.reader parses away commas # , rows nice lists reader = csv.reader(f) # give list of lists looks # [["id", "2", "n"], ...] row_definitions = list(reader) # iterate , unpack headers # gives ["id", "name", "code"] header = [name name, length, dtype in row_definitions] # [2, 8, 2] lengths = [int(length) name, length, dtype in row_definitions] # define generator (possibly closure) slices # string bit bit -- yields

Matlab - why doesn't fileID variable update when importing data using for loop? -

i'm using matlab's import data code generator pass data series of commands. works fine when run script , reference single file, if loop through several files, variables aren't updated expect. believe have traced problem 'fileid' not updating after first iteration of loop. in code below, can confirm 'filename' updated each iteration of loop, while 'fileid' not. consequently, same vector assigned variable 'y' in each iteration. can suggest going wrong? filelist = dir('*.csv'); n = size(filelist,1); k = 1:n % file name: filename = filelist(k).name; delimiter = ','; startrow = 2; %% format string each line of text: % column2: double (%f) % column3: double (%f) % column4: double (%f) % column5: double (%f) % more information, see textscan documentation. formatspec = '%*s%f%f%f%f%[^\n\r]'; %% open text file. fileid = fopen(filename,'r'); %% read columns of data according format string. dataarra

Acumatica - computing field default value -

in acumatica want compute "quote expires" date on sales order entry form based on date new order of type "qt" created. date computed adding default "default quote expiry days" set in sales order preferences. example if default expiry days = 45 (setup) , order created on april 1, 2015 default date "quote expires" on sales order entry form may 16, 2015 (april 1, 2015 plus 45 days). expiry date may overridden user. any examples appreciated. protected virtual void soorder_usrexpireddate_fielddefaulting(pxcache sender, pxfielddefaultingeventargs e) { soorder row = e.row soorder; if (row.orderdate.hasvalue) { e.newvalue = row.orderdate.value.adddays(45); } } for example added custom field soorder called usrexpireddate, feel free replace number 45 kind of setup.

go - Connecting to remote golang server -

i've been trying feels days remotely connect sockjs-go ( https://github.com/igm/sockjs-go ) server application i've written. i'm developing locally on windows, , works fine. when try running on remote linux server (after building on linux box, obviously), never able connect sockjs server. i've tried running example echoserver web example sockjs-go repository on remote machine, , cannot connect either. i made sure change sockjs client ip local machine remote machine. i have right public ip address , can view static web page served lighttpd. i've tried searching on google golang-specific, have found nothing. suggestions great. update i using echo test code verbatim given here: https://github.com/igm/sockjs-go/tree/v2/examples/webecho as far can tell, linux server isn't filtering. port 8080 closed before running webecho, , open after starting webecho. i have tried https://coderwall.com/p/wohavg/creating-a-simple-tcp-server-in-go , can conn

if statement with just one variable as conditionals-php -

i trying study php , came across if statement has single variable conditional this: <?php if($a){ //do } ?>; i know c++ , javascript, in languages, if statement ben invalid. tell me if statement means? as rizier123 said above, conditional checking "truthy" values in variable $a. in loosely-typed language php, truthy value non-empty, non-null, or non-zero value. see great answer similar question: https://stackoverflow.com/a/6693908/2796449 or php docs: http://php.net/manual/en/language.types.boolean.php boolean logic reduces down entire statement down 1 value, either true or false. executing "echo (3==4);" show false. if variable returns truthy value, evaluated true. these 3 comparable statements: $a = 1; if ( $a ) if ( 1 ) if ( true )

grails - does importing domains in Gsp make the pages vulnerable -

say page import of domain in gsp, example: <%@ page import="com.sample.entity.book" %> to use page via <g:select from="${book.list()}" optionkey="id" optionvalue="title" name="booksample"/> is bad programming practice use import? new grails , have seen practice in lot of tutorials, lead discourage me because according him hackers can data db. i've been arguing against guess need support. i agree on above more ideal use controller list of books - think not idea using <%@ page import="" %> bad coding because makes page vulnerable. i know gsps compiled , no reference of import visible html pages. update: thank giving inputs. i've updated question give more focus. if told wrong , reason - kind of think beyond best practices , more on security, can't imagine how, through import i'm not sure "hackers bad things" reasoning, there bett

arrays - How to kill a list of processes in c# -

i new c# , trying kill list of processes. able use code below kill 1 process change kills list of processes. on time list grow ideally find way updating list quick , easy. try { foreach (process proc in process.getprocessesbyname("notepad")) { proc.kill(); } } catch (exception) { console.writeline("procces not found."); } i'm sorry if have overlooked question asked this. thank in advance provided. the observablecollection<t> class provides event if collection changed. can create collection of process , handle new added items in event handler: observablecollection<process> processes = new observablecollection<process>(); processes.collectionchanged += processes_collectionchanged; static void processes_collectionchanged(object sender, notifycollectionchangedeventargs e) { if (e.newitems != null) foreach (var process in e.newitems.oftype<process>()) process.kill(); pro

python 3.x - np.sum is rounding values to the nearest integer (not wanted) -

(some of code has been removed, such plotting code, doesn't affect issue) as title states, i'm having issue numpy's sum function rounding nearest integer. in following code, create variable chisqrr using np.sum, works intended, giving value of 1.23727.... near bottom of code, have practically exact same code need find bunch of values 'chisqr' based on range of input values. 3 lines of interest are: chisqr[i] = np.sum(((counts - fit_exp_nonlin(t, popt[0], mu[i], popt[2]))/yerr)**2) print(((counts - fit_exp_nonlin(t, popt[0], mu[i], popt[2]))/yerr)**2) print(chisqr[i]) where first 'print' line, without np.sum command, gives bunch of values (all of long decimals), however, once summed np.sum, exact integers, not possible. example, 1 array before it's summed is: [ 0.2251407 0.25516322 0.90413181 1.08316468 7.40191331 0.00893473 1.94594874 0.24967999 2.58848903 1.39550592 0.06140513] and 'sum' gives array is: 16 whereas i

python - Remove special character -

how convert input text 'abcde'f gh' to output 'abcdefgh' ? this did not work. a='abcde'f gh' b=a.translate({(u"\u0027"):none}) you should escape apostrophe ' or use quotes " define string: >> a='abcde\'f gh' or >> a="abcde'f gh" to remove symbol ' , spaces, use string.translate this: >> b = a.translate(none," \'") 'abcdefgh' string.translate(s, table[, deletechars]) delete characters s in deletechars (if present), , translate characters using table, must 256-character string giving translation each character value, indexed ordinal. if table none, character deletion step performed.

swift - Replace elements of 2 arrays? -

i have 2 arrays: var underarray = ["_", "_", "_", "_", "_"] , var letterarray = ["a", "b", "c", "d"] . have button, , every time press button want replace element of underarray 1 letterarray . for exmple: first press: var underarray = [a, _, _, _, _] second press: var underarray = [a, b, _, _, _] third press: var underarray = [a, b, c, _, _] etc... i can manually like: underarray[0] = letterarray[0] , underarray[1] = letterarray[1] , that's not option. so far tried creating - loop , did not work: @ibaction func mybuttons(sender: uibutton) { var index = 0; index < underarray.count; ++index { swap(&underarray[index], & letterarray[index]) } } i suspect it's wrong approach. right approach? you have declare variables out of ibaction , make sure don't in case button has been pressed many times: var presscounter = 0 var und

xcode6.3 - Error after Xcode 6.3 update -

i getting following errror after updated xcode 6.3. cannot run apps on simulator or on device. didn't update os. need update os 10.10.3 xcode working? the operation couldn’t completed. (mach error -308 - (ipc/mig) server died)

python - Using self.render() in a StaticFileHandler -

i'm trying extend staticfilehandler in such way can process file requests call self.render(filename, **kwargs) on file serve client. (yes, realize @ point it's no longer static file per se). here's code i'm trying run: class mustachefilehandler(tornado.web.staticfilehandler): def get(self, filename): self.render(_static_root_ + '/' + path.split('/')[len(path.split('/'))-2], userloginstatus='you logged out!') # ... class application(tornado.web.application): def __init__(self, **overrides): handlers = [(r'/(.*)', mustachefilehandler, {'path' : _static_root_})] # ... ... _static_root_ variable included in server's config file loaded on startup. the issue i've got is, whenever try get on file know exists on server, following error: traceback (most recent call last): file "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1332, in _execute result =

sass - Unbound variable ionic -

i'm getting unbound variable when load sass ionic. trying override checkbox , ionicon variable not resolve // path our ionicons font files, relative built css in www/css $ionicons-font-path: "../lib/ionic/fonts" !default; // include of ionic @import "www/lib/ionic/scss/ionic"; .following { .checkbox input:before, .checkbox-icon:before { content: $ionicon-var-android-add-circle; } } if didn't update since beta14 have v1.5 of ionicons , $ionicon-var-android-add-circle not included in that. update framework latest rc or add ionicons v2.0 manually project.