Posts

Showing posts from January, 2013

networking - How To Chain SSH Tunnels -

i trying set simple ssh tunnels chain. i have following machines: local machine, @ 10.0.0.1. remote machine, @ 10.0.0.2. i have following programs: client.py: import socket client_host = [...] client_port = [...] sock = socket.socket(socket.af_inet, socket.sock_stream) sock.setsockopt(socket.sol_socket, socket.so_reuseaddr, 1) sock.connect((client_host, client_port)) sock.send('test') sock.close() server.py: import socket server_host = [...] server_port = [...] server = socket.socket(socket.af_inet, socket.sock_stream) server.setsockopt(socket.sol_socket, socket.so_reuseaddr, 1) server.bind((server_host, server_port)) server.listen(1) client = server.accept()[0] print client.recv(1024) client.close() server.close() now: i run client.py (client_host='127.0.0.1', client_port=8000) , server.py (server_host='', server_port=8000) on same machine, , works expected. i run client.py (client_host='127.0.0.1', client_port=8000) on l

javascript - Remembering a User Preference with a Cookie -

i want present users 2 options upon entering websites homepage foo.com . button 1: continue in english (takes them foo.com/english.html) or button 2: continue in spanish (takes them foo.com/spanish.html) a checkbox present, if check remember choice , upon returning foo.com go directly english.html or spanish.html based on previous selection. i have never used cookies before, , having hard time wrapping head around how this. examples have seen cookies basic, seems more complex me. any appreciated! in advance. there number of cookie libraries , jquery extentions available if find difficult dealing them discreetly , g* search should return plenty. a couple are: cookies.js jquery cookies an alternative cookies use html5 localstorage

javascript - Trying to flip the output if element will land off screen -

var $elem = elem; var position = $elem.position(); var output = {}; var winx = $(window).height(); var winy = $(window).width(); output.width = $elem.width(); output.height = $elem.height(); output.bottomleftx = position.left;//left top output.bottomlefty = position.top + output.height;//left bottom output.bottomrightx = position.left + output.width;//right top output.bottomrighty = position.top + output.height;//right bottom if(position.left > 0 && position.top > 0 && position.left+output.width < winy && position.top+output.height < winx) { //something } else { alert('not gonna fit') } return output; no matter way try this, can't seem right, above last attempt before coming here trying on this. tring position of element in dom, , based on position show element. kind of tool tip different in few aspects. anyway. trying figure out how can flip outputs around if need in event element show going go off screen , in will, wan

gwt - Add id to field with ui:field declaration -

i'm trying declare these elements in uibinder xml: <label for="lastname">last name:</label> <input type="text" id="lastname" ui:field="lastnamefield" maxlength="150" /> simply put, label associated text input. when try compile, however, error: [error] cannot declare id="lastname" , ui:field="lastnamefield" on same element element (:23) this seems idiotic restriction, since ui:field doesn't generate id. solution i've found far assign id in java code this: @uielement inputelement lastnamefield; ... lastnamefield.setid("lastname"); this adds needless clutter java. adds complication if id gets updated somewhere down line, <label> declaration in xml need updated (and there's no @uielement label, it's pretty invisible java side.) is there way add id element ui:field declaration within uibinder xml itself? uibinder uses id implement ui

javascript - Down-Sized Images are Slow in Chrome -

i'm working on script , have issue chrome. here's i'm doing: 1. loading large images div. 2. scaling images fit size of div. 3. when browser resized, image scaled , down browser. everything working 100% in browsers except chrome. i've checked profiler in chrome , don't see unusual. these large images, working fine (even live) in other browsers. i've read ton of places have noted issue when using down-sized images in chrome...but not solution. nothing special going on, using var img=new image(); $(img).load(function(){ .... {); does know of workaround or solution work in chrome? thanks! so appears chrome sucks when comes handling large images , images aren't large, scaled down. i've searched around endlessly find similar questions without resolutions. still not sure why other browsers (even ie 7 , 8) can handle large images (tested 7mb scaled-down pngs), chrome can't manage 700kb scaled-down jpg without lagging. so, i

c# - LINQ-XML How should I get the error XML node with given error attribute -

here xml get resultcode attribute, if error product's child nodes <product action="result" resultcode="error" resulttext="an error occurred in child element."> <pno>9723151113</pno> <catalog_no resultcode="error" resulttext="invalid entry field.">1134</catalog_no> </product> so first want check wheather node's attribute has error , select child node , descendent child node has error , node using linq. above,look nodes under cust check attribute 'resultcode', if has error value select node , thier child nodes find out exact error. cust -> node error ? -> product => select product => child nodes under product => select error attribute node. i don't want put logic wil parse each , every node in loop, thinking linq use easy .any idea how achive using linq query? try one: var xdoc = xdocument.load(@"you

PHP/MySQL update statement inserting a 0? -

i creating "edit" page content on website stored in mysql database. can without problems reason having annoying problem here it. i have title , message boxes wish update in database , when update query sent, title saved correctly, message seems add single "0" field? here php validation removed (the problem still occurs without it): if(isset($_post['savechanges'])){ $title = mysql_real_escape_string(stripslashes($_post['message'])); $message = mysql_real_escape_string(stripslashes($_post['title'])); $savequery = "update messages set message = '$message' , title = '$title' id = '$postid'"; $saveresult = mysql_query($savequery); if($saveresult){ //do } else if(!$saveresult){ //do } } html form: <form action="edit.php" method="post"> <input name="title" type="text"> <textarea name="message"></textarea> <button

MYSQL Select By This Week -

i have user can see uploaded images week. is correct? "select * images userid = '$userid' , uploadeddate >= datepart(week, uploadeddate) = datepart(week, getdate()) order uploadeddate desc"; i getting error. help. select * images userid = $userid , uploadeddate >= curdate() - interval weekday(day) day , uploadeddate < curdate() - interval weekday(day) day + interval 7 day create index on (userid, uploadeddate) work fast.

c++ - OpenGL Asymmetric Frustum for Desktop VR -

Image
i making opengl c++ application tracks users location in relation screen , updates rendered scene perspective of user. know "desktop vr" or can think of screen diorama or fish tank. rather new opengl , have defined simple scene far, cube, , rendered correctly. the problem when start moving , want rerender cube scene, projection plane seems translated , don't see think should. want plane fixed. if writing ray tracer, window fixed, eye allowed wander. can please explain me how can achieve effect desire (pinning viewing window) while having camera/eye wander @ non-origin coordinate? all of examples find demand camera/eye @ origin, not conceptually convenient me. also, because "fish tank", setting d_near xy-plane, z = 0. in screen/world space, assign center of screen (0,0,0) , 4 corners to: tl(-44.25, 25, 0) tr( 44.25, 25, 0) br( 44.25,-25, 0) bl(-44.25,-25, 0) these values in cm 16x9 display. i calculate user's eye (actually web cam on face) using p

Objectify generics compile time error with incompatible objects in Java 7 -

in java 6 following line compiles in java 7 incompatible type error (see below). ideas going on here? player player = new fplayer(); player.setid("somestring"); player.setwid(123456, "somestring"); key<player> keyforplayer = ofy().save().entity(player).now(); gets compile time error incompatible types required: com.googlecode.objectify.key<com.xx.xxxxxx.xxxxx.xxxxxx.player> found: com.googlecode.objectify.key<java.lang.object>

javascript slideshow that loads new page after last slide -

sorry, i'm quite new js. have basic html page i've put in slideshow advances slide each click. want have happen have change new page when user clicks next , on last slide. html: <div id="images"> <img id="image1" src="http://www.lorempixel.com/960/580/sports" /> <img id="image2" src="http://www.lorempixel.com/960/580/cats" /> <img id="image3" src="http://www.lorempixel.com/960/580/food" /> <img id="image4" src="http://www.lorempixel.com/960/580/people" /> </div> and js looks this: var max = 4; function gotonext() { var hash = string(document.location.hash); if (hash && hash.indexof(/image/)) { var newh = number(hash.replace("#image", "")); (newh > max - 1) ? newh = 0 : void(null); document.location.hash = "#image" + string(newh + 1); } else { d

C# Font display OpenGL -

Image
i developing 2d cad application using tao framework in windows. use fonts windows libraries display drawing information. in addition rotate scale text. bitmap fonts not this. i went through opengl font survey [http://www.opengl.org/archives/resources/features/fontsurvey/] of them c++ based apis. could guide me available solutions in c#? for 3d have followed examples found relation opentk compatible tao.framework . public void addtexture(bitmap texture, bool mipmaped) { this.tex_id = world.loadtexture(texture, mipmaped); } public void addtext(string text, color color, float x, float y, float scale) { const int side = 256; bitmap texture = new bitmap(side, side, system.drawing.imaging.pixelformat.format32bppargb); graphics g = graphics.fromimage(texture); using (brush brush = new solidbrush(color)) { g.fillrectangle(brush, new rectangle(point.empty, texture.size)); } usin

Python: how to set value to a list element -

this question has answer here: 'str' object not support item assignment in python 6 answers i have list, named mac , saves 6-bytes mac address. want set last byte 0, use: mac[5] = 0 but gives me error: typeerror: 'str' object not support item assignment how fix error? because mac str , strings immutable in python. mac = list(mac) mac[5] = '0' mac = ''.join(mac) #to mac in str or use bytearray , function mutable string. >>> x = bytearray('abcdef') >>> x bytearray(b'abcdef') >>> x[5] = '0' >>> x bytearray(b'abcde0') >>> str(x) 'abcde0'

image - jQuery Show/Hide doing something strange, hiding wrong element -

so, i've written snippet of jquery makes sense me, it's doing had not intended do. on navigation bar, on rollover, want little image appear underneath using show/hide functions. so, when hover on "home", example, want image.png appear beneath it. here's jquery. $("#home").hover( function () { $(this).show(".mustache_one"); }, function () { $(this).hide(".mustache_one"); } ); now it's doing when on hover, nothing, , when removing mouse "home", moving entire div contains navbar left hide "home" link. meanwhile, image.png never shows up. you cannot pass element id/class show or hide . besides, $this refer #home , hence it'll try show/hide home element. don't know markup, how js should look. $("#home").hover( function () { $('.mustache_one').show('slow'); }, function () { $('.mustache_one').hide('slow'); } );

actionscript 3 - AS3 Hamcrest - Assert one array contains all of another -

i attempting use hamcrest matchers come flashbuilder 4.7 environment. have 2 arrays, array , array b. want make sure of members of b found in regardless of order. i'm looking works kind of this. var a:array = new array( 1, 2, 3, 4); var b:array = new array( 1, 2, 3, 4 ); //both arrays contain same values should //return true assertthat( , haseachandeverylastoneinsideofit(b)); right i've tried 'allof' , 'hasitems' i'm not quite able grip on syntax. here's gist handle custom hamcrest matcher. usage : assertthat( , arrayexact(b) ); the matcher class : https://gist.github.com/jamieowen/5480802 and shorthand "arrayexact()" function access: https://gist.github.com/jamieowen/5480819 it should match 2d arrays well.

reporting services - Count if SSRS in textbox -

i have scenario need calculate percentage based on - no of records value/ total no of records. going textbox in header. trying following keep getting error saying "argument not specified parameter falsepart of pulbic function iif. can shed light on please? =count((iif((fields!confirmed.value, "kpi_calculation")= true,1,nothing)),"kpi_calculation") /count(fields!confirmed.value, "kpi_calculation") thanks. this worked me in simple test: =sum(iif(fields!confirmedvalue.value, 1, 0), "kpi_calculation") / countrows("kpi_calculation") it looks in above example you're declaring scope many times , hence getting syntax error.

php - trying to understand some functions related to zend -

/** * getter method, same offsetget(). * * method can called object of type zend_registry, or * can called statically. in latter case, uses default * static instance stored in class. * * @param string $index - value associated $index * @return mixed * @throws zend_exception if no entry registerd $index. */ public static function get($index) { $instance = self::getinstance(); if (!$instance->offsetexists($index)) { if ($instance->lazyload($index, $return)) { return $return; } else { throw new zend_exception("no entry registered key '$index'"); } } return $instance->offsetget($index); } ... public static function getdb() { return self::get('db'); } ... this taken xenforo/application.php, although comment clear, still have questions: $in

ruby on rails - using fields_for & paperclip multiple file update -

i 'm trying upload multiple files s3 using paperclip gem , referring this tutorial. 'm having 2 issues 1. upload tag rendered once instead of 6 times specified in controller. 2. , secondly following error whenever try edit document. activerecord::unknownattributeerror in documentscontroller#edit unknown attribute: document_id any suggestions how fix this? models/document.rb class document < activerecord::base attr_accessible :documentid, :name, :notes, :user_id belongs_to :user has_many :photos, :dependent=>:destroy accepts_nested_attributes_for :photos acts_as_taggable validates :name, :length => {:minimum =>3} validates_date :dtreminder, :on_or_after => lambda { date.current }, :allow_blank => true validates_associated :user validates_uniqueness_of :name, :scope => :user_id end models/photo.rb class photo < activerecord::base belongs_to :document has_attached_file :image, :style =>{:thumb =>

javascript - Targetting specific div through class with jquery draggable/droppable -

when dragging div using jquery ui , dropping ui droppable div, want trigger jquery animation on div being dropped area. when animation triggered, called on divs class = "drag-element" want specific dragged , dropped element animated. have tried including removeclass(".drag-element") , addclass(".animate-element") , telling animate() act on still applying animation .drag-element divs. how do fix this? jquery: $(function() { $( ".drag-element" ).draggable({ containment: ".container" }).removeclass(".drag-vid"); $( ".drop-field" ).droppable({ drop: function( event, ui ) { $(".drag-element").animate({"left": "+=50px"}, "slow"); $( ) .css("background-color", "silver"); } }); }); http://jsfiddle.net/nbhmt/ use: ui.draggable.animate({"left": "+=50px"}, "slow"); instead of: $(".drag-ele

java - Long type Integer calculation -

i making source code calculates long integers, don't know why calculation gives me wrong answer. long l; //variable l input long, signed int l *= 0x6869l; if(l == 0xeaaeb43e477b8487l) system.out.println("correct!"); i did 0xeaaeb43e477b8487 / 0x6869 = 0xffffcbbb6d375815 when calculate 0xffffcbbb6d375815 * 0x6869 gives 0xeaaeb43e477ba89d. why thing happens? , real answer of math question? this because when divide 0xeaaeb43e477b8487l / 0x6869 lose remainder, causes loss of precision. 0xeaaeb43e477b8487l % 0x6869= -9238 if take account get 0xeaaeb43e477ba89dl -9238 = 0xeaaeb43e477b8487 this works if ((l - 9238) == 0xeaaeb43e477b8487l) system.out.println("correct!");

c# wpf Updating UI source from BlockingCollection with Dispatcher -

here's problem. i'm loading few bitmapimages in blockingcollection public void blockingproducer(bitmapimage imgbsource) { if (!collection.isaddingcompleted) collection.add(imgbsource); } the loading happens in backgroungwork thread. private void worker_dowork(object sender, doworkeventargs e) { string filepath; int imgcount = 0; (int = 1; < 10; i++) { imgcount++; filepath = "snap"; filepath += imgcount; filepath += ".bmp"; this.dispatcher.begininvoke(new action(() => { label1.content = "snap" + imgcount + " loaded."; }), dispatcherpriority.normal); bitmapimage imgsource = new bitmapimage(); imgsource.begininit(); imgsource.urisource = new uri(filepath, urikind.relative); imgsource.cacheoption = bitmapcacheopti

c++ - Large Integer Division - Knuth's Algorithm D -

i have divide number (no matter size) number using large integer division using knuth's algorithm d (the art of programming volume 2), example 74839234 72548 . i made 2 arrays represent these numbers n[] = {7,4,8,3,9,2,3,4} d[] = {7,2,5,4,8} i trying output this: q[] = {1,0,3,1} r[] = {4,2,2,4,6} i don't know start this. or guidance appreciated! at d1 have d=1 , set n[]={0,7,4,8,3,9,2,3,4} n = 5 , m = 3 . also, there formal error in step d4: (second line) should ... minus q(hat) times (v1, v2, ..., vn)b times b ** (m - j) . here, ** means "power of" (fortran style easy writing). of course, b = 10 here, so times b ** (m - j) shifts subtrahend left, proper place subtraction.

iphone - Is Build required for uploading to appstore -

Image
i ready upload app appstore. read http://soulwithmobiletechnology.blogspot.in/2011/03/how-to-create-app-on-app-store.html but article says after creating choose archive, build required before click archive? no. when click archive build , create new ipa file. have submit application archievs screen. see screenshot more information

java - 2D Char array Minesweeper game loop -

i'm comp sci student taking intro comp sci. right working on end of year project text based minesweeper game using java. first part suppose make representation of 5x5 minesweeper board 2 d char array , manually add bomb locations , update numbers indicate neighboring bombs.then create second representation of board represent whether or not cell has been revealed. after need write following methods: print board(char[][] board, boolean[][] revealed) : prints minesweeper board screen in text form. keep in mind, printed board should reflect cells have been revealed. reveal cell(int row, int col, boolean[][] game board, char[][] answers board) : appropriately modifies state array when cell revealed while determining how reveal surrounding blank spaces according rules of minesweeper. then have write main game loops incorporates both of these methods while checking see if player won or lost. i've done print board , reveal cell method, need make game board ,

c# - Why the ternary operator is not working this way? -

why not compile? wrong in following code? (_dbcontext == null) ? return _dbcontext = new productandcategoryentities() : return _dbcontext; if restate in terms of if compiles: if (_dbcontext == null) return _dbcontext = new productandcategoryentities(); else return _dbcontext; the things on either side of : in conditional expression expressions , not statements. must evaluate value. return (anything) statement rather expression (you can't x = return _dbcontext; , example), doesn't work there. new productandcategoryentities() , _dbcontext both seem expressions, though. can move return outside of conditional expression. return (_dbcontext == null) ? (_dbcontext = new productandcategoryentities()) : _dbcontext; although, in case, it'd better lose ?: , go straight if . if (_dbcontext == null) _dbcontext = new productandcategoryentities(); return _dbcontext; which bit more straightforward. returning value o

hadoop - Extending Hive: writing a UDF that does both Map and Reduce operations -

i working on project extend hive support image processing functions. to this, need read in image , break multiple files, pass each separate map task processing on , reduce them 1 image returned user. to this, had planned implement udf call mapreduce task in hadoop. however, understand udf operate either on map side or reduce side of hql query , while need ideally ' bridge gap ' between map , reduce side. the hive documentation isn't helpful, , looking pointers on start looking more information this. please feel free ask more questions if haven't been clear enough in question. looking hipi (hadoop image processing inteface) might give start. particularly, example on computing principal components of bunch of images might of interest.

input box finds and opens folder in windows explorer -

the problem: i have 10,000 numbered folders. example: root/7000-8000/7400/7473/ root/3000-4000/3800/3846/ these network folders "unit folders" contain documents, design, photos, accounting, etc data each "unit" company sells. these documents organized subdirectory. dozens of employees refer these folders hundreds of times per day. tedious drill down folder looking for. what want: i want create simple input box, user has enter in unit number, lets between 1 , 100,000, , press enter. system automatically open corresponding "unit folder". how: i looking me figure out scripting language need learn done, functions in particular should into, , deal-breakers should know about. i need sort of input box, simpler better, can stay on desktop or in taskbar. next need parse input digits, , break them down thousands, hundreds, tens, etc. need assemble variables target folder, create correct command send explorer. lastly need issue error if went

java - String("2013-4-25") to date conversion -

i have string "2013-4-25" need convert "mm-dd-yyyy" format. later have append date like calendar cal=new gregoriancalendar(); cal.settime(date); cal.set(calendar.hour, 23); cal.set(calendar.minute, 59); cal.set(calendar.second, 59); how this? use this string str = "2013-4-25"; simpledateformat formatter = new simpledateformat("mm-dd-yyyy"); try { simpledateformat parseformatter = new simpledateformat("yyyy-mm-dd"); date date = parseformatter.parse(str); string formatteddate = formatter.format(date); system.out.println(formatteddate); } catch (parseexception e) { // todo auto-generated catch block e.printstacktrace(); }

c++ - How to Convert Byte Array to IplImage using OpenCv? -

how convert byte array iplimage using opencv ? is possible conversion here byte array iplimage using opencv ? short as uchar mybytes[]={1,255,0,4,1,4,76,43,45}; mat mymat(3,3,cv_8uc1,mybytes); or analytical int nl= mymat.rows; int nc= mymat.cols; (int j=0; j<nl; j++) { uchar* data= mymat.ptr<uchar>(j); (int i=0; i<nc; i++) data[i]= mybytes[j*i]; }

php - How to Data migration from VirtueMart 1.1.x to VirtueMart 2.5.x? -

how data migration virtuemart 1.1.x virtuemart 2.5.x ? i need migrate/update website data , database virtuemart 1 virtuemart 2? vm1 vm2 so, how can ? help me. jignesh. hope migrate virtuemart. http://www.ostraining.com/blog/joomla/virtuemart-11-to-version-2/

How to fire multiple JavaScript functions at once -

how fire these 4 functions @ same time; firethisnow1(); firethisnow2(); firethisnow3(); firethisnow4(); you mean asynchronously yes? try this: settimeout(function(){ firethisnow1(); }, 0); settimeout(function(){ firethisnow2(); }, 0); settimeout(function(){ firethisnow3(); }, 0); settimeout(function(){ firethisnow4(); }, 0); same (if parent object window): for(var = 1; < 5; i++){ settimeout(function(){ window['firethisnow' + i](); }, 0); }

mongodb upgrade from version 1.8 to 2.4 -

hi need upgrade mongodb standalone server 1.4.5 2.4 , replica set 1.8.3 2.4. have got docs upgrade 2.2 2.4. not able docs upgrading mongodb version 1.4 2.4 or 1.8 t o2.4. in 1 of documents found upgrade 2.0 2.4, first needed upgrade 2.2 , 2.4. need gradual upgrade?

windows 8 - How to change url dynamically after packaging Metro apps? -

hi have created package metro application.here while developing app have given url static,but need change url dynamically whenever requirement changes.so should do?can me. thank you. if requirements changing, might releasing new version of application anyways, might make sense update app package manually each time url changes , re-release it. simplest solution if url going change infrequently. need handle deprecating old url in instance or @ least gracefully handling when old url shut down users have not upgraded latest version still don't have horrid experience. if not viable option, gets bit messier here on. way change stored url have sort of secondary service or authority on current url is. app 1 of following (or combination): query url authority current url before making requests. attempt make request current stored url, if fails, query url authority new url , store url.

kendo ui - Why pagination is not applied to grid when using common data source -

i referred kendo articles , did goggling ,but couldn't found solution. step 1: is possible when using common data source , binding whole data chart , grid pagination happen when page loading. step 2: later on based on filter condition applied on grid data in chart should change. any or suggest me whether possible or not.. var common = new kendo.data.datasource({ type : "odata", transport: { read: "http://demos.kendoui.com/service/northwind.svc/orders" }, schema : { model: { fields: { orderdate: { type: "date" } } } } }); common.read(); var grid = $("#grid").kendogrid({ datasource: common, pagesize : 10, pageable : { refresh : true, pagesizes: [10, 20] }, filterable:true, columns : [ { field : "orderid", filterable: false }, "

sql - syntax error in Data Explorer -

the stack exchange data explorer allows sql queries against stack exchange database. tried one — select month(creationdate) month, year(creationdate) year, sum(lower(left(title,2))='wh')/count(*) wh, (select sum(score)/count(*) posts u month(creationdate)=month(t.creationdate) , year(creationdate)=year(t.creationdate) , lower(left(title,2))='wh' , posttypeid=1 -- question ) wh_score, sum(score)/count(*) score, (select sum(answercount)/count(*) posts u month(creationdate)=month(t.creationdate) , year(creationdate)=year(t.creationdate) , lower(left(title,2))='wh' , posttypeid=1 -- question ) wh_answers, sum(answercount)/count(*) answers posts t posttypeid=1 -- question group month,year; — site told me incorrect syntax near ')'. incorrect syntax near 'wh_score'. incorrect syntax near 'wh_answers'. and cannot figure out why. can help, please? things i've trie

c - Parent and child sync by signals trouble -

so, task sync parent , 2 children in way: 1 child sends sigusr2 signal parent , blocks waiting parent msg. sync implemented global flags, parent waits of flag_ch become 1 (it happens when child sends sigusr2) , sends signal sigusr1 child, , child resumes (cause global flag_p becomes 1) the trouble parent receives signals 1 child, , blocks waiting second child signals, don't appear . idea?.. #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <signal.h> #include <sys/signalfd.h> #define lpc 10 pid_t ch[2]; sig_atomic_t flag_ch[2] = {0, 0}; sig_atomic_t flag_p = 0; int get_ind(pid_t ch_pid) { int i; (i = 0; < 2; ++i) { if (ch_pid == ch[i]) return i; } return -1; } void usr_handler(int signo, siginfo_t* si, void* unused) { int ch_index; switch(signo) { case sigusr2: ch_index = get_ind(si->si_pid); if (ch_index >= 0) flag_ch[ch_

c# - How to set a name to the TITLE of a newly opened tab from the @Html.ActionLink cshtml page -

my current code in index.cshtml page: @html.actionlinks(@html.actionlink(objlist.name, "name", "controllername", new {id=objlist.id}, new {target = "_blank"})) the above code makes me open page( name.cshtml ) in new tab after clicking link in index page. goal assign name( objlist.name ) title new tab. so, added title attribute in following code not working expected. @html.actionlinks(@html.actionlink(objlist.name, "name", "controllername", new {id=objlist.id}, new {target = "_blank", title = objlist.name})) how acheive this? you have pass objlist.name parameter "name" action, in action can include name in viewbag: viewbag.mytitle = nameparameter; and in "name" view: <title>@viewbag.mytitle</title> if using layout page, have put in "name" action: viewbag.title = nameparameter; because in layout view have this: <title>@viewbag.title</titl

c# - MS Word 2010 not showing image -

i generating .docx file in .net web application , providing download url users on same page. problem is, same downloaded word document shows image on systems , fails show on some(image refers external link). compared settings related word on both systems , didn't notice difference. please give me inputs on might causing this. systems checked have windows 7 , ms word 2010. almost links referred suggest me uncheck 'show picture placeholders' option. it's disabled in case. thanks please check services packs systems.

javascript - js sliding menu help -- animation delay in the middle? -

Image
i'm looking make menu has kind of specific functions. i'm relatively new javascript , jquery have no idea start. here want do: hovering on link 4 , 5 continue make them stay in end-animation state. any suggestions? tried doing css3 animations can't pause after user stops hovering on link 3 before sliding back. ran issue of gap between link 3 , link 4 causing hover stop. javascript seems better choice. jsfiddle of css3 animations this relevant code has css3 animations in it: -webkit-transition: .2s ease 0s; -moz-transition: .2s ease 0s; -o-transition: .2s ease 0s; -ms-transition: .2s ease 0s; transition: .2s ease 0s; edit: i've updated jsfiddle of current css3 animation (it looks bit different in live preview on jsfiddle on website). the third 'li' of top menu has been extended in width when moving cursor on 'extralinks' menu, latter doesn't slide out of view. pure css solution: jsfiddle link css : * { padding

orm - JPA EclipseLink Weaver generates call to porperty getter inside its setter -> NullPointerException -

i have @embeddable class uses property access wrap object that's not directly mappable jpa via field access. looks this: @embeddable @access(accesstype.property) public class mywrapper { @notnull @transient private wrappedtype wrappedfield; protected mywrapper() { } public mywrapper(wrappedtype wrappedfield) { this.wrappedfield = wrappedfield; } @transient public wrappedtype getwrappedfield() { return wrappedfield; } public void setwrappedfield(wrappedtype wrappedfield) { this.wrappedfield = wrappedfield; } @column(name = "wrappedtypecolumn") protected string getjparepresentation() { return wrappedfield.tostring(); } protected void setjparepresentation(string jparepresentation) { wrappedfield = new wrappedtype(jparepresentation); } } persisting @entity mywrapper field works fine. when execute query load entity database, nullpointerexception . stack

Adding an iframe by JAVASCRIPT -

i trying javascript adds iframe javascript. create iframe before tag. you can see jsfiddle demo. dont want add tag. want add external .js file things on own! use this var newelem = createelement('script'); newelem.setattribute('src', 'http://example.com/js/script.js'); newelem.setattribute('type', 'text/javascript'); newelem.setattribute('language', 'javascript'); document.getelementbyid('idfromtheheadelem').appendchild(newelem);

javascript - Display messages in JSP, When java bean class get affected? -

please don't hesitate edit question , if not clear. currently have situation when server sends response ,i need reflect message in jsp when bean class changes. my bean class be, public class information { public linkedlist<string> information = null ; public linkedlist<string> getinformation() { return information; } public void setinformation(linkedlist<string> information) { this.information = information; system.out.println("list : "+this.information); } } my thread running affect bean class , when response server class producer extends thread{ linkedlist<string>() list = new linkedlist<string>(); information info = new information(); public void run() { if(connectionprotocol.protocol != null){ try { response = connectionprotocol.protocol.receive(); if(response != null){ system.out.print

html - How to stream RTMPT in a webpage -

how can play link below within html file? rtmpt://s4bfl.castup.net/993860018-123.flv?ct=il&rg=kz&aid=386&tkn=20130417204452&ts=0&cu=c78d7065-b213-4905-a7e9-73e7994a4443 i know need swf player, can't find 1 works link. for example, site lets me stream in demo http://www.ideaweb.it/eng/player.cfm . can't find way include in website. you can make embed of player http://www.longtailvideo.com/jw-player/ need download player , upload website , thats it.

java - command works in Windows cmd but fails with Runtime.getRuntime.exec() -

windows 7 cmd has no trouble executing ping -n 5 127.0.0.1 > nul . also, runtime.getruntime.exec(new string[]{"ping", "-n", "5", "127.0.0.1"}) works fine. but runtime.getruntime.exec(new string[]{"ping", "-n", "5", "127.0.0.1", ">", "nul"}) fails bad parameter > . why? i'm using java7 in java6 mode. the > redirection not part of ping command, part of cmd itself. when exec() sees > tries feed ping argument. to same functionality, read (and ignore) data inputstream process exec return value.

queryover - NHibernate: how to select a sorted parent/child and retrieve only specific row_numbers -

i have 2 tables: parent , child have following relation: parent has many childs. public class parent { public datetime timestamp; public ilist<child> child; } public child { public string name; } i want select both parent , child, sorted timestamp , rows between index x y. public ilist<parent> get(datetime from, datetime to, int startrow, int count) { queryover<parent>().where(row => row.timestamp >= from) .and(row => row.timestamp <= to).orderby(row => row.timestamp).asc.list(); } i don't know how required rows. should queryover? or better doing in hql? thanks i changed relation , instead of having parent , child use 1 table: public class info { public datetime timestamp; public string name; } in order records between dates, sorted , them index startrow startrow + count used following: public ilist<info> getinfo (datetime fromdate, datetime todate, int startrow, int count) { il

backbone.js - BackboneJS, MarionetteJS - Trying to display layout + regions -

i've got following code $ -> class mainlayout extends marionette.layout template: handlebars.compile $("#main_layout_hb").html() regions: header : "#header" options : "#options" footer : "#footer" class mainregion extends marionette.region el:"#main_wrap" class app extends marionette.application main_region : new mainregion main_layout : new mainlayout onstart: => @main_region.show(@main_layout) # start backbone history url routing if backbone.history backbone.history.start() app = new app app.start() i'm trying follow example on page https://github.com/marionettejs/backbone.marionette/wiki/the-relationship-between-regions-and-layouts but when run code, don't template "#main_layout_hb" inserted region. what's going on there? you should create app's region using addregions method: app.a

C# WindowsForms - Radio button comment/uncomment content of textbox keypress, textchanged and focusleave -

i have 3 radio buttons: rbtpercentualmedioanual rbtpercentualmensal rbtvalorfixo i change options events textbox1 according choosed option if chose rbtvalorfixo, uncomment: private void textbox1_textchanged(object sender, eventargs e) { //substituipontovirgula_textbox(sender textbox, e); } private void textbox1_leave(object sender, eventargs e) { //formatamoeda_textbox(sender textbox, e); } private void textbox1_keypress(object sender, keypresseventargs e) { //numeropontoouvirgula_textbox(sender textbox, e); formatarporcentagem_textbox(sender textbox, e); } and comment private void textbox1_keypress(object sender, keypresseventargs e) { numeropontoouvirgula_textbox(sender textbox, e); //formatarporcentagem_textbox(sender textbox, e); } if choose option rbtpercentualmedioanual or rbtpercentualmensal, comment: private void textbox1_textchanged(object sender, eventargs e) { substituipontovirgula_textbox(sender textbox, e);

c# - wpf - Data Template, change template with button -

my task make datatemplate list, , create button changing view. have "data" , "footballteam" classes, , have static resources. need button event, how can change current template? as tip, example says use method: "this.resources[resource-key] data-type;" the xaml: <window x:class="wpfapplication11.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="250" width="300"> <window.resources> <datatemplate x:key="teamname"> <textblock fontweight="bold" text="{binding path=teamname}"></textblock> </datatemplate> <datatemplate x:key="year"> <textblock text="{binding path=foundingyear}"></textblock> <

javascript - table's columns width changes after adding another page to tr using ajax -

i have problem kinda hard explain hope understand , me, have table produce rows dynamically, when row pressed shows page containing information, problem when press on row , info page shown columns width changed , entire table shifts(all widths). have noticed happens after info page loaded cant figure out why... code: post table: echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" align=\"center\" class=\"result_table\" id=\"result_table\"> <tr align=\"right\" bgcolor=\"red\"> <th bgcolor=\"#cccccc\" align=\"right\" >עיר</th> <th bgcolor=\"#cccccc\" >רחוב</th> <th bgcolor=\"#cccccc\" >מספר בית</th> <th bgcolor=\"#cccccc\" >מחיר</th> </tr>"; foreach($types $data){ echo $data['id']; echo "<tr onclick=\"waiting_for_post(".$dat

ruby on rails - How do you find what place in an array something is? -

user edit view: <%= form_for(@user, :html => {:multipart => true}) |f| %> <%= f.text_field :name, placeholder: :name %> <%= f.submit "save" %> <%= f.fields_for :photos |photo_fields| %> <%= image_tag(photo_fields.object.photo.url(:user_thumbnail) %> <%= f.radio_button :avatar, @selected_photo_number %> so show photos uploaded user , radio button next each of them. how can made when click first 1 @selected = 0 , second 1 @selected = 1 , on. need know in place photo in array @user.photos[]. thanks! instead of @selected_photo_number need photo_fields.object.place in array?? i think you're looking index . >> array = [1,2,3,4,5] >> array.index(1) # 0 >> array.index(3) # 2 but code, think you're looking each_with_index instead <% f.object.photos.each_with_index |photo, index| %> <%= f.fields_for :photos, [photo] |photo_fields| %> <%= imag

ios - RubyMotion undefined method `addTarget' for #<UIRoundedRectButton:0x761fd40> -

i following motioncasts screencast at: http://motioncasts.tv/start-building-views-in-rubymotion/ and there code: button = uibutton.buttonwithtype(uibuttontyperoundedrect) button.frame = [[15, 300], [280,50]] button.settitle("move next view", forstate: uicontrolstatenormal) button.addtarget(self, action: "movetochildview:", formcontrolevents: uicontroleventtouchupinside) which supposed work, when trying compile produces error: (main)> 2013-04-18 18:41:06.205 12wbt[76267:c07] home_controller.rb:19:in `viewdidload': undefined method `addtarget' #<uiroundedrectbutton:0x761fd40> (nomethoderror) app_delegate.rb:6:in `application:didfinishlaunchingwithoptions:' 2013-04-18 18:41:06.208 12wbt[76267:c07] *** terminating app due uncaught exception 'nomethoderror', reason: 'home_controller.rb:19:in `viewdidload': undefined method `addtarget' #<uiroundedrectbutton:0x761fd40> (nometho

php - SQL Updating all mistyped entries on the same table while performing a query -

a little guys, have table named products following fields [products] pid name category problem there lots of erroneous entries under category refers same category. example of erroneous categories: bags , wallet bags , wallets bag , walles bags & wallets correct 1 should bags & wallets i want change using single sql statement subquery update products set category = 'bags & wallets' products category = (select category products category 'bags , wall') you can implement mysql's regexp searching: update products set category = 'bags & wallets' products category regexp 'bags? , wall'

optimization - C/Arm4 Mult and Division performance -

i trying optimize code going used on arm architecture. the target architecture arm9 architecture doesn't support fpcalculations, , testing configuration arm4 emulation in vs2008. have tried run comparisons see if it's worth attempting change divisions multiplications , i've ran interesting results don't understand. here code ran: for(int = 0; < testrate; i++){ num = 356.0f * 0.06666666666666666666666666666667f; } queryperformancecounter( &end ); double result1 = end.quadpart - start.quadpart; queryperformancecounter( &start ); for(int = 0; < testrate; i++) num2 = 356.0f / 15.0f ; queryperformancecounter( &end ); double result2 = end.quadpart - start.quadpart; and result: calculation time 1: 1485016.000000, result : 23.733335 calculation time 2: 1068092.000000, result : 23.733334 calculation 1 when done multiplications , calculation 2 divisions. result shows divisions faster , on better cases difference between 2 calculations b