Posts

Showing posts from January, 2010

Ruby on Rails: BlueCloth gem cannot work in production when deployed to heroku -

i'm trying use bluecloth gem in order parse markdown rails app. added gem file: gem 'bluecloth' in .html.erb views user code <%= bluecloth.new(post.content).to_html.html_safe %> to render markdown html. works fine in local dev environment, when push heroku, after running bundle install , restarting app, accessing app generates internal server errors. i following error in logs: actionview::template::error (uninitialized constant actionview::compiledtemplates::bluecloth): i include bluecloth in gem file: source 'https://rubygems.org' gem 'rails', '3.2.8' gem 'pg' group :assets gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem 'devise' gem 'bluecloth' i have run command bundle install via heroku command line. thanks help! it looks man

arrays - Why isn't my string being passed properly to this thread-invoked function? -

i working on multithreaded application in client program generates request threads send strings data server program, answers sending strings back. unfortunately, having trouble passing data client's main function function invoked each request thread. in main, request threads going (some previous variable declarations not shown): for(int j = 0; j < persons.size(); j++){ //requests deal imaginary people thread_args* dat = new thread_args; strcpy(dat->str, persons[j].c_str()); cout << "***i copied " << dat->str << " dat->str!!!"<<endl; //prints expected pthread_create(&request_thread[j],null,&deposit_requests, &dat); } specifically, structure using pass things threads looks this: typedef struct str_thdata{ char str[100]; } thread_args; now, in cout within main ("***i copied..."), , good. correct value indeed copied in. when actual function invoked thread, though, string lost:

orchardcms - Orchard how to make homepage address also accessible by index -

supposed home page @ moment is: www.myorchard.com how make when user access www.myorchard.com/index goes home page? you don't want that. seo, resource should correspond 1 url. want redirect 1 other, permanently. can either using iis's rewrite url module, or through orchard module: http://gallery.orchardproject.net/list/modules/orchard.module.contrib.rewriterules the former solution preferred less overhead, if think you're going have manage lots of rewrites often, latter more convenient.

c# - Can't Create New Thread Using Method Call -

i have problem multithreadding. vs2010 don't accept "sendcom(ip, com)". error: expacted method name private void sendcom(string com) { //send command int i=0; string ip; foreach (var item in checkedlistbox1.checkeditems) { console.writeline(item.tostring()); ip = getip(item); thethreads[i] = new thread(new threadstart( sendcom(ip, com) )); i++; } } private void sendcom(string ip, string com) { thesshclass.runsinglecom(ip, com); } consider expression new threadstart( sendcom(ip, com) ); it says call sendcom , pass result threadstart constructor. that's not want - want threadstart have reference sendcom function, , have new thread pass in ip , com . the typical way hans passant says: var t = new thread(new threadstart(() => sendcom(ip, com))); t.start(); here you're constructing anonymous

c# - Multiple identity columns or a way to auto increment -

i have table ( torder ) has following structure in sql server 2008 orderid (int) - primary key , identity field. name(varchar) address(varchar) groupid (int) - field need auto increment, @ same time want able insert values into. my data like: 1 - john - address1 - 1 2 - mary - address2 - 1 3 - mary -address3 - 2 4 - jane - address4 - 3 where order ids 1 , 2 share same group , while 3 , 4 in own. many orders can have same groupid , when insert order of new group, groupid auto populated next sequence number automatically, while @ same time allowing me insert duplicate groupid different orders if need to. hope makes sense. how go doing this? (i'm using c# in end, if makes difference) one option create trigger on torder table (not fan of triggers, given criteria, can't think of option). create trigger torder_trigger on torder after insert update torder set groupid = (select coalesce(max(groupid),0) + 1 torder) inserted i.groupid n

Concatenating String in C -

this question has answer here: concatenating strings in c 5 answers i have method concatenates 2 c string. method returns new one. works fine. there way make method void, , modify first one? edit: cannot use strcopy or other function string.h library. suppose caller make sure s1 has enough space accommodate s2. char *str_glue(char *s1, char *s2) { char *r; //return string int len1, len2; int i, j; len1 = str_length(s1); len2 = str_length(s2); if ((r=(char*)malloc(len1 + len2 + 1))==null) { return null; } (i=0, j=0; i<len1; i++, j++) { r[j] = s1[i]; } (i=0; i<len2; i++, j++) { r[j] = s2[i]; } r[j] = '\0'; return r; } int main() { char* x = "lightning"; char* y = "bug"; char *z = str_glue(x, y); printf("%s\n", z); } not really. *s1 char[] has fixed length. if write past length you'll st

polymorphism - Deserializing a Message multiple times with Google Protocol Buffers -

i working system extremely modular. messages can determined by 3-tuple of src, dest, type. i'm looking reimplementing our messages protocol buffers. i've read through protocol buffer polymorphism , what's right way polymorphism protocol buffers? , http://www.indelible.org/ink/protobuf-polymorphism/ what wondering has implement solution where: message header { required string src = 1 required string dest = 2 required string type = 3 } and creating separate messages where: message foo { required header h = 1 required string = 2 } separate file: message bar { required header h = 1 required uint32 num = 2 } in receiving code have like: message.parsefromstring(msgstr) if (message.type == foo) { foomessage.parsefromstring(msgstr) } else { barmessage.parsefromstring(msgstr) } if approach has been used, better or worse what's described in above links? only way found serialize/deserialize message body byte array

regex - How to extract certain words from a "disassembled" file -

i'm doing : #!/usr/bin/env/perl open file1, "<exed.exe"; open file2, ">fileinhexadecimal.txt"; binmode file1; while (<file1>) { $lines = $_; $lines = unpack("h*", $lines); chomp $lines; print file2 "$lines\n"; } close (file1); close (file2) print "finish\n"; <>; after, created other program read ".txt" file search infos. with script, i'm creating text file containing hexadecimal data of .exe file. great problem : 1- want extract line regexp : /8b55-(.*)-8b55/ (with second script, wasn't posted here) 2 - here problem : ever file.txt : 8b55-646464-8b558b55-636363-8b55 8b55-656565-8b558b55-666666-8b55 when run script, script pop these data : "646464", "656565". you still not understanding question. want extract : 646464, 636363, 656565, 666666 . script, when found first match, he's jumping next line, don't reading rest. can how catch matchs ?

unit testing - Mock static method with GroovyMock or similar in Spock -

first-timer here, apologies if i've missed anything. i'm hoping around call static method using spock. feedback great with groovy mocks, thought i'd able past static call haven't found it. background, i'm in process of retrofitting tests in legacy java. refactoring prohibited. i'm using spock-0.7 groovy-1.8. the call static method chained instance call in form: public class classundertest{ public void methodundertest(parameter param){ //everything else commented out thing = classwithstatic.staticmethodthatreturnsaninstance().instancemethod(param); } } staticmethod returns instance of classwithstatic instancemethod returns thing needed in rest of method if directly exercise global mock, returns mocked instance ok: def exercisethestaticmock(){ given: def globalmock = groovymock(classwithstatic,global: true) def instancemock = mock(classwithstatic) when: println(classwithstatic.staticmethodthatreturnsaninstance().insta

python - How do I run pycdc? -

i trying decompile .pyc .py avoid rewriting code, don't understand instructions given in description on the page pycdc on github . i downloaded it, how run decompiler? says ./bin/pycdc [path pyc file] i'm not sure means. typed in command prompt , doesn't recognize it. need do? this ./ notation applies unix shell commands. not apply windows. means have run pydc [path pyc file] , [path pyc file] , directory pyc file. example: if pyc file named example.py , located in c:\users\bobby\example.py type: python pycdc c:\users\bobby\example.py

jquery - Google Maps Simulating Random Movment -

i planning building application simulate movement on google map not seeing examples of want. movement want movement along random paths want move pin forward particular predefined point without breaks or skipping points after time lets after 10 mins of moving in 1 direction turn left or right, stop, forward or backward , on. i not want use defined paths. doesn't matter if movement goes off road, once movement happening in order without breaks. want able log movement every 10 seconds. not sure event listener have registered handle or how handled. i implements using jquery . accepting advice, examples , demos ( examples not have in form of code snippets. can formula on how modify longlat coordinates simulate path ). if know how increment longlat coordinate make movement forward have no understanding of how manipulate longlat coordinates. this think: find way increment coordinates move straight modify degrees turn , move again turn , on. google have noce tool call

wampserver - after created alias directory service wamp not running -

i using wamp server version 2.2 i have create alias name , after alias created wamp servervice not running it's turned yellow not blue.. what's wrong ? alias /yudeth/ "d:/yudeth/" <directory "d:/yudeth/"> options indexes followsymlinks multiviews allowoverride order allow,deny allow </directory> since using wamp 2.2 can create alias directly system tray icon .. see post

Alert dialog dismissed while rotating phone in android -

i had give permission in manifest activities in app activity re-starting while rotating phone. restart dismissing alert box, again calling web server fetching data , activity maintain previous state. had tried possibilities can not solution. how can fix issue? @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.station_list_layout); constantvalues.current_activity=stationlistactivity.this; constantvalues.nearest_place_menu_slider_flag=false; constantvalues.message_menu_slider_flag=false; constantvalues.station_list_menu_slider_flag=true; orientation=getresources().getconfiguration().orientation; userandmessagecount=new userandmessagecount(); ((textview)findviewbyid(r.id.stationlist_route_name)).settext(constantvalues.route_name); list = (listview) findviewbyid(r.id.mylistview); cursor cursor=new updateloc

python - Search a list using a string -

i have list of lists: = [['andy', 'dear', 'boy', 'tobe', 'todo'], ['where', 'what', 'when', 'how'], ['korea', 'japan', 'china', 'usa'], ['tweet', 'where', 'why', 'how']] i have three questions exact: how retrieve sub-list list using particular element keyword? instance, want retrieve lists having element 'why' in them? is best possible way of doing so? how retrieve sub-list list using part of particular element keyword? instance, want retrieve lists having elements containing 'wh' beginning characters of of elements? how position or index of resulting sub-lists of these 2 searching methods? i familiar concept of retrieving elements list matching particular keyword, confusing when comes retrieve lists matching particular keyword... any guesses? in advance. simple , straight elem =

SQL date formatting -

i have datetime column in table. how display time? say, value in column 2013-03-25 08:40:00.000 . how display value 08:40 alone? thanks in advance. try select convert(varchar, getdate(), 8) or select substring(convert(varchar, getdate(), 8), 1, 5) if want hh:mm for more date formatting in sql server see this

sql - copy content from table into stored procedure for backup and storage -

i've got question raising errors , copying contents table stored procedure. what need move employee information archive table storage , backup,raise error messages when employee number not exist, , move employee records have no sales, i'm stuck on after i've made sure both sale number , employee number not null. here have far: create procedure archiveemployeetranactions ( @salenumber int, @employeenumber int ) select sale.employeenumber, employee.firstname, employee.lastname, sale.salenumber employee inner join sale on employee.employeenumber = sale.employeenumber if @salenumber null begin raiserror ('please enter valid sale number',16,1) end else begin if

php - MySQL Error: Unknown system variable CHARACTER_SET -

i using character_set utf8 in sql execution part , got error, mysql error: unknown system variable character_set here code, $this->runquery('execute','set character_set utf8'); // error getting line. there no character_set variable, use character set instead - set character set utf8;

kineticjs - Kinetic JS - Put length of a line on top of it -

i calculating length of line draw on canvas using following: layer.on("mouseup", function () { moving = false; var mousepos = stage.getmouseposition(); x2 = mousepos.x; y2 = mousepos.y; $("#distance").val(calculatedistance(x1, y1, x2, y2)); }); function calculatedistance(x1, y1, x2, y2) { var distance = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); distance *= 0.264583333; distance = math.round(distance * 100 / 1) / 100; return distance; } currently putting distance in input field; add lable line! demo @ http://jsfiddle.net/user373721/xzead/1/ . i appreciate suggetions, in advance. you need midpoint , label. customize fit needs. http://jsfiddle.net/xzead/2/ var midx = (line.getpoints()[0].x + line.getpoints()[1].x)/2; var midy = (line.getpoints()[0].y + line.getpoints()

undefined - AngularJS directive with ng-repeat not redering -

the problem have manage list of gum balls retrieved service. directive i've created seems work when hardcode elements in html, when attempt dynamically allocate gum balls using ng-repeat. html <div ng-controller="gumballsctrl"> <h1>working</h1> <ul> <li ng-repeat="gumball in gumballs"> <div class="gumballcolor{{gumball.color}}">{{gumball.color}}</div> </li> </ul> <h1>problem - expecting same result @ work version</h1> <ul> <li ng-repeat="gumball in gumballs"> <mygumball id={{gumball.id}} color="{{gumball.color}}">{{gumball.color}}</mygumball> </li> </ul> </div> javascript var myapp = angular.module('myapp', []); function gumballsctrl($scope, gumballs) { $scope.gumballs = gumballs; } myapp.factory('gumballs', function (

c# - How do I allow only one hyphen (-),only one space( ),only one apostrophe (') in a regular expression -

i have text box last name of user. how allow 1 hyphen (-),only 1 space( ),only 1 apostrophe (') in regular expression you can use negative lookahead each of 3 chars want avoid : ^(?!.*-.*-.*)(?!.*'.*'.*)(?!.*\s.*\s.*)[a-za-z- ']+$

jquery - Having trouble returning the correct values for one element in this function -

i'm having trouble getting 'var haslining' function work properly. should return "0" or "1", depending upon if there lining. can't figure out why, causing function return wrong answer (i'm not sure what's happening, looks it's giving value next equation). i've posted fiddle demonstrate problem: jsfiddle.net/chayacooper/9nkjt/1 var isthickerfabric = function() { var item = $("[name=item]").val(); return item == "blazer" || item == "jacket" || item == "outerwear"; } var haslining = function() { var lining = $("[name=lining]").val(); return lining != "0"; } $("[name=item],[name=fabric_type],[name=lining]").change(function(){ if ( $("[name=fabric_type]").val() === "satin" ) { var fabricthicknesselement = $('[name=fabric_thickness]'); if ( isthickerfabric() && !haslining || !isthickerfabric() &&

rubygems - Rails: error while installing rubyracer -

i running 'bundle install' on linode server. not able install cause of rubyracer. bundle install output is: installing therubyracer (0.11.0) gem::installer::extensionbuilderror: error: failed build gem native extension. /usr/local/bin/ruby extconf.rb checking main() in -lpthread... yes *** extconf.rb failed *** not create makefile due reason, lack of necessary libraries and/or headers. check mkmf.log file more details. may need configuration options. provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby --with-pthreadlib --without-pthreadlib --enable-debug --disable-debug /usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in `build_with_rubygem_libv8': undefined local variable or method `libv8_include_flags' main:object (nameerror)

ef code first - Entity framework TPT hierarchy not working for deep hierarchy when reading values from database -

i have 3 tables: duty task :duty processtask : task i'm using tpt hierarchy , seems fine when creating database. when read values database, i'm not getting values duty table. query: var tasks = _dbcontext.duties.oftype<task>() .oftype<processtask>() .where(c => c.parentid == id); only values task , processtask returned, although sql query returned correct values (i checked sql profiler). why not map first abstract class' fields? appreciated. my source code: public class duty { public int id { get; set; } } [table("task")] public class task : duty { public int id { get; set; } public int? duration { get; set; } public int? noofrepeats { get; set; } } [table("processtask")] public class processtask : digibob.model.governance.duties.task { public int processtasktypeid { get; set; }

c# - button click method doesn't work as it's visibility changes -

i have picturebox(called pic_image) , 2 buttons(called btn_addimage & btn_removeimage). want make buttons visible user moves mouse on pic_image , make them invisibe mouse leaves pic_image. code making visible: private void pic_image_mousemove(object sender, mouseeventargs e) { btn_addimage.visible = true; btn_removeimage.visible = true; } and code making invisible: private void pic_image_mouseleave(object sender, eventargs e) { btn_addimage.visible = false; btn_removeimage.visible = false; } the problem after use pic_image_mousemove method onbutton click method doesn't work. thanks in advance mouse movie events continuously fires until mouse on picture replace mouse move mouse enter private void pic_image_mouseenter(object sender, mouseeventargs e) { btn_addimage.visible = true; btn_removeimage.visible = true; if (pic_image.image != null) btn_removeimage.visible = true; }

java - How to be sure about Integer value of a JTextfield? -

this question has answer here: is there way accept numeric values in jtextfield? 19 answers restricting jtextfield input integers [duplicate] 6 answers i have jtextfield users must enter number in that. i want check value sure contains * *integer* . * here code: jtextfield tex_amount=new jtextfield(); . . . string s=tex_amount.gettext(); int a=integer.parseint(s); the problem if user enter string in field face error: java.lang.numberformatexception . how can check value? you can use try..catch try{ int = integer.parseint(s); } catch(arithmeticexception e){ //handel error here }

c# - relationship between configuration in app.config or web.config and code in WCF -

how service host in wcf interact configuration web.config or app.config. when create service host specify url in service host constructor , class of service. but in app.config or web.config have list of endpoints, each it's own specific url. how wcf handle situation? endpoint take app.config or web.config? the address of endpoint relative base address of service host. example, if had these endpoints: <service name="myservice"> <endpoint address="" binding="ws2007httpbinding" contract="imyservice" /> <endpoint address="mex" binding="mexhttpbinding" contract="imetadataexchange" /> </service> and service host url of http://localhost:7777 , exposing service on http://localhost:7777 , , metadata on http://localhost:7777/mex .

map - Trying to make the wireworld move by fmap (transition) but it shows me an error somehow (Haskell) -

the same last question, im asked make wireworld ordered lists, have written following codes,(all of function in code somehow defined in other modules, so, dont worry xd, feel free ask me if u want have @ "predefined funcs") when run on terminal, shows error, here code: module transitions.for_ordered_lists_2d ( transition_world -- :: ordered_lists_2d cell -> sparse_line cell ) import data.cell (cell (head, tail, conductor, empty)) import data.coordinates import data.ordered_lists_2d -- replace function more meaningful: xandy :: element_w_coord cell -> coord xandy (e, (x, y)) = (x, y) transition_sc :: ordered_lists_2d cell -> placed_elements cell -> sparse_line cell transition_sc world pec = case world of sparse_line{y_pos = y, entries = xline}: rest_of_sparse_lines -> case pec of placed_element{x_pos = x, entry = head} : rest_of_placed_elements -> (sparse_line{y_pos = y, entries = placed_element{x_pos = x, entry = tail} : rest_of

html - How to move the scroll bar of the browser on a pdf file with ASP / Javascript? -

Image
i looking time if there free apis / or other projects in order move scroll bar of browser position of item referred pdf document. redirect user pdf file of site ("/ help.pdf") directly desired position .(on title or page number, example) , not on position (x or y) varies according screen resolution. you can passing parameters link : <a href="http://www.example.com/myfile.pdf#glossary"> goes glossary <a href="http://www.example.com/myfile.pdf#page=3"> goes page 3 http://helpx.adobe.com/acrobat/kb/link-html-pdf-page-acrobat.html

php - How to use array_diff_key properly? -

i have array array ( 500 => array ( 1 => 1, 6 => 2, 2 => 1, ), 550 => array ( 3 => 1, 6 => 2, 4 => 1, 5 => 1, ), ) how next result? array( 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, ) i trying use array_diff_key / array_intersect_key , can't goal. suggestions? upd. i don't need iterations. direct array_* functions only. you might looking key difference of union , key intersection: $array = array_diff_key( ($a = $array['500']) + ($b = $array['550']), array_intersect_key($a, $b) ); for input array give desired output ( demo ): array ( [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 )

javascript - Stop chrome back/forward two finger swipe -

i want disable 2 finger swipe causes chrome going or forward. have website user might lose progress on work if doesn't saves. i have tried using window.onbeforeunload doesn't seem work if have hashes in url (back forward change between www.example.com/work/#step1#unsaved www.example.com/work/#step0) , event doesn't seem trigger. i switch solution today noticed in google docs it's disabled. how did achieve that? you're looking @ problem @ wrong level. onbeforeunload not triggered because there nothing being unloaded browsers perspective. therefore have, quite bluntly, implemented wrong mechanism versioning - fragments page states, not document states using now. if insist on maintaining state through hash fragments need use mechanism guard against page state changing. since current browsers support localstorage i'd use that. , well, while @ it, put document state data there instead of in url, since how google docs , why don't have issue.

Connect to MySQL from Excel -

Image
i'm trying connect mysql database using 'from sql server' option in excel. gave connection details: server address , username , password , connection doesn't through. should make changes on server side make connection possible? thanks might provide. sql server specific rdbms product microsoft; is, competing product mysql. want use "from microsoft query", provided have mysql odbc connector installed.

.net - Using set in a C# class -

i have following class: public class class1 { private int pam1; public class1() { } public void changepam1(int _newvalue) { updatepam1(_newvalue); pam1 = _newvalue; } public int pam1 { set { this.pam1 = value; } { return this.pam1; } } } currently, when want change value of pam1 , following: int n = 500; class1 c1 = new class1(); c1.changepam1(n); how can change using set ? you can (it call set ): public class class1 { private int pam1; public class1(){} private void chancepam1(int newvalue) { updatepam1(newvalue); pam1 = newvalue; } public int pam1 { set { chancepam1(value); } { return this.pam1; } } } then: int n = 500; class1 c1 = new class1(); c1.pam1 = n; also have @ this .

regex - Rewrite engine. How to translate URL -

i new regular expressions , rewrite engine i want translate: domain.com/type/id on domain.com/index.php?type=type&id=id i use rewriterule (\w+)/(\d+)$ ./index.php?id=$1&type=$2 i works fine , able 2 variables website has problem including other files. main url is: http://domain.com/repos/site , after trying type url http://domain.com/repos/site/ee/9 , firebug says: "networkerror: 404 not found - http://domain.com/repos/site/ee/lib/geoext/script/geoext.js " it seems site takes "ee" part of ulr, not variable. yes, have change paths. paths behavior: - href="mypath": append "/mypath" url current url - href="./mypath": same before - href="/mypath": append mypath to root . behavior want note: can use "../" come parent directory of are.

android - QR scanner with ZXing and ZBar doesn't read low quality codes on cards -

Image
i have made applications using zxing , zbar both. both working fine , read good quality qr codes always. but problem when scan code on card not nice in quality never scans. tried 5 mp camera device same results. tried many apps google play store neither of them worked. card not of bad quality. can tell me solution or suggest other api that. know not api quality of qr code. appreciated. this card image try these settings on imagescanner, scanner = new imagescanner(); //slows frame, job scanner.setconfig(0, config.x_density, 1); scanner.setconfig(0, config.y_density, 1); scanner.setconfig(0, config.enable, 0); // enable codes app requires scanner.setconfig(symbol.qrcode, config.enable, 1); made huge difference in app.

Android Java Code : Convert column values in to rows? -

i have table value in sqlite like.. 101 local local local local local local 102 9 12 9 12 9 9 1 3:55 4:20 4:40 5:00 5:20 5:40 18 4:50 5:15 5:35 5:55 6:15 6:35 above value need store in arraylist> listdata = new arraylist>(); or other arrays local 9 3:55 4:50 local 12 4:20 5:15 local 9 4:40 5:35 local 12 5:00 5:55 local 9 5:20 6:15 local 9 5:40 6:35 plz me find :) i think best way create domain/container-object table entitys. public class tableentity { private int col1; private string col2; private string col3; // generate getters , setters... } then reading values of sqlite table create new object , return arraylist: arraylist<tableentity> lalltableentitys = new arraylist<tableentity>(); while(cursor.movetonext()){ tableentity tableentity = new tableentity(); tableentity.setcol1(cursor.getstring(cursor.getcolumnindex("col1&q

Changing Netty 4 HTTP File Server example to use ChunkedStream instead of ChunkedFile -

i'm trying wrap head around netty 4 way of implementing http server serve httpresponses bodies using chunked transfer-encoding when total data size unknown. as starting point, changed httpstaticfileserverhandler (found in https://github.com/netty/netty/tree/netty-4.0.0.cr1/example/src/main/java/io/netty/example/http/file ) use chunkedstream instead of chunkedfile (they both chunkedbyteinputs). i understand not ideal in original example use case use fileinputstream think makes example reusing known code. so, here diff against httpstaticfileserverhandler class io.netty.example.http.file package (vs. 4.0.0.cr1): diff --git a/example/src/main/java/io/netty/example/http/file/httpstaticfileserverhandler.java b/example/src/main/java/io/netty/example/http/file/httpstaticfileserverhandler.java index 904579b..0d3592f 100644 --- a/example/src/main/java/io/netty/example/http/file/httpstaticfileserverhandler.java +++ b/example/src/main/java/io/netty/example/http/file/httpstaticfiles

c# - Sync Fx: Succeesfully synchronize but no data were synchronize -

i've made winform application data synchronization offline scenario using sync fx. problem when synchronize database, application give me message said application synchronized (complete number of rows synchronized) when check @ database data not synchronized , still same. idea why happened? and want know, possibilities makes data failed synchronize? subscribe applychangefailed event of providers see if error or conflict encountered during sync. you might want expound databases synching (sql ce?, sql express, server, localdb, azure?) , change failing (inserts, updates, deletes?)

unity3d - object movement as wave in Unity 3d -

Image
i created object in unity gameobject monsterclone = (gameobject)instantiate(monsterprefab, floorposition, quaternion.identity); this object should move in wave style limit1 limit2. then move limit2 limit1. y position x position have change in specific way. vector3 npos = mfloorpos + new vector3(2f, 0f, 0f); vector3 opos = mfloorpos + new vector3(-2f, 0f, 0f); how can it? i can't write code without knowing more specific think question asked link out move object wave edit: i think flat , float down functionality work moving 1 point example: var floatup; function start(){ floatup = false; } function update(){ if(floatup) floatingup(); else if(!floatup) floatingdown(); } function floatingup(){ transform.position.y += 0.3 * time.deltatime; yield waitforseconds(1); floatup = false; } function floatingdown(){ transform.position.y -= 0.3 * time.deltatime;; yield waitforseconds(1); floatup = true; } example taken from

asp.net - How to change Chrome required field processing -

i have input fields required attr <input id="name" required="" placeholder="write name"> additionally have button makes post , other link makes postback well. but in case input field has't data chrome block post-back action, , show chrome pupup box information need fill data on form. in same time ie allows it. how resole ? of course can remove attribute javascript before post-back action, not sure right way. i think shouldn't count on html5 required attribute since (in case of ie) ie 10+ supports (see "form validation" section here: web forms - dive html5 ). of course, same goes placeholder attribute in cases it's can live (and having working validation more critical). i think should use validation functionality provided asp.net itself, it's easy started , can make work , without javascript enabled on client. more info here: understanding asp.net validation techniques .

php - How can i make to get not only by id but by one more column also -

this model public function get_news($newsid= false) { if ($newsid === false) { $this->db->select('*'); $this->db->from('news'); $this->db->where('status' , 1); $this->db->where('language' , 2); return $query->result_array(); $config['per_page']; $this->uri->segment(3); } $query = $this->db->get_where('news', array('newsid' => $newsid)); return $query->row_array(); controller public function single($newsid) { $data['news_item'] = $this->news_model->get_news($newsid); if (empty($data['news_item'])) { show_404(); } $data['newsid'] = $data['news_item']['newsid']; $this->load->view('news/single', $data); } view <?php echo $news_item['tittlen

how to change date format in java? -

i getting date input string in format dd-mm-yy through jsp page. because format better understand . want store date in yyyy-mm-dd hh:mm:ss format in database. using following code. try { string s="30-04-2013"; simpledateformat ft = new simpledateformat("yyyy-mm-dd hh:mm:ss"); d1=new simpledateformat("yyyy-mm-dd").parse(s); system.out.println(d1); system.out.println(ft.format(d1)); } catch(exception e) { system.out.println("exception:"+e); } my jsp date format dd-mm-yy , gives answer as tue oct 04 00:00:00 ist 35 0035-10-04 00:00:00 what mistake? can tell me please thank you. d1=new simpledateformat("yyyy-mm-dd").parse(s); should d1=new simpledateformat("dd-mm-yyyy").parse(s); because input date string you've provided string s="30-04-2013"; of format, dd-mm-yyyy . hence, parse this, need give dd-mm-yyyy format in sdf.

r - How do I plot the 'inverse' of a survival function? -

Image
i trying plot inverse of survival function, data i'm increase in proportion of event on time. can produce kaplan-meier survival plots, want produce 'opposite' of these. can kind of want using following fun="cloglog" : plot(survfit(surv(days_until_workers,workers)~queen_number+treatment,data=xdata), fun="cloglog", lty=c(1:4), lwd=2, ylab="colonies workers", xlab="days", las=1, font.lab=2, bty="n") but don't understand quite has done time ( i.e. doesn't start @ 0 , distance decreases?), , why survival lines extend above y axis. would appreciate this! cheers use fun="event" desired output fit <- survfit(surv(time, status) ~ x, data = aml) par(mfrow=1:2, las=1) plot(fit, col=2:3) plot(fit, col=2:3, fun="event") the reason fun="cloglog" screwing axes not plot fraction @ all. instead plotting according ?plot.survfit : "cloglog" create

Android: Send Multiple sms on one click -

i developing sms sending application. code running fine. able send sms application using following code : private void sendsms(string phonenumber, string message, final int k){ string sent = "sms_sent"; string delivered = "sms_delivered"; intent sentintent = new intent(sent); intent delivereduntent = new intent(delivered); pendingintent sentpi = pendingintent.getbroadcast(this, 0,sentintent, 0); pendingintent deliveredpi = pendingintent.getbroadcast(this, 0,delivereduntent, 0); //---when sms has been sent--- sentreceiver = new broadcastreceiver() { @override public void onreceive(context arg0, intent arg1) { switch (getresultcode()){ case activity.result_ok: toast.maketext(getbasecontext(), "sms sent "+k,toast.length_short).show(); break; case smsmanager.result_error_generic_failure: to

python - Object of type NoneType using threads -

i have following class queue = queue.queue() class spectraprocessing(threading.thread): def __init__(self, queue, pbar = none, image_infos = []): threading.thread.__init__(self) self.queue = queue self.pbar = pbar self.image_infos = image_infos def run(self): while true: spectrum = self.queue.get() self.image_infos.append(get_spectruminfos(spectrum)) #signal queue job has been done if self.pbar: self.pbar.update(self.pbar.currval + 1) self.queue.task_done() msrun iterator on spectrum objects created class reader: msrun = pimzml.run.reader(file_imzml, file_ibd, msn_precision = 250e-6) each spectrum object has attribute list will(initially []) contains intensities (float values). main function contain this: number_spectra = len(msrun) print "start creating image spectra..." pbar = progressbar( maxval = number_spectra ).start() #spawn pool of threads, , pass th

jsp - How to store the body of a JSTL custom tag into a variable? -

i create custom jsp tag can used this: <mytags:mytag> <p>my content!</p> </mytags:mytag> in tag, process content of body use other attribute. so, tag definition - body not attribute something else. mytag.tag: <%@taglib prefix="mytags" tagdir="/web-inf/tags/mytags" %> <%@attribute name="body" required="true"%> <div> <c:if test="${fn:contains(body, 'test')}"> <p>found test string<p> </c:if> </div> obviously, <jsp:dobody/> or <jsp:invoke fragment="body" /> not me. also, seem bit overly complicated create java tag purpose. it possible capture body content using <jsp:dobody> action through var attribute demonstrated in this article. body content added attribute pagecontext of tag file , can accessed through expression. mytag.tag <%@ taglib prefix="c" uri="http://java.sun.

xslt - sum value of element -

i need add number of values​​, depending on content of each item. example. <links> <test element="32"/> <test element="17"/> <test element="13"/> <test element="11"/> <test element="9"/> <test element="8"/> <test element="7"/> <test element="7"/> </links> total element: 8 , sum of values ​​of each element: 104 , value show this(104). <xsl:template match="//x:span[@class='ws-filter-count']"> <xsl:variable name="countproduct" select="normalize-space(translate(text(), '()', ''))" /> <xsl:variable name="sum" select="number(0)"/> <test element="{$countproduct}" /> </xsl:template> this sum: will done call-template?, recursive, correct?. thanks. if understood correctly want achieve: stylesheet <xsl

"if" or "where" in for loop of arraylist in java? -

i'm sorry if question bit vague i'll try explain it. i got code: public string tostring() { string s = "text.\n"; (klus k : alleklussen) { s += k.tostring() + ".\n"; } return s; } but want make different loops different conditions. example, "klus" has couple of variables like: status, date etc. i'm not experienced java yet, possible this: for (klus k : alleklussen; status = "completed") {..} i know wrong i'd show "klus" objects status "completed" , "klus" objects statis "not completed". thanks , if unclear or used wrong word something, please tell me. edit: it should make this: if (k.getstatus().equals("completed"){ string s = "completed ones \n" s += k.tostring() + ".\n"; //get completed ones } if (k.getstatus().equals("uncompleted"){ string s = "uncompleted ones \n" s

ios - is retina working in my developer iphone? -

i'm testing app in iphone5. i duplicate image, named image1.png , image1@2x.png, , tried in iphone5, in part of code: uiimage *myimage = [uiimage imagenamed:@"image1.png"] ; cgfloat imagewidth = myimage.size.width; cgfloat imageheight = myimage.size.height; nslog(@"image %f %f", imagewidth,imageheight); cgrect screenbound = [[uiscreen mainscreen] bounds]; cgsize screensize = screenbound.size; cgfloat screenwidth = screensize.width; cgfloat screenheight = screensize.height; nslog(@"screen %f %f", screenwidth, screenheight); and when running in iphone, in console see: 2013-04-05 13:13:48.386 vallabici[2413:907] image 320.000000 57.000000 2013-04-05 13:13:48.389 vallabici[2413:907] screen 320.000000 568.000000 as using normal screen instead of retina. how can be? the size of image should not change on retina device, scale. take scale of image add following log: nslog(@"scale %f", myimage.scale);

Get JSON objects in PHP, not array -

im writing website in php gets jsonstring php-api ive created. string looks this: { "result": "true", "results": { "20": { "id": "20", "desc": "a b ct tr", "active": "1", "startdate": "2013-04-03", "starttimehour": "18", "starttimemin": "0", "enddate": "2013-04-03", "endtimehour": "22", "endtimemin": "0", "creator": "a" }, "21": { "id": "21", "desc": "test", "active": "0", "startdate": "2013-04-04", "starttimehour": "18",

Git - local branches , update from remote -

i've setup git environment (mo github) have remote: 1 branch local: master branch , featurex branch work on it/ now, on remote teammate pushed on remote feature on remote want on feature branch. which right steps that? the concept of remote , local branches can little bit confusing in beginning. if want keep local branch "master" in sync remote branch git pull suggested in answer here way of doing so. there way of keeping remote branch while still working on featurex branch without leaving branch: merge friends changes directly remote branch. git fetch git merge origin/master

r - How to capture execution error (stderr connection) into a string variable? -

with stdout connection can use [capture.output][1] function. error messages? this of course require form of try block. faik try block doesn't provide way access string of actual error messages repressed. can me, please? use trycatch , conditionmessage trycatch(stop("oops"), error=function(err) conditionmessage(err)) provide reproducible example more help.

jquery - Showing a hidden link upon clicking another link -

i have page show 2 graphs, different information in them, depending on link clicked @ top of page (adding variable in address line). when clicking link, want have button appear below graphs, adding option download entire database. i have looked this, , found solution "should" work, not. my menu: <div class="menu"> <a href="mf.html?area=ac">kma</a> <a href="mf.html?area=oc">kmo</a> </div> the jquery (placed inside docuemnt.ready function): $("#menu").click(function () { $("#downloadlink").show(); }); and lastly, link want make appear: click here download databse the above not work. if provide on matter, appreciated, im quite frankly getting bit frustrated, close weekend! thanks in advance, jon. try: $(".menu a").click(function () { $("#downloadlink").show(); });

java - Caliper: micro- and macro benchmarks -

for elki need (and have) more flexible sorting implementations provided standard java jdk , collections api. (sorting not ultimate goal. use partial sorting bulk loading index structures such k-d-tree , r*-tree, , want make rather generic implementation of these available, more generic in elki - either way, optimizing sort means optimizing index construction time). however, sorting algorithms scale differently depending on data size. tiny arrays, known fact insertion sort can perform (and in fact, quicksort implementations fall insertion sort below threshold); not theory cpu pipelining , code size effects not considered sorting theory. so i'm benchmarking number of sorting implementations find best combination particular needs; want more flexible implementations on par jdk default implementations (which fine tuned, maybe different jdk version). in long run, need these things easy reproduce , re-run. @ point, we'll see jdk8. , on dalvik vm, results may different on ja

sql - Deadlock vs. Logging -

web application. c#, sql 2k8 in list, there lot of things going on, before actual dynamic sql gets executed, , returns desired records. recently added code whole app (deadlock issues) transaction commit, , rollback , retry x times, whole 9 yards. that big plus, needed that. but in order debug possible issues list, saving dynamic sql string in log table (which doesn't store old records last couple of weeks) problem is: right there no log, if list crashes. because of rollback stuff ... my best idea far call list twice: "check" - mode, create dynamic sql, save in log tbl, not exec "list" - mode either: 2a. recalculate dynamic sql or 2b. reuse dynamic sql created "check - mode either 2a or 2b, should not have huge performance issue, because expensive part of list stored procedure actual execution of dynamic sql. "check" - mode basic string concatenation. the deadlock retry part second db call, good! still. not happie

perl - directory tree warning -

i have writed script, recursively print's directory's content. prints warning each folder. how fix this? sample folder: dev# cd /tmp/test dev# ls -p -r test2/ testfile testfile2 ./test2: testfile3 testfile4 my code: #!/usr/bin/perl use strict; use warnings; browsedir('/tmp/test'); sub browsedir { $path = shift; opendir(my $dir, $path); while (readdir($dir)) { next if /^\.{1,2}$/; if (-d "$path/$_") { browsedir("$path/$_"); } print "$path/$_\n"; } closedir($dir); } and output: dev# perl /tmp/cotest.pl /tmp/test/test2/testfile3 /tmp/test/test2/testfile4 use of uninitialized value $_ in concatenation (.) or string @ /tmp/cotest.pl line 16. /tmp/test/ /tmp/test/testfile /tmp/test/testfile2 may try code: #!/usr/bin/perl use strict; use warnings; browsedir('/tmp'); sub browsedir { $path = shift

java - Securing RESTful webservices (Jersey on Tomcat) -

i have implemented number of web services using jersey . need secure them. means need encrypt data transferred , authenticate users. server i'm using tomcat is there articles , tutorials this? for encryption can use https in tomcat. here guide on how it. authentication can use have @ post . hope helps !!

javascript - google maps multiple markers clickevent -

im looping , placing markers, when click marker, respond same value here code for(a=0; < prod.length; a++){ // add marker map var mylatlng = new google.maps.latlng(prod[a]['lat'],prod[a]['lon']); var marker = new google.maps.marker({ position: mylatlng, map: map, title: prod[a]['name']+" \n"+prod[a]['description'], icon: image }); google.maps.event.addlistener(marker, "click", function() { show_details(a); }); } function show_details, has same value i have looked @ other answers here didnt solve problem. tipical problem in async programming/scripting. a variable passing, when click event runs, , value of after for loop finishes. should create inner function scope, , save value of a in variable, lives in scope. solution: (function(z){ google.maps.event.addlistener(marker, "click", function() { show_details(z); }); })(a); the a

android - How could I swipe view using Fling Gesture -

Image
i need swipe views using fling gestures how that have searched alot got idea like: @override public boolean onfling(motionevent e1, motionevent e2, float velocityx, float velocityy) { string swipe = ""; float sensitvity = 50; // todo auto-generated method stub if((e1.getx() - e2.getx()) > sensitvity){ swipe += "swipe left\n"; swipeleft(); }else if((e2.getx() - e1.getx()) > sensitvity){ swipe += "swipe right\n"; }else{ swipe += "\n"; } if((e1.gety() - e2.gety()) > sensitvity){ swipe += "swipe up\n"; }else if((e2.gety() - e1.gety()) > sensitvity){ swipe += "swipe down\n"; }else{ swipe += "\n"; } gestureevent.settext(swipe