Posts

Showing posts from January, 2015

concurrency - Can I catch an external exit in Erlang? -

i have 2 processes linked; let's they're a , b , a set trap exits. want able recover piece of b 's process data if calls exit/2 on it, e.g. exit(b, diediedie) . in b 's module, let's call bmod.erl , have code looks this: -module(bmod). -export([b_start/2]). b_start(a, x) -> spawn(fun() -> b_main(a, x) end). b_main(a, x) -> try ! {self(), doing_stuff}, do_stuff() catch exit:_ -> exit({terminated, x}) end, b_main(a, x). do_stuff() -> io:format("doing stuff.~n",[]). and in a 's module, let's call amod.erl , have code looks this: -module(amod). -export([a_start/0]). a_start() -> process_flag(trap_exit, true), link(bmod:b_start(self(), some_stuff_to_do)), a_main(). a_main() -> receive {pid, doing_stuff} -> io:format("process ~p did stuff.~n",[pid]), exit(pid, diediedie), a_main(); {'exit', pid, {terminated,

Funcall inside Cons Lisp -

i began play lisp , i'm trying use funcall inside cons. this i'm trying do: (cons '(1 2 3) '(1 (funcall #'rest '(a b)) )) the result should be: ((1 2 3) 1 (b)) i know works: (cons '(1 2 3) (funcall #'rest '(a b))) and tried , didn't work (cons '(1 2 3) `,'(1 (funcall #'rest '(a b)) )) (cons '(1 2 3) '(1 (apply 'rest '(a b)))) (cons '(1 2 3) '(1 `,(apply 'rest '(a b)))) thanks in advance. (cons '(1 2 3) `(1 ,(funcall #'rest '(a b))))

php - Mysqli not showing errors properly -

i trying learn mysqli of functions. 1 thing left have proper error reporting across layers. don't understand why following snippet of code detects error won't error number nor error code. function get_pid_tid_by_pk($con,$ourid) { $returned['errno'] =""; $returned['error'] =""; //mistake on here!!! if(!$stmt = $con->prepare("elect gene_name,jgi_protein_id,jgi_transcript_id jgi_transid_protid_match our_protein_id = ?")) { $returned['errno'] = $con->errno; $returned['error'] = $con->error; return $returned; } if(!$stmt->bind_param('s',$ourid)) { $returned['errno'] = $stmt->errno; $returned['error'] = $stmt->error; return $returned; } if(!$stmt->execute()) { $returned['errno'] = $stmt->errno; $returned['error'] = $stmt->error; retu

facebook - fb security warning while trying to login with fbgraph api -

while trying login fb, using graph api, web page appear showing message. security warning:please treat url above password , not share anyone. in ios fb graph api. this error occurs not time, half of time. how skip fb message ? i found 1 solution. hope work you. just paste uiwebviewdelegate method in fbgraph.m file.... - (bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype{ if([request.url.relativestring hasprefix:@"https://www.facebook.com/connect/login_success.html" ]) self.webview.hidden=true; return yes; }

NYTProf Profiler for Perl -

this question devel::nytprof profiler. the output receive profiler simple line such as: use strict; output: statements: 3 time on line: 22µs calls: 2 time in sub: 12µs so questions are: how 3 statements ? the time in sub .. represent ? does represent time spent converting module optree or else? is compile phase time or run phase time ? thank in advance use foo; is equivalent executing require foo; foo->import; at compile time. perhaps sub called strict::import . update : profiling program require strict; strict->import; shows devel::nytprof counts require statement 1 sub call , import another.

c++ - Cocos2dx : How to stop CCFollow moving the ParallaxNode and making background black -

i trying follow herosprite using ccfollow, there 2 erratic behaviors happening . i making camera follow sprite follows : startsprite = ccsprite::createwithspriteframename("santa_001.png"); startsprite->setposition(ccp (size.width / 5 , size.height / 2 )); this->addchild(startsprite,1); this->runaction(ccfollow::create(herosprite, ccrectmake(0, 0, size.width, size.height * 2))); now, happens : a) background parallax node consisting of different sprites , moving @ different speed moving in "upward" direction when herosprite jumps upward. want keep sprites @ original position , not move upward herosprite. how do ? voidnode = ccparallaxnodeextras::node(); voidnode->addchild(pspritegrass, 2, ccp(3.0f,0), ccp(0, size.height/10 - 50) ); voidnode->addchild(pspritegrass02, 3, ccp(3.0f,0), ccp(size.width - 10 , size.height/10 - 50) ); voidnode->addchild(psprite, 1, ccp(1.0f,0), ccp(0, size.height/10 - 50) );

How to Create C DLL using Visual Studio 2012 -

i've been doing of development using c# in visual studio, first 2010 , 2012. need create dll using c language project i'm working on. when file | new project, can't find option creating dll using c. how do this? it's under file / new / project / templates / visual c++ / win32 / win32 project. follow wizard, , you'll offered "dll" on second page. (this visual studio 2012 - of wording may differ in other versions.)

tdd - Is there an rspec test for exact length of an attribute? -

i'm trying test length of zip code attribute ensure 5 characters long. right i'm testing make sure not blank , short 4 characters , long 6 characters. is there way test being 5 characters? far i've found nothing online or in rspec book. if you're testing validation on activerecord model, recommend trying out shoulda-matchers . provides bunch of useful rspec extensions useful rails. write simple 1 line spec zip code attribute: describe address { should ensure_length_of(:zip_code).is_equal_to(5).with_message(/invalid/) } end

linux - SPI data transfer - why MOSI goes to zero half cycle before the data transfer? -

Image
i have spi signal output spi device. wonder why data output ( mosi ) goes 0 half cycle before actual data written on bus? must condition spi device? if not go zero, there problem on data transfer? i use spidev32766.1 on linux (ubuntu 12.04 - kernel 3.7.1), processor imx233 thank in advance!! the slave device doesn't care happens on data line except short period (usually <1ns) either side of active clock edge (this window defined setup , hold time specifications interface). i have no idea why system put out "wiggle" though!

c# - If Int32 is just an alias for int, how can the Int32 class use an int? -

been browsing through .net source code of .net framework reference source , fun of it. , found don't understand. there int32.cs file c# code int32 type. , somehow seems strange me. how c# compiler compile code int32 type? public struct int32: icomparable, iformattable, iconvertible { internal int m_value; // ... } but isn't illegal in c#? if int alias for int32 , should fail compile error cs0523 : struct member 'struct2 field' of type 'struct1' causes cycle in struct layout. is there magic in compiler, or off track? isn't illegal in c#? if "int" alias "int32" should fail compile error cs0523. there magic in compiler? yes; error deliberately suppressed in compiler. cycle checker skipped entirely if type in question built-in type. normally sort of thing illegal: struct s { s s; int i; } in case size of s undefined because whatever size of s is, must equal plus size of int. there no such

c# - Cast issue 'System.String' to type 'System.Web.UI.HtmlControls.HtmlInputFile' -

i have list box contains paths specific files in directory code reads , parses data , ohter stuff it. error unable cast object of type 'system.string' type 'system.web.ui.htmlcontrols.htmlinputfile' , i'm not sure how overcome this. i have html input control of type file function directory path becuase directory not same. split postedfile.filename looks c:\temp\2013\03-2013\calib 100 29 mar 13\211jd13100.txt on '\' string array. reasseble path in string adding array elements less last index , use param 'directory.getfiles(string) files in directory. again, don't know of anohter way directory information. anyway i'll post code, easier understand. static public arraylist hif = new arraylist(); static string[] filepaths; protected void btnaddfile_click(object sender, system.eventargs e) { if (page.ispostback == true) { stringbuilder sb = new stringbuilder(); string[] dirlocation

Why does reading from a php://memory wrapper I've just written to fail? -

i'm trying read php://memory wrapper using fread() fread() returns false. code simplified: $file_handle = fopen('php://memory', 'w+'); // have tried php:temp also. fwrite($file_handle, 'contents'); $file = fread($file_handle, filesize($file_handle)); // have tried 99999 filesize. $file false after fread() . what's going on? thanks in advance! you'll need rewind($file_handle) after writing before can read you've written, because writing moves file pointer end of file

jquery - Google Maps integration lightens text below it? -

edit: seems issue on end, @ least wasn't able replicate outside of mac os setup chrome / safari. i'm using google maps on this site , , seems lighten text (not sure other elements) below it. navigation above doesn't seem affected. you can see best when comparing 'h2' "besuchen sie uns" 'h2' on other pages . in fact, can see when load page. brief second, before google maps starts loading, text has original styling. now, can't explain , haven't found @ all. granted, don't have experience google maps, doing wrong? both headers have computed font-weight:300 , color:#414141 , same computed font-family on chrome, , there don't appear google maps introduced style rules match them. the header on map integration page seem overlap map, there doesn't seem z-index issue.

html - Bootstrap container and span width problems -

i new bootstrap , working on site it. my challenge justify bootstrap.min.css , bootstrap.responsive.min.css i got these files bootswatch , free templates , problem width of site. in bootstrap.min.css .container {width : 994px;} but in bootstrap.responsive.min.css .container {width : 1170px} // big, , dont it. however, other objects derived .container such .span* . these files not consistent each other. what did replacing places of these css files in app , worked not sure, if did correct thing. can advice?

xcode - Always Show the NSUserNotification -

i have nsusernotification showing document when within app happens. there way show notification when app frontmost app (i.e., show it)? (it show if i'm in other app) here's answer info need. notifications displayed when application isn't key application. if want notifications display regardless of if application key or not, you'll need specify delegate nsusernotificationcenter , override delegate method usernotificationcenter:shouldpresentnotification: returns yes .

javascript - Why Bootstrap's Carousel left arrow throws errors while the right one works fine? -

i have created page http://www.virtuemax.com/projects/urtotal/index.html its static page , built entirely on bootstrap's framework. carousel works fine when click left arrow navigate carousel left throws errors. can help? your html not written properly <div class="carousel-inner"> <img id="floral" src="img/floralorange.png" alt=""> <div class="item active"> <img alt="slide 1" src="img/slide1.jpg"> </div> <div class="item"> <img alt="" src="img/slide2.jpg"> </div> </div> the first image should wrapped inside <div class="item"></div> other. including 2 jquery plugin @ time. remove 1 avoid unwanted conflict

jquery - Add an if statement to append() -

is possible add if statement append() inside jquery function ? }).data("uiautocomplete")._renderitem = function(ul, item) { $(ul).addclass("quicksearch"); $(ul).css('margin-left','-125px'); var rating_color = item.level; var revision = item.revision.tolowercase(); //if revision === "") { append ! return $("<li></li>").data("item.autocomplete", item).append('<a><img class="clubpicture" src="'+item.clubpicture+'" /><img class="nationpicture" src="'+item.nationpicture+'" /><span class="name">'+item.name+'</span> ('+item.position+') <span class="rating '+rating_color+' '+revision+'">'+item.rating+'</span></a>').appendto(ul); }; if point me in correct direction that'd great jsfiddle demo you

optimization - How to quickly replace many matching items with a single replacement in BASH? -

i have file, "items.txt" containing list of 100,000 items need remove file "text.txt" , replace "111111111". i wrote script works intend: #!/bin/bash a=0 b=`wc -l < ./items.txt` while read -r line a=`expr $a + 1` sed -i "s/$line/111111111/g" text.txt echo "removed ("$a"/"$b")." done < ./items.txt this script looks @ eat line in "items.txt", uses sed remove each line "text.txt". this script slow though. estimate, take more 1 week remove of items file on computer. there more efficient way replace of items quickly? bash 4.1.5 use sed build sed script replace items: sed 's/^/s=/;s/$/=111111111=g/' items.txt | sed -f- text.txt update: following perl script seems faster: #!/usr/bin/perl use warnings; use strict; open $items, '<', 'items.txt'; @items = <$items>; chomp @items; $regex = join '|', @items; $regex =

java - Best Practice In JSF for Forms, Datatables, etc -

should have bean every form, datatable etc in jsf? for example, have form registration, has 2 fields , button are: nickname, password, submit should submitting form go registirationformbean or somewhere in userbean or userservicebean? what best practice? thank you. to decide whether or not should create @managedbean exclusively component of page (e.g. form, datatable), believe should think modularity of design. the 1st question should ask is: will component re-used in many pages? . example, on sensitive pages such changepassword or deleteaccount , usually, ask user enter current password validate identity before performing logic. in case, should have exclusive bean validating password component can re-use component again , again without having re-code validating function every time. secondly, use @managedbean place hold related functions work toward same goal . grouping of functions can pretty subjective. example, can have page called createproduct.xhtml

ubuntu 12.04 - Alfresco 4.2c CIFS configuration issue -

i got fresh installation of alfresco 4.2 on ubuntu 12.04. had "successfully" configured cifs , modified iptables include (nat) ports(1445 tcp -- 445 tcp , 1137-1139 tcp/udp 137-139 tcp/udp) smb , netbios. machine ec2 instance @ amazon i've created security group include inbound traffic 445,137-139 tcp , 137-139 udp. when connecting windows machine using network drive, connect (seems port 445 working) show 2 folders (one site-name , other swsdp). when moved site folder there no content (\server\alfresco\site-name), missing documentlibrary , subfolders. i've double checked user used connect had permissions see content (even connect administrator , still problem). have set debug cifs under alfresco's log4j non-error or under application log. i followed steps advised on http://andoylang.wordpress.com/2010/07/20/alfresco-with-cifs/ , try isolate problem within linux box. when used sbmclient connect got following error: bitnami@ip-10-46-57-42:/opt/bitnami/

How do I check if a certain set of words is in a string with PHP -

so have code below wondering how can tell if '$text' contains words 'by owner'. how do this? looked around can't find anything. foreach($anchors $a) { $i = $i + 1; $text = $a->nodevalue; $href = $a->getattribute('href'); if ($i > 22 && $i < 64 && ($i % 2) == 0) { //if ($i<80) { echo "<a href =' ".$href." '>".$text."</a><br/>"; } // } //$str = file_get_contents($href); //$result = (substr_count(strip_tags($str),"ipod")); //echo ($result); } something like: $text = $a->nodevalue; if(strpos($text, "by owner") == -1){ // if want text *start* "by owner", can replace strpos($text, "by owner") != 0 echo "doesn't have owner"; } else{ echo "has owner"; }

javascript - Star field won't appear, Can this be because of my Graphic Card -

i working in webgl project three.js, , in project have make solar system. but there problem, star field won't show in screen.... tried many codes find in internet, went through steps of tutorial, still didn't work. downloaded code of starfield, still starfield won't appear!!. i wanted ask you, problem vga (graphic card) ?? here specification of graphic card: chip type: mobile intel(r) 4 series express chipset family dac type: internal adapter string: mobile intel (r) gma 4500mhd bios information: intel video bios total available graphic memory: 797 mb dedicated video memory: 64mb system video memory: 0mb shared system memory: 733 mb everything has star field won't appear on screen, other things sphere, cubes, torus, texture mapping etc, working fine, star field isn't!! you didn't show picture, starfields can seem vanish or turn black, if filtered. try using different, nonsense picture starfield, , see if appears. the reason: texture scal

Overriding CSS property using jQuery -

suppose have following css in linked style sheet: td {background: -moz-linear-gradient(top, #fbfbfb, #fafafa);} this makes table columns green. suppose have following table row: <tr id="myrow"><td>stuff</td><td>more stuff</td></tr> the whole row green following user input want following: $("#myrow").children('td').css('backgroundcolor', 'red'); why won't turn row green red , how can make work without adding !important style sheets? you can try: $("#myrow").children('td').css('background-color', 'red'); or $("#myrow").children('td').css('background', 'red'); also bizzare things check if above won't work: where call jquery code? (is in function, $(document).ready() ..?) do have inline style attribute there? do have errors caused previous code? (see debugger - built-in chrome dev tools of fir

php - Displaying Rows of HTML Elements in Vertical Rows -

i want show list of categories in virtuemart webshop vertically sorted same way shown in demonstration: http://www.inkplant.com/code/mysql-vertical-sort.php so borrowed code: <?php $cols = 4; //number of columns, can set positive integer $values = array(); $result = mysql_query("select * states order name"); $numrows = mysql_num_rows($result); $rows_per_col = ceil($numrows / $cols); ($c=1;$c<=$cols;$c++) { $values['col_'.$c] = array(); } $c = 1; $r = 1; while ($row = mysql_fetch_assoc($result)) { $values['col_'.$c][$r] = stripslashes($row['name']); if ($r == $rows_per_col) { $c++; $r = 1; } else { $r++; } } echo "<table>" ; ($r=1;$r<=$rows_per_col;$r++) { echo "<tr>" ; ($c=1;$c<=$cols;$c++) { echo "<td>".$values['col_'.$c][$r]."</td>" ; } echo "</tr>" ; } echo "</table>" ; unset($values); ?> i tried mo

c# - Form does not displayed as Dialog inside backgroundworker? -

the form not displayed dialog inside backgroundworker? here code: //from form1 private void backgroundworkerresult_dowork(object sender, doworkeventargs e) { //do here backgroundworkerresult.reportprogress(100); frmmessagebox frmmsgbox = new frmmessagebox(); frmmsgbox.showdialog(); } even though showed frmmsgbox dialog can still click form1 supposed not? how can fix this? i created simple code sample can use understand how background worker works. copy code test form , add following controls label control - name 'lblstatus' progressbar control - should named progressbar1. add 2 buttons named 'btnstartasyncoperation' , 'btncancel' , link click events . basically should display results in runworkercompleted event public partial class form1 : form { backgroundworker backgroundworker; public form1() { initializecomponent(); backg

c# - How to populate gridview with mysql? -

i know how populate gridview asp:sqldatasource have column of templatefield in gridview , when need modify sql alter grid content, lose templatefield , think learn populate gridview c# can teach me or give me tutorial? using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using mysql.data.common; using mysql.data.mysqlclient; using system.data.sqlclient; using system.windows.forms; using system.data; public partial class viewadmin : system.web.ui.page { string myconstring = "server=localhost;" + "database=databasename;" + "uid=root;" + "password=;"; protected void page_load(object sender, eventargs e) { mysqlconnection conn = new mysqlconnection(myconstring); mysqlcommand cmd = new mysqlcommand("select * tablename;", conn); conn.open(); datatable data

playframework - Play doesn't convert java-list to scala-list -

i have controller hands java-list of model-objects view way it's done in examples. the compiler throws error can't convert java.util.list scala.collection.immutable.list . have no clue should do. [error] /myapp/myappsubprojects/frontend/app/controllers/frontend/mycontroller.java:15: error: method render in class linklist cannot applied given types; [error] return ok(linklist.render("link test", link.findall())); [error] ^ [error] required: string,scala.collection.immutable.list<link> [error] found: string,java.util.list<link> [error] reason: actual argument java.util.list<link> cannot converted scala.collection.immutable.list<link> method invocation conversion [error] 1 error note: i'm using subprojects (common, frontend, backend) , had hard time make run properly. it's related that. i went fishing details , ended (luckily) answering question in comment

Storing a random byte string in Python -

for project, need able store random byte strings in file , read byte string again later. example, want store randombytestring following code: >>> os import urandom >>> randombytestring=urandom(8) >>> randombytestring b'zoz\x84\xfb\xcem~' what proper way this? edit: forgot mention want store 'normal' string alongside byte strings. code like: >>> fh = open("e:\\test","wb") >>> fh.write(randombytestring) 8 >>> fh.close() operate file binary mode. also, in better manner if file operations near 1 place (thanks @blender): >>> open("e:\\test","wb") fh: fh.write(randombytestring) update: if want strong normal strings, encode , write like: >>> "test".encode() b'test' >>> fh.write("test".encode()) here fh means same file handle opened previously.

jquery - Change background color in CSS using a JavaScript function -

using css, i'm trying set background color of each element random color on hover: :hover { background-color: "getrandom()"; } however, doesn't appear possible put javascript function call here. there alternative approach work? here's page i'm working on: http://jsfiddle.net/fwkqq/3/ in jquery code: $("*").hover( function(event) { $(this).css("background-color", getrandomcolor()); }, function (event) { $(this).css("background-color", "white"); } ); (you should remove :hover css element) example: http://jsfiddle.net/jqsgq/

android - Passsing View to PageFragment -

i'm able pass string value pagefragment via bundle/instance. how can pass view ? i tried create public linearlayout in pagefragment used pagefragment.linearlayout.addview(myview); in fragmentpageradapter. didnt worked public class pagefragment extends fragment { public static linearlayout linearlayout; public static pagefragment newinstance(string title) { pagefragment pagefragment = new pagefragment(); bundle bundle = new bundle(); bundle.putstring("title", title); pagefragment.setarguments(bundle); return pagefragment; } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.page_quiz, container, false); tv = (textview) view.findviewbyid(r.

jquery - How to add delay time into line of code on JavaScript -

im trying function when user move cursor on image show preview. im taking src of image fired event , im changing path of different images. $('#image').hover(function(){ var src = ""; var elem = $(this); (var i=2; i<16; i++) { src = elem.attr('src').split('.'); src[3] = i; src = src.tostring(); src = src.split(',').join('.'); elem.attr('src', src); } }); the problem here, when try below, putting delay every preview doesn't work want. $('#image').hover(function(){ var src = ""; var elem = $(this); (var i=2; i<16; i++) { src = elem.attr('src').split('.'); src[3] = i; src = src.tostring(); src = src.split(',').join('.'); settimeout(function() { elem.attr('src', src); }, 800); } }); how can solve it? i'm working problem +2h

java - Out of memory exception while converting byte array to string [ displaying pdf on webview] +Android -

i'm using following code load pdf file on webview try { imagebytearray =loadfile(environment.getexternalstoragedirectory().getabsolutepath()+"/sample.pdf"); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } webview = (webview)findviewbyid(r.id.webview1); string image64 = base64.encodetostring(imagebytearray, base64.default); string imgtag = "<img src=\"data:image/jpeg;base64," + image64 + "\" />" ; webview.getsettings().setbuiltinzoomcontrols(true); webview.setinitialscale(30); websettings websettings = webview.getsettings(); websettings.setusewideviewport(true); webview.loaddata(imgtag, "text/html", "utf-8"); but getting outofmemory exception while converting byte code string question : 1.how can load large byte code string type 2.or can use other data type display byte array in webview see in line &qu

In c language ,how to open different directory to read multiple files? -

i using c language in vc++. want open multiple images (.tiff) different directory .can me please. thanks get file paths : if files' paths absolute : file *fopen(const char *filename, const char *mode); if relative : #to current directory #include <unistd.h> char *getcwd(char *buf, size_t size); to parent directory, can little tricky since there isn't standard c function so. list files in directory : #include <dirent.h> dir *opendir (const char *name);

Database Design Questions -

i have 2 questions regarding project. appreciate if clarifications on that. i have decomposed address individual entities breaking down smallest unit. bur addresses repeated in few tables. address fields there in client table employee table. should separate address separate table linking field for example create address table following attributes : entity_id ( employee id(home address) or client id(office address) ) unit building street locality city state country zipcode remove address fields employee table , client table we can obtain address getting employee id , referring address table address which approach better ? having address fields in tables or separate shown above. thoughts on design in better ? ya separating address better because people can have multiple addresses increasing data redundancy. you can design database problem in 2 ways according me. a. using 1 table table name --- address column names serial no. (uniq

math - imageline (PHP+gd) creates too long line -

i'm trying draw line representing complex number on circle (base image: http://i.imgur.com/mngenrp.png ) starting centre of circle , ending on point on circle. here come problems: i have tried many formulas find $x2 , $y2 ended randomly positioned lines. what's right formula calculate ending coordinates? edit: cleong solved positioning problem line still long, goes out of circle , out of image. of formulas use are: $x2=$half+($radius*(cos(deg2rad($theta)))); $y2=$half-($radius*(sin(deg2rad($theta)))); where $half centre of circle (in pixels), $radius radius of circle in pixels , $theta angle in radians. in advance.

java - Can I miss the catch clause to throw exception to its caller? -

what kind of problem may occur code? think exception occurs, code can throw exception caller. not generate trouble. how can improve it? public static void cat(file named) { randomaccessfile input = null; string line = null; try { input = new randomaccessfile(named, “r”); while ((line = input.readline()) != null { system.out.println(line); } return; } { if (input != null) { input.close(); } } } what kind of problem may occur code? public randomaccessfile throws filenotfoundexception . public final string readline() throws ioexception . public void close() throws ioexception . since public class filenotfoundexception extends ioexception you can change method to: public static void cat(file named) throws ioexception and don't need try-catch blocks. and caller should catch exception thrown method. but why don't want catch exceptions?

sql - Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause -

i'm trying select bunch of patients unit , division , want group result unit name, code doesn't execute , gives error topic of question. select top (100) percent pat.patname name, srvdiv.sgmtype perkhidmatan, pat.patmrank pangkat, pat.patmilitaryid [no# tentera], unt.untname unit, fct.pesstatuscode statuscode, fct.pessigneddate signeddate dbo.factpes fct inner join dbo.dimpatient pat on fct.pespatid = pat.patid left outer join dbo.dimunit unt on fct.pesunitid = unt.untid left outer join dbo.dimservicediv srvdiv on fct.pesservicedivid = srvdiv.sgid group unt.untname having (deas.didate between convert(datetime, @fromdate, 102) , convert(datetime, @todate, 102)) i assume it's because unt.untname in left join can't use outside join maybe ? i'm bit confused because when put works: group unt.untname, pat.patname, srvdiv.sgmtype, pat.patmrank, pat.patmilitaryid, unt.untname, fct.pesstatuscode,

window - What MFC class should I base free floating views on -

i have dialog based mfc application. want create wiew (one or more) toolbar, scroll bars , client window (based on cwnd). what mfc class should base window on? best way it? thanks. using scrolling client window more natural in document-view application dialog based application -- can have menu bars , toolbars connected dialog, view far know. a sdi application allows support multiple docking/floating toolbars , multiple views of same document, advice...

opengl - Render to FBO + glReadPixels all black -

i trying render simple checkerboard in fbo , glreadpixels(). when without fbo, works fine. assume render function ok , glreadpixels(). fbo, lines draw after calls fbo have been done. here code (python, aiming cross platform): def renderfbo(): #whyyounoworking(gl_framebuffer) # degug function... error checking glbindframebuffer( gl_draw_framebuffer, framebuffer) glbindrenderbuffer( gl_renderbuffer, renderbuffera) glrenderbufferstorage( gl_renderbuffer, gl_rgba, window.width, window.height) glbindrenderbuffer( gl_renderbuffer, renderbufferb) glrenderbufferstorage( gl_renderbuffer, gl_depth_component, window.width, window.height) glbindframebuffer( gl_draw_framebuffer, framebuffer) glframebufferrenderbuffer( gl_draw_framebuffer, gl_color_attachment0, gl_renderbuffer, renderbuffera) glframebufferrenderbuffer( gl_draw_framebuffer, gl_depth_attachment, gl_renderbuffer, renderbufferb) #whyyounoworking(gl_framebuffer) gldrawbuffer(

xamarin.android - Debugging a "remote" Android device with Xamarin? -

so needing debugging xamarin android. wouldn't such problem if emulator wasn't slow. so, looked @ setting x86 emulator, because i'm running xamarin within vmware (host machine linux), won't work. best bet install either x86 accelerated android, or use android-x86 host machine. how xamarin connect device not's running on same machine though? it's possible configure adb debug on network instead of usb. check out xamarin's document titled setup device development , , scroll down section titled connect device computer directions on how so.

vb.net - using between in a controller ASP.Net MVC -

this question has answer here: how call stored procedure in mvc ef 3 answers i have got code below return data table in database. i have tried , not been successful using stored procedures can advice how use between 2 dates below code work. thanks imports system.data.entity public class homecontroller inherits system.web.mvc.controller private db new articlesdbcontextnew function index() actionresult viewdata("message") = "modify template jump-start asp.net mvc application." dim articles = title in db.articleslist select title articles = articles.where(function(s) s.publishdatefrom > (date.now.date) , s.publishdateto > (date.now.date)) return view(db.articleslist.tolist()) return view(articles) return view() end function function about() a

getting panic() argument in defer function in GO lang -

i have function calling function b sometime call panic based on invalid data. in function defer function, know message function b passed panic() can report error in json on network client. e.g. func a( abc data) result string{ defer func(){ // panic args , return result. } xx = b( abc[0] ); yy = b( abc[1] ); ... } the reason function b use panic avoid large amount of err := b(abc) if err != nil { ... } in function , make code easier read , maintain. for example: package main import ( "errors" "fmt" ) func a(s string) (result string, err error) { defer func() { if e := recover(); e != nil { switch x := e.(type) { case error: err = x default: err = fmt.errorf("%v", x) } } }() b(s)

Facebook not honoring og:description -

i noticing facebook debugger/linter tool correctly parses og:description when share link, output takes scrapped content body text has class , id of 'content'. if delete body text output og:description correctly when sharing. basically, seems facebook has preference using body content on og:description. can confirm or maybe tell me why happening? i have facebook share og:description regardless of body content. update: here paste of html => http://paste.ubuntu.com/5989551/ okay, issue drupal fb module not submitting defined og:description. didn't realize override og:tags in sense.

android - INVALID_AUDIENCE error with Google OAuth 2.0 API -

i following tutorial auth tokens. i have both of client_ids web server , android device set getting invalid_audience error. believe because have not generated , signed apk, instead in development. is there special need test auth on device via usb? i'll go through how set client_ids. web server this easy needed url. android this 1 little harder. generated apk certificate (the .jks file). cd jdk/bin dir , ran keytool -exportcert -alias occucard -keystore "c:\users\shane\androidappkeys\occucard/occucard.jks" -v -list as tutorial instructs. think may problem. since development generated apk , not signed key. side note: scope token required googleauthutils looks like: "audience:server:client_id:" + server_client_id my solution create third client_id debug.keystore sha1 key. ran command keytool -list -alias androiddebugkey -keystore "c:\users\shane\.android/debug.keystore" -storepass android -keypass android thi

decoding - How to use android/google software decoder at app level -

i have video in android uses hardware accelerated decoder. there way can customize use android software decoder @ app layer? if so, how go it? there way this? try taking @ ffmpeg software video decoding. also, see this article relating ffmpeg , android. also, this post contains further information regarding topic of encoding android.

knockout.js - Knockout with repeat binding: Initially selected value being overwritten -

i have preset value select selectedvalue has value of "ham". have 3 options "spam", "ham", "cheese". when viewmodel applied, "ham" value selected , selectedvalue looses it's value, "ham" isn't selected although appears be. what need change allow selectvalue retain it's initial value? here's jsfiddle html <select data-bind="value:selectedvalue"> <option data-bind="repeat: values" data-repeat-bind="value: $item(), text: $item()"> </option> </select> <br>selectedvalue: <span data-bind="text:selectedvalue"></span> viewmodel var viewmodel = function () { this.selectedvalue = ko.observable("ham"); //initial value has been chosen. this.values = ko.observablearray(["spam", 'ham', 'cheese']); this.showmeselectedvalue = function(){alert(this.selectedvalue())};

mercurial - Is a workflow of hg clone on non-bare hg repositories safe? -

i know git refuse push non-bare repository, hg doesn't seem to... mean not need worry bareness when cloning hg? i've experimented (in pastebin below), , haven't seen problems approach, inability find problems not same there being no problems. also, have autopush enabled in .hgrc... http://pastebin.com/qzyyqb6p mercurial not auto-merge when push, pushing non-bare repository safe. why mercurial not distinguish between bare , non-bare repositories - bare repository 1 working directory @ null revision (i.e. before initial commit). if pushing new head existing branch mercurial require specify hg push -f . because having multiple heads on same branch imposes additional complications other developers , potentially result in heads being merged in different ways, leading cascade of unnecessary merges. the workflow should follow pull ; merge new heads existing head ; push . of course, depends heavily on branching strategy using - 1 uses bookmarks (equivalent gi

asp.net - Configuring WCF Services in Code WCF 4.5 -

hi, trying configure wcf using code behind, below code: public static void configure(serviceconfiguration config) { string configpath = configurationmanager.appsettings["wcfconfigdbpath"]; // enable “add service reference” support config.description.behaviors.add(new servicemetadatabehavior { httpgetenabled = true }); // set support http, https, net.tcp, net.pipe if (isenabled(configpath, "enablehttp")) config.enableprotocol(new basichttpbinding()); if (isenabled(configpath, "enablenettcp")) config.enableprotocol(new nettcpbinding()); if (isenabled(configpath, "enablepipe")) config.enableprotocol(new netnamedpipebinding()); } private static bool isenabled(string path, string elementname) { try { string elementvalue = string.empty; bool returnval = false; using (xmltextreader reader = new xmltextreader(path)) { reader.readtofoll

asp.net mvc - Ajax Paging Mvc 4 -

i need help. i'm doing simple blog using mvc 4. edit3 : in general, concept follows: on left navigation bar categories, on right posts ajax paging. when click on concrete post, turn page details of post. i have layout: <body> <div class="container-fluid"> <div class="row-fluid"> <div class="sidebar-nav-fixed fill"> @html.action("getcategories","navigation") </div> <div class="sidebar-nav-fixed-stuck-left fill white"> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <div class="content-area"> @renderbody() </div> </div> </di

actionscript 3 - How can find wich object cause null object reference in Flash? -

i have error in flash application , con not find error source? possible find object cause error whit flash dibuger? typeerror: error #1009: cannot access property or method of null object reference. @ reading2mergedlayers_fla::maintimeline/hidetimer2() @ reading2mergedlayers_fla::maintimeline/frame37() @ flash.display::movieclip/prevframe() @ reading2mergedlayers_fla::maintimeline/back32() run code flash builder (with source hooked in sort of project--which kind depend on have). debugger should stop @ line error, , can see variable null.

Xpath Query Help. Selecting data from multiple paths as a single data set -

i have xml structure following : <doc> <line void="false"> <linenumber>1</linenumber> <info1>ddddd</info1> <info2>aaaaa</info2> </line> <line void="true"> <linenumber>2</linenumber> <voidlinenumber>1</voidlinenumber> <voidvalue>2.00</voidvalue> </line> </doc> i need 1 single set of data. select lines void = false voidlinenumber , voidvalue data line void = true , voidlinenumber = linenumber original line. is possible? appreciated. thanks as michael kay noted, xpath can used select nodes, not transform them. can want xslt: <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="html" encoding="utf-8" indent="yes" /> <xsl:template match="doc">

javascript - Moving objects inside the browser -

i want display in browser web page contains: a number of objects predictable shapes (squares, rectangles etc) the user should have ability connect these objects using arrows (please see image link) http://img850.imageshack.us/img850/6999/o33z.jpg in addition user should able move objects, , connecting arrows need move objects arrows keep point same objects. are there current web technologies can or there 1 fit start using basis. have not done web work javascript might answer please guide me specifics. look jquery ui. there's plenty of abilities in here specified above. or using flash/actionscript, although seems (arguably) diminishing technology. you can find info on how use jueryui here, http://jqueryui.com/draggable/

swing - Getting last character of a JTextField(or its String) in Java -

i trying build calculator works jbuttons numbers , arithmetic operands. every time jbutton clicked, string variable (textin) updated , passed parameter of non-editable jtextfield.the jtextfield displays number going passed in parameter calculation.when operand clicked, next number should reset jtextfield(i.e. "678+" when 4 clicked jtextfield should reset "4").the problem every time, regardless of presence of "+".a fragment of code follows. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class gui extends jframe { private jbutton but1; private jbutton but6; private jbutton plus; private jbutton equal; private jtextfield text; public static string textin; public double num1; public double num2; public string operand; public gui() { super("calculator"); setlayout(new flowlayout()); textin = ""; num1 = 0; num2 = 0; but

c# - logging into DB with log4net -

i use log4net logging errors in project. want log messages db ( sql server ) added adonetappender not work (other appenders work fine, connection string correct). can wrong? i decided create bare-bones example project. works. perhaps should try making work. create empty console application project. add reference log4net. c# code: using log4net; [assembly: log4net.config.xmlconfigurator(watch = true)] namespace litter { class program { static void main() { logmanager.getlogger("default").info("hello, world!"); } } } config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configsections> <section name="log4net" type="log4net.config.log4netconfigurationsectionhandler, log4net"/> </configsections> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5&q

d3.js - How to change d3 tickmark lines to circles -

how create tickmark in d3 axis? --o---o---o---o---o instead of default ---|---|---| i searched d3 examples, not see sample of changing tickmark lines circles.. any appreciated.. this isn't supported out of box. can quite select tick groups, append circles , delete tick lines using following code. var ticks = axis.selectall(".tick"); ticks.each(function() { d3.select(this).append("circle").attr("r", 3); }); ticks.selectall("line").remove(); complete example here .

plot - ploting many files order on one line at gnuplot -

Image
i have plot 10 files same legend, need order number inside files, because when write line @ gnuplot, shows bad image. numbers have before others show continue line on graph. looking red line possible see mean. there way that? plot '<paste ../00/statistic100.txt ../01/statistic100.txt ../02/statistic100.txt ../03/statistic100.txt ../04/statistic100.txt ../05/statistic100.txt ../06/statistic100.txt ../07/statistic100.txt ../08/statistic100.txt ../09/statistic100.txt' linespoint ls 1 title 'reputation until 100%' thanks in advance! felipe use smooth unique after plot command. from gnuplot documentation : the unique option makes data monotonic in x; points same x-value replaced single point having average y-value. resulting points connected straight line segments. example without ordering plot "-" lines 0 3 2 4 -2 2 -5 -1 1 5 5 6 -1 -3 4 0 -3 -3 3 -4 -4 1 e result: with ordering plot &q

.net - Grouping published events in NServiceBus -

i'm using nservicebus send orders (one order per command) back-end systems. each order has customer (parent). back-end system publishes "order accepted" event after order saved successfully. there multiple subscribers event 1 of them file generator component generates xml file consumed third party. file generated per customer. since published event @ order level every time "order accepted" event published file component creates entire file customer. is there way within nservicebus group events @ subscriber can reduce number of times file generator runs if there multiple orders same customer? one idea had put subscriber sleep fixed time , when wakes can group messages in queue customer , generate file once per customer. sound idea? thanks in advance. the best way use saga behavior of debouncer. the saga subscribe event, , every time observed, request new timeout period of time willing wait, let's 5 minutes. if timeout message arrives ,

Django Views Query -

i have view in data form , use run python script within view. python script gives output , needs prompt user proceed further , perform other functionality. how can in single view ?? my views.py class deploywizard(sessionwizardview): template = "deploy_form.html" def done(self, form_list, **kwargs) : form_data = process_form_data(form_list) #process data form form #call script of the form data argument # display output user , ask user proceed (something "yes", "no") , proceed further # again call python script other arguments return rendor_to_response("done.html", {'form_data' : form_data}) i think should use either django's form wizard or form preview depending on precise use case. the former if need classic multi-step wizard, latter if need user confirm input.

c# - Using DataGrid ItemDataBound Event to Check Value -

i've got datagrid datasource bound sqldatareader object: sqldatareader areader = runner.reader; dgsearchresults.datasource = areader; dgsearchresults.databind(); i've created itemdatabound event grid , want check value of specific column/cell while each item bound can enable/disable flags. how can value of specific cell "svcid" on itemdatabound? here code: public void dgsearchresults_itemdatabound(object sender, datagriditemeventargs e) { if (viewstate["svcids"] != null) { if (e.item != null) { var svcids = (list<int>) viewstate["svcids"]; if (svcids.contains(convert.toint32(**datagrid svcid goes here**)) { //todo: enable/disable icons } } } } i've used rowdatabound events before not datagrid control, , required steps bit different seems. what code check value

swt - TreeViewer no longer sizes properly when using StyledCellLabels -

i using jface treeviewer while. has bunch of branches of varying lengths, @ end of day, entire tree stretched size of longest string. great. recently, decided treeitems labels should have style them fonts , highlights. the trouble, new fonts bit larger , stretch size of overall string. seems tree or treeviewer doesn't recognize expansion , still judges size of label amount of small characters in it. result treeviewer horizontal scrollbar, highly inconvenient because users have scroll across each tree, rather being glance @ data. does know how tree fit length of longest string, , take account added length of styling, etc? thanks! while not complete answer, hope jogs someone's memory has more advanced knowledge on this: when set font viewercell object font wide, entire row resizes. seems tree measures width checking length of text , font, disregards style ranges .