Posts

Showing posts from April, 2011

c# - Detecting and replacing all smilies in a string -

this question has answer here: mysql server not support 4-byte encoded utf8 characters 8 answers i have integration facebook , have notice thay sends example u+1f600 called grinning face. when try store in mysql text field server not support 4-byte encoded fast solution remove these special chars string. the question how? know u+1f600 suspect there more of them. consider switching mysql utf8mb4 encoding... https://mathiasbynens.be/notes/mysql-utf8mb4

node.js - How to find a sub document in mongoose without using _id fields but using multiple properties -

i have sample schema - comment.add({ text:string, url:{type:string,unique:true}, username:string, timestamp:{type:date,default:date} }); feed.add({ url:{type:string, unique:true }, username:string, message:{type:string,required:'{path} required!'}, comments:[comment], timestamp:{type:date,default:date} }); now, don't want expose _id fields outside world that's why not sending clients anywhere. now, have 2 important properties in comment schema (username,url) want update content of sub document satisfies feed.url comment.url comment.username if comment.username same client value req.user.username update comment.text property of record url supplied client in req.body.url variable. one long , time consuming approach thought first find feed given url , iterating on subdocuments find document satisfies comment.url==req.body.url , check if comment.username==req.user.username if so, update comment object. but, think...

javascript - active item li on menu where hover -

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <div id="topbar"> <ul> <li class="active"> <a href="">about us</a> </li> <li> <a href="">services</a> </li> <li> <a href="">gallery</a> </li> <li> <a href="" class="nav-quote-button">get quote</a> </li> </ul> </div> how set class active on li 2,3,4... hover, , remove class active has go thank you! unless need active kind of query down line (i don't know why would, though), try css. li:hover { // active class css here } you can add further selectors li keep...

java - How to change JFileChooser label "Look in:" to "Save in:" (not title)? -

Image
how change jfilechooser label "look in:" "save in:" (not title)? here can see want change: i found solution, maybe useful too: jfilechooser chooser = new jfilechooser("open"); //set text , language of components in jfilechooser uimanager.put("filechooser.opendialogtitletext", "open"); uimanager.put("filechooser.lookinlabeltext", "lookin"); uimanager.put("filechooser.openbuttontext", "open"); uimanager.put("filechooser.cancelbuttontext", "cancel"); uimanager.put("filechooser.filenamelabeltext", "filename"); uimanager.put("filechooser.filesoftypelabeltext", "typefiles"); uimanager.put("filechooser.openbuttontooltiptext", "openselectedfile"); uimanager.put("filechooser.cancelbuttontooltiptext","cancel"); uimanager.put("filechooser.filenameheadertext","filename"); ...

c# - How can I pass values of a listview from aspx page to another ? -

i working on class project creating listview in 1 .aspx page. can display database through list view cannot transfer value of selected item .aspx page another. my designing code below: <asp:listview id="lvpresent" runat="server" datasourceid="sqldatasource1" onitemdatabound="lvpresent_itemdatabound" > <layouttemplate> <table> <tr> <td></td> </tr> </table> <asp:placeholder id="itemplaceholder" runat="server"></asp:placeholder> </layouttemplate> <itemtemplate> <td> <asp:hyperlink id="hyperlink1" runat="server"> <asp:image id="imagebutton1" runat="server" imageurl='<%#eval("url")%>' height="200px" width=...

pthreads - Can't pass in struct into function for pthread_create correctly -

i'm trying pass in professor struct professor function can't information stored in pass function. suspect has how malloc'd p thought freeing after it's completed solve problem. segfault when try print *professor->id, because apparently decides read p memory location 0x0, though it's not in main typedef struct{ int *id; int *assignings; int *min_wait; int *max_wait; int *min_assignments; int *max_assignments; int *min_hrs; int *max_hrs; } professor; professor* makeprofessor(){ professor *professor = malloc(sizeof *professor); return professor; } void * professorfunc(void *p){ professor *professor = (professor*)p; fprintf(stdout,"starting professor %d\n", *professor->id); pthread_exit(0); } int main(int argc, char **argv){ //creating threads pthread_t professor[num_professors]; professor *p; int i; int id; for(i = 0; < num_professors; ++i){ id = + 1; ...

r - frequency() and cycle() of a monthly xts object returns value "1" -

i have monthly xts object, , function frequency() returns value of 1, expect 12. function cycle() not return month numbers, instead value of 1 each observation. library('quantmod') getsymbols("gs10", src="fred") frequency(gs10) cycle(gs10) try this: time(gs10) <- as.yearmon(time(gs10))

c++ - zlib inflate stream and avail_in -

part of application i'm working on involves receiving compressed data stream in zlib (deflate) format, piece piece on socket. routine receive compressed data in chunks, , pass inflate more data becomes available. when inflate returns z_stream_end know full object has arrived. a simplified version of basic c++ inflater function follows: void inflater::inflate_next_chunk(void* chunk, std::size_t size) { m_strm.avail_in = size; m_strm.next_in = chunk; m_strm.next_out = m_buffer; int ret = inflate(&m_strm, z_no_flush); /* ... check errors, etc. ... */ } except strangely, every like... 40 or times, inflate fail z_data_error . according zlib manual , z_data_error indicates "corrupt or incomplete" stream. obviously, there number of ways data getting corrupted in application way beyond scope of question - after tinkering around, realized call inflate return z_data_error if m_strm.avail_in not 0 before set size . in other words, seems...

h.264 - How to decide using MTAP over STAP in h264 rtp payload -

i've been digging encoding , streaming h264 on past week. night i'm implementing rtp h264 payload. according rfc 3984 (" rtp payload format h.264 video - february 2005 ") multiple new nalu introduced. among them mtap (multi time aggregation packet) , stap (single time aggre...). as names indicating, in stap mode, units assumed have same timestamps. not mean can't use stap vcl nal units? for example 1 may use stap transmitting nal types 7 or 8 (sps, pps) can't use stap types 1,2,3? you can use stap packets aggregating both vcl , non-vcl nalus have same presentation time, should case if part of same frame. you're encoder should providing series of nalus frame , should have same presentation time. i've worked encoders produced nalu byte stream containing nalus frame. byte stream assigned single presentation time. i've seen encoders produced individual nalus, multiple have same presentation time if part of same frame.

javascript - JSON field undefined in EJS template -

on front-end, have html: <a name="user" id="user" value="<%=user%>"></a> i entirely sure user defined on front-end and have js file this: var user; var teamcollection = new teamcollection([]); //new backbone collection $(document).ready(function(){ user = $("#user").attr("value"); //pull user object html window.userhomemaintableview = new userhomemaintableview({el: $("#user-home-main-table-div")}); window.userhomemaintableview.render(); }); the render method of userhomemaintableview looks this: render: function () { console.log('teamcollection models:', teamcollection.models); //defined console.log('user:', user); // defined var data = {teamcollection:teamcollection,user:user}; //this should point user variable @ top of js file. var html = new ejs({url: '/js/backbone/views/userhomeviews/templates/...

python - Adding and multiplying columns of a numpy array with another array -

i have 2d numpy array x , and 1d numpy array y : import numpy np x = np.arange(12).reshape((4, 3)) y = np.array(([1.0,2.0,3.0,4.0]) i want multiply / add column vector y.reshape((4,1)) each column of x . attempted following: y1 = y.reshape((4,1)) y1 * x yields array([[ 0., 1., 2.], [ 6., 8., 10.], [ 18., 21., 24.], [ 36., 40., 44.]]) which wanted. found array([[ 1., 2., 3.], [ 5., 6., 7.], [ 9., 10., 11.], [ 13., 14., 15.]]) with y1 + x . know if there better (more efficient) way achieve same thing! numpy supports via broadcasting. code used broadcasting , it's efficient way things. write as: >>> x * y[..., np.newaxis] array([[ 0., 1., 2.], [ 6., 8., 10.], [ 18., 21., 24.], [ 36., 40., 44.]]) to see equivalent: >>> z = y[..., np.newaxis] >>> z.shape (4, 1) you can see numpy doesn't copy data, changes iteration on same mem...

java - submitting form in ftl to spring MVC controller -

i have simple form want submit spring mvc controller. form goes this: <form id="assaydetailsform" method="get" action="[@spring.url '/reports/assay/runassaydetailsreport.htm'/]"> below spring controller java code: @requestmapping(value="/assay/runassaydetailsreport", method = requestmethod.get) public modelandview runassaydetailsreport(@requestparam("magentaassayids")string magentaassayids, @requestparam("reportformat")string reportformat){ the problem request never reaches desired method i.e. "runassaydetailsreport" , runtime exception thrown. i tried submitting above form using ajax call 404 status code returned. appreciate help.

node.js - Rrdtool with nodejs -

let's have program running in local machine, , listen http requests, triggers program run , respond output of program. example, have rrdtool (command line utility accessing round robin database) installed in linux box, , want web clients request web server run rrdtool program , respond output of rrdtool. quesitons: i know programming languages used generate dynamic html contents sent clients, rrdtool existing program needs triggered web request. in fact, rrdtool provides various programming language bindings such python, use node.js on server side , javascript binding rrdtool isn't supported. how interface between javascript code , rrdtool program (cli) done? i thought using java implementation of rrdtool functionalities such rrd4j, portability isn't priority me , run official rrdtool program (written in c) better performance. however, i'm not sure if cost of interface between javascript on server side , rrdtool outweigh performance benefits of running c progr...

Connection Error with SQL Azure and Entity Framework on Azure Website -

not sure start, whenever publish asp.net website azure, pages have database access give me message saying "error. error occurred while processing request." open remote debugger (which fickle because refuses attach half of time) , see error occurs when establishing when trying access entity framework. error varies between "network-related or instance-specific" error, or "login failed" error (which result of previous error, don't know). the ado.net connection string sql azure gives is server=tcp:[servername].database.windows.net,1433;database=ensemblemusicwebdatabase;user id=user@[servername];password=(password);trusted_connection=false;connection timeout=30; but every implementation (inserting ef metadata string, changing server data source...etc) still gives me same login error i'm pretty sure it's problem connection string, infuriating part i've tried every possible combination can think of (entity framework metadata, using sql...

sql - Store hashes of User-Agent strings in a MySQL table: insert if not exists, return id -

inspired following 2 answers on stackoverflow tried implement table goal store user-agent strings in it: https://stackoverflow.com/a/13210391 https://stackoverflow.com/a/3554596/1103527 here's table structure: create table if not exists ua_strings ( ua_id integer primary key auto_increment, ua_hash binary(16), ua text, unique key ua_hash (ua_hash) ); i'd achieve following: input: user-agent string should inserted in table if doesn't exist yet output: ua_id so far i've come solution: insert ignore ua_strings (ua_hash, ua) values (unhex(md5('test')), 'test'); select ua_id ua_strings ua_hash = unhex(md5('test')); is possible make 1 query out of 2 queries? how can improve table structure or queries in terms of speed , elegance? the important thing rid of insert ignore . discovered increment primary key if fails. can burn through 4 billion keys way. select first, it's going common case a...

Upload multiple files in Azure Blob Storage from Linux -

is there way upload multiple files azure blob storage linux machine, either using terminal or application (web based or not)? thank interest – there 2 options upload files in azure blobs linux: setup , use xplatcli following steps below: install os x installer http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/ open terminal window , connect azure subscription either downloading , using publish settings file or logging in azure using organizational account (find instructions here) create environment variable azure_storage_connection_string , set value (you need account name , account key): “defaultendpointsprotocol=https;accountname=enter_your_account;accountkey=enter_your_key” upload file azure blob storage using following command: azure storage blob upload [file] [container] [blob] use 1 of third party web azure storage explorers cloudportam: http://www.cloudportam.com/ . can find full list of azure storage explorers here: http://blogs.msdn.co...

c# - Working with multiple threads and while updating the UI -

Image
background info: i'm creating batch encoder project. it's this: (i need add cancel button inside each item , replace placeholders) for each item added, thread/task should process given information (image) , saved on disk encoded image. i'm used work delegate , delegateobject.begininvoke(...) , updated ui static calls inside delegate method. the problem: i did winforms , not dynamic list of items. i'm not familiar cancellation of threads/tasks ui. the question: i need little push head best way of approaching problem. how manage multiple parallel operations , update ui? have looked @ using cancellation tokens. along lines of: private cancellationtokensource _cts; private async void start_click(object sender, eventargs e) { _cts = new cancellationtokensource(); var token = _cts.token; try { await task.run(() => { // encoding process }); } catch (operationcanceledexception)...

jquery - How to not return success when data is not valid, or exception is thrown? -

i using jquery ajax, , hit success: function (msg)... . want able specify when hit: error: function (msg)... the issue here seems don't have way return true or false , since have return view. in normal web app (unlike mvc), used return true or false, check on boolean value, , act according this. how can specify want jump error: function (msg) in cases? example when validation doesn't pass, don't want it's success. here jquery code: function contactdialog(action, controller) { var url = '/' + action + '/' + controller; $("#contactdialog").dialog({ autoopen: true, hide: "fade", show: "bounce", height: $(window).height() / 2, width: $(window).width() / 2, title: "send email", buttons: [{ text: "send", click: function () { $.ajax({ url: url, data: $("form").serialize(...

Array in Java beginner -

i'm beginner in coding. write project convert degree f c , c f using command line argument. here got far: public class implementation { public static void main(string[] args) { { string[] days = {"very cold", "cold", "mild", "very mild", "warm", "very warm", "hot"}; } } if (args.length != 3) { system.out.println("error! please try again."); system.exit(0); } else { double degree; string celsius; string fahrenheit; degree = double.parsedouble(args[0]); celsius = args[1]; fahrenheit = args[2]; switch (celsius) { case "c": system.out.printf("%n%s celsius %s fahrenheit\n", args[0], ( 5.0 / 9.0 * (degree - 32))); break; ...

stored procedures - How to handle complex conditional where clauses in mysql -

based on variety of optional user inputs, need modify structure of clause in query (not dynamic values, dynamic structure). examples.. if select customerid, don't use branchid filter, if select empid use both empid , branchid filters. there more criteria used well, thats example. i could build logic clause using case statements, i'm guessing wouldn't optimized? know dynamically build sql statement within stored proc, , use prepared statements well... seems sloppy? there method i'm not thinking of? the usual approach dynamically building query in layer handles user input. in case not use high level language in front of database, means resorting stored procedure indeed, , might bit dirty indeed - find language quite awkward. a pure sql solution not have of overhead, since constant-based conditions optimized away quite efficiently (user input constant when query starts).

ios - UIScrollView doesn't scroll vertically(i have a bottom bar view) -

import uikit class detailsviewcontroller: uiviewcontroller, uiscrollviewdelegate { // titolo dell'annotazione selezionata proveniente dalla viewcontroller var titolostringa = "" /* // riferimento alla scrollview delle immagini @iboutlet var scrollview: uiscrollview! // riferimento al page control relativo alle immagini @iboutlet var pagecontrol: uipagecontrol! // array che conterrà le immagini var pageimages: [uiimage] = [] // array di optionals che conterrà istanze di uiimageview per mostrare ogni immagine nella sua relativa pagina var pageviews: [uiimageview?] = [] */ // riferimento alla label titolo @iboutlet weak var titolo: uilabel! @iboutlet weak var scroolview: uiscrollview! @iboutlet weak var labeltesto: uilabel! @iboutlet weak var pagecontrol: uipagecontrol! override func viewdidload() { super.viewdidload() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } override func vi...

algorithm - Counting the number of unival subtrees in a binary tree -

i came across interview question of finding number of unival subtrees in binary tree. how can done? int countunivals(node* head, bool* unival) { if (!node) { *unival = true; return 0; } bool unil,unir; int sum = countunivals(head->l, &unil) + countunivals(head->r, &unir); if (unil && unir && (!head->l || head->l->val == head->val) && (!head->r || head->r->val == head->val)) { sum++; *unival = true; } return sum; }

.net - C#: Form receives all keypresses except the ENTER key -

i designing custom calculator. key pressed on calculator form should captured @ 'form' level. end, i've following code- private void bindcontrolmouseclicks(control con) { con.mouseclick += delegate(object sender, mouseeventargs e) { triggermouseclicked(sender, e); }; // bind controls added foreach (control in con.controls) { bindcontrolmouseclicks(i); } // bind controls added in future con.controladded += delegate(object sender, controleventargs e) { bindcontrolmouseclicks(e.control); }; } private void triggermouseclicked(object sender, mouseeventargs e) { } private void form1_load(object sender, eventargs e) { this.keypreview = true; this.keypress +=new keypresseventhandler(form1_keypress); bindcontrolmouseclicks(this); this.formborderstyle = system.windows.forms.formborderstyle.fixeddialog; this.maximizebox = false; } void form1_keypress(object sender, keypresseventargs e) { ...

r - Select cases in a data frame -

i want select range of cases in data frame, every n column. illustrate problem reproducible example: set.seed(100) data <- data.frame(replicate(18,sample(0:100,18,rep=true))) from data, want select data[1:6, 1] , data[7:12, 7] , data[13:19, 13] , , forth. obviously, i'm working bigger dataset (>10000 rows , columns), why prefer automated way this. have tried define sequence beforehand ( seq() ) couldn't quite figure out how apply problem. help! matrix indexing might handy here: sel <- cbind(sequence(nrow(data)),rep(seq(1,ncol(data),6),each=6)) sel # row col # [,1] [,2] # [1,] 1 1 # ... # [6,] 6 1 # [7,] 7 7 # ... #[12,] 12 7 #[13,] 13 13 # ... then: data[sel] # [1] 31 26 55 5 47 48 97 3 92 73 20 84 37 30 55 37 85 62

ios - How to set table cell checkmark based on a user default setting -

i have simple table has 2 cells checkmark options (these meant settings options): setting 1 setting 2 in storyboard have prototype cells' accessory set checkmark. of course automatically checks both of cells when they're built. what can't figure out how check user default settings upon viewdidload , determine of cells should checked. these particular settings set in nsuserdefaults setting 1 = true , setting 2 = false . out of box settings. i know it's got if statement of sort. maybe this: if settingscell[0] && settingday == true{ settingscell.accessorytype = .checkmark } but can't figure out: a) proper syntax b) should placed in uiviewcontroller (viewdidload stated earlier or in tableview function) checkmark cells based on actual settings? any appreciated!

java - 'Get' method is returning null when called -

i trying return name of user class have set up, when getname called, null returned. doing wrong? public class investor { private string firstname; private string lastname; public string getname(){ return firstname + " " + lastname; } public void setname(int userindex){ arraylist<string> firstnamelist = new arraylist<string>(); arraylist<string> lastnamelist = new arraylist<string>(); string line = ""; try{ filereader fr = new filereader("investments.txt"); bufferedreader br = new bufferedreader(fr); while((line = br.readline()) != null) { line.split("\\s+"); firstnamelist.add(line.split("\\s+")[3]); lastnamelist.add(line.split("\\s+")[4]); } } catch(ioexception e){ system.out.println("file not found!"); } this.first...

hyperlink - Wordpress Divi Theme Link to Filtered Portfolio Category -

i'm using current version of divi 2.0 theme , wordpress. theme uses filterable portfolio gallery user can click filter between categories. links # , instead think click passed using: data-category-slug="%1$s" where "%1$s" name of category. i've tried adding "%1$s" end of #link, doesn't work. theme function: function et_pb_filterable_portfolio( $atts ) { extract( shortcode_atts( array( 'module_id' => '', 'module_class' => '', 'fullwidth' => 'on', 'posts_number' => 10, 'include_categories' => '', 'show_title' => 'on', 'show_categories' => 'on', 'show_pagination' => 'on', 'background_layout' => 'light', ), $atts ) ); wp_enqueue_script( 'jquery-masonry-3' ); wp_enqueue_script( 'hashchange...

javascript - If the CreateJS library supports the JSON output formats of Texture Packer -

i'd been using createjs little time. got trouble load image made texture packer, , got json file this: {"frames": [ { "filename": "aim_dot", "frame": {"x":118,"y":4,"w":76,"h":76}, "rotated": false, "trimmed": false, "spritesourcesize": {"x":0,"y":0,"w":76,"h":76}, "sourcesize": {"w":76,"h":76} }, { "filename": "boundary", "frame": {"x":4,"y":385,"w":250,"h":100}, "rotated": false, "trimmed": false, "spritesourcesize": {"x":0,"y":0,"w":250,"h":100}, "sourcesize": {"w":250,"h":100} }] } when bitmap represents image this: var bitmap = new createjs.bitmap("imagepath.jpg"); but if image image sprites,could use bitmap ...

javascript - I am having issue in my if condition. Based on user selection day It has to validated -

i need day , timing user. here how do in javascript. using jquery hide , show showing timing form. further want validate form, based on user selection. questions are: based on users selection want validate day , timing: if select monday. has validate monday time , time form has submit. should validate enter tuesday time. like wise if user select both monday , tuesday has validated both.and form has submit http://jsfiddle.net/kodesh/kog3ugbt/1/ here form: <form name="f1" action="s.php" method="post"> <table cellpadding="2" cellspacing="2"> <tr> <td> <p style="color:#999; font-size:14px; text-align:right;">what times available take classes?</p> </td> <td style="color:#999; font-size:14px;"> <input type="checkbox" name="day[]" class="day" value=...

Date in SQL Server different with output in .cfm -

i have sql code this: select date aaa id = 1 date value id = 1 '2015-03-16' when execute in sql server shows '2015-03-16' . why if execute same query in .cfm shows '2015-03-14' ? all of data have different 2 days between sql server , .cfm ?

java - What is the difference between .foreach and .stream().foreach? -

this question has answer here: what difference between collection.stream().foreach() , collection.foreach()? 3 answers this example: code a: files.foreach(f -> { //todo }); and code b may use on way: files.stream().foreach(f -> { }); what difference between both, stream() , no stream() ? practically speaking, same, there small semantic difference. code defined iterable.foreach , whereas code b defined stream.foreach . definition of stream.foreach allows elements processed in order -- sequential streams. (for parallel streams, stream.foreach process elements out-of-order.) iterable.foreach gets iterator source , calls foreachremaining() on it. far can see, current (jdk 8) implementations of stream.foreach on collections classes create spliterator built 1 of source's iterators, , call foreachremaining on iterator -- iterable.fo...

ios - Red Bear Lab BLE Shield isn't connecting to my iPhone -

i've purchased this: http://redbearlab.com/bleshield/ i've connected arduino , i'm trying run first test program tell me run ble controller sketch. i've connected , resolved original compile errors got, , upload. when upload it, iphone unresponsive shield. i'm trying figure out if problem in code or if it's problem shield itself. if it's code, how fix code? i'm relatively new arduino , new making work bluetooth. here's entire sketch guide told me download github. blecontrollersketch.ino /* copyright (c) 2012, 2013 redbearlab permission hereby granted, free of charge, person obtaining copy of software , associated documentation files (the "software"), deal in software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of software, , permit persons whom software furnished so, subject following conditions: above copyright notice , permission notice...

Why does Oracle SQL Developer use such strange delete criteria? -

when deleting rows in grid view, message panel indicates sql developer issues delete command. delete "mh"."t" rowid = 'aabug+aaeaaeztraaa' , ora_rowscn = '1220510600909' , ( "a" null or "a" not null ) it seems specifying rowid should sufficient identify row, so why specify ora_rowscn? and more befuddling, why null / not null clause? the rowid physical address of row. if 1 row deleted , row inserted, new row have same rowid old row. if data in row had been modified, possible rowid have changed. ora_rowscn criteria ensures neither of these have happened. allows sql developer alert if session had modified data since read can confirm still want delete row. i'm @ loss a null or not null predicate adding. if first predicate, guess standard 1 = 1 predicate folks add queries dynamically built simplify process of building sql statement dynamically. doesn...

SQL Server : pivot date to month quarter and year subtotal format -

i have table contains datefield , product . want below pivot query show month total, quarter total , year total. year month b c ----------------- 2014 jan 2014 feb 2014 mar 2014 q1 2014 apr 2014 may 2014 jun 2014 q2 2014 jul 2014 aug 2014 sep 2014 q3 2014 oct 2014 nov 2014 dec 2014 q4 2014 total 2015 jan 2015 feb 2015 mar 2015 q1 refer simple-way-to-use-pivot-in-sql-query codeproject , code given in example more similar requirement.

javascript - Updating node.js to 0.12 Header errors -

error: "name" , "value" required setheader(). @ clientrequest.outgoingmessage.setheader (_http_outgoing.js:333:11) @ new clientrequest (_http_client.js:101:14) @ object.exports.request (http.js:49:10) @ request.start (/users/aaa/desktop/projects/a/node_modules/request/request.js:904:30) @ request.end (/users/aaa/desktop/projects/a/node_modules/request/request.js:1635:10) @ end (/users/aaa/desktop/projects/a/node_modules/request/request.js:676:14) @ immediate._onimmediate (/users/aaa/desktop/projects/a/node_modules/request/request.js:690:7) @ processimmediate [as _immediatecallback] (timers.js:358:17) i errors after updating node.js 0.12 in request. what should out for? try npm update or remove node_modules dir , npm install

mysql - SQL SERVER (TSQL) SUM of inverse DateDiff (SQL or Stored Procedure) -

i have tricky sql create, having table: +-----------------------+ | employee login logout | +-----------------------+ | 1 08:30 08:50 | | 1 09:00 10:00 | | 1 10:20 11:00 | +-----------------------+ i need sql sum break times: 08:50 -> 09:00 = 10 minutes + 10:00 -> 10:20 = 20 minutes = 30 minutes in total so need somehow go on each record , using datediff method sum duration of breaks between records. is there easy way using sql or stored procedure ? as commented @thebjorn, first difference between first login , last logout (work shift) , subtract sum of difference of each login-logout pair (actual time you're working). result total time you're not working or break time. ;with sampledata(employee, login, logout) as( select 1, cast('08:30' time), cast('08:50' time) union select 1, cast('09:00' time), cast('10:00' time) union select 1, cast('10:20' time), cast('11:00...

sockets - How to read and write tar file in C? -

i want read tar file , write tar file using c. procedure m following here : creating tar file of folder writing client socket program reading tar file binary file in c using fread function writing whatever comes in buffer socket writing server socket program receive sent data buffer writing received buffer tar file. closing files , socket. here code : server.c #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #define max 1024 #define sock_path "/tmp/foo" int s, s2, t, len; struct sockaddr_un local, remote; void createssocket() { if ((s = socket(af_unix, sock_stream, 0)) == -1) { perror("socket"); exit(1); } printf("\nserver socket created..."); } void setssocketpath() { local.sun_family = af_unix; strcpy(local.sun_path, sock_path); unlink(local.sun_path);...

Optaplanner SwapMove filter in Cheap Time -

i working on new planning problem , using cheap time testing. want add filter handle hard score constraint. in cases, machine cannot assigned - @ all. i added filter swapmove filter: public class taskassignmentfilter implements selectionfilter<swapmove> { public boolean accept(scoredirector scoredirector, swapmove move) { taskassignment task1 = (taskassignment)move.getleftentity(); taskassignment task2 = (taskassignment)move.getrightentity(); if (task1.getmachine().getindex() == 0 || task2.getmachine().getindex() == 0) return false; return true; } } and added config <swapmoveselector> <filterclass>….taskassignmentfilter</filterclass> </swapmoveselector> however, machine index 0 still assigned. any hint doing wrong? and possible handle constraint in score calculator also?

jboss7.x - Running Jboss 7 using different config folder under standalone-servers -

i'm used jboss 5 deployment schemes use command deploy: d:\jboss5\bin\run.bat -c zzz which deploy whatever in jboss5\server\zzz folder i have structure on jboss7: d:\jboss7\ +standalone-servers ++zzz +++modules when try run jboss7 this: d:\jboss7\bin\standalone-servers.bat -c zzz it complains following: org.jboss.modules.modulenotfoundexception: module org.jboss.as.standalone:main not found in local module loader @7559ec47 (roots: d:\jboss7\standalone-servers\modules) @ org.jboss.modules.localmoduleloader.findmodule(localmoduleloader.java:126) @ org.jboss.modules.moduleloader.loadmodulelocal(moduleloader.java:275) @ org.jboss.modules.moduleloader.preloadmodule(moduleloader.java:222) @ org.jboss.modules.localmoduleloader.preloadmodule(localmoduleloader.java:94) @ org.jboss.modules.moduleloader.loadmodule(moduleloader.java:204) @ org.jboss.modules.main.main(main.java:262) how tell jboss7 right configuration resides in folde...