Posts

Showing posts from April, 2010

java - Override on Field initialization -

for following example, public abstract class recorddata { private mydate mdate = new mydate(new simpledateformat(""yyyy-mm-dd hh:mm:ss")); public date getmydate() { return mdate.getdate(); } ..... } i implementing classes override date format. 1 way of doing have method this: protected simpledateformat getdateform() { return new simpledateformat("yyyy-mm-dd hh:mm:ss") } so,the initialization should like: mydate mdate = new mydate(getdateform()); is there other convenient way of doing this. potential issues above implementation. doing bad idea: base class call methog of subclass in constructor, , call method on object hasn't been initialized yet. you'd better pass data needed superclass in constructor: public abstract class recorddata { private mydate mdate; protected recorddata(string datepattern) { this.mdate = new mydate(new simpledateformat(datepattern)); } } doing how others

iframe - on ipad once loaded youtube video freezes all other keys until played -

i using following code load youtube video. jquery(document).ready(function() { $("#load").click(function(){ data = '<iframe id="placeholder"> </iframe>'; $('#putithere').html (data); $('#putithere').show (); document.getelementbyid ('placeholder').src='http://www.youtube.com/embed/7r4ljq7-_6y'; }); }); additional buttons exist well. problem on ipad or iphone, other buttons frozen (do not respond touch) until video started. once started, other buttons function. occurs in 'touch' environment. using 'click' environment, buttons not frozen. so, example on lap top (using mouse), can load video, see wrong one, , click load different video. on ipad, can not click (touch) load different video until loaded video has started play. this has been logged bug youtube api, affects ipod/ipad/iphone family links directly underneath embedded youtube video not work same hei

c# - BinaryReader overwhelming me by padding byte array -

so have simple code reads file , spits data out in hex viewer fashion. here is: using system; using system.collections.generic; using system.linq; using system.text; using system.io; namespace hexviewer { class program { static void main(string[] args) { binaryreader br = new binaryreader(new filestream("c:\\dump.bin", filemode.open)); (int = 0; < br.basestream.length; i+= 16) { console.write(i.tostring("x") + ": "); byte[] data = new byte[16]; br.read(data, i, 16); console.writeline(bitconverter.tostring(data).replace("-", " ")); } console.readline(); } } } the problem after first iteration, when do br.read(data, 16, 16); the byte array padded 16 bytes, , filled data 15th byte 31st byte of file. because can't fit 32 bytes 16 byte large array, throws exceptio

android - static inner class and non static outer method -

i have problem colorpickerdialog http://www.yougli.net/android/a-photoshop-like-color-picker-for-your-android-application/ this colorpickerdialog has inner static class... in inner static class need use "close()" or "dismiss()" on colorpickerdialog close it... my problem public class colorpickerdialog extends dialog the close() , dismiss() methods non static in dialog. how can use methods in inner static class private static class colorpickerview extends view ? edit... here important sections code.. public class colorpickerdialog extends dialog { public interface oncolorchangedlistener { void colorchanged(string key, int color); } private static class colorpickerview extends view { @override public boolean ontouchevent(motionevent event) { if (x > 266 && x < 394 && y > 316 && y < 356){ saveddialog(); } return true; } private void saveddialog() { new

html5 - servlet Server-sent event not working with Chrome/Safari -

i working on servlet encountered problem. sse works fine firefox cannot work chrome/safari. similar code in php can run smoothly in 3 browsers mentioned above. how solve problem? thx!! this servlet code: response.setcontenttype("text/event-stream;charset=utf-8"); response.addheader("cache-control", "no-cache"); printwriter out = response.getwriter(); out.print("data: " + new date()); out.flush(); out.close(); and js code: if (typeof(eventsource) !== "undefined") { var source = new eventsource("sse"); source.onmessage = function(event) { document.getelementbyid("result").innerhtml += event.data + "<br />"; alert("ok"); }; } else { document.getelementbyid("result").innerhtml = "sorry, browser not support server

mysql - I am not getting the out put file for the below sql batch file -

@echo off set sql_exe="c:\program files\mysql\mysql server 5.1\bin\mysql.exe" set sql_options=-user root -password amma set sql_db="c:\documents , settings\all users\application data\mysql\mysql server 5.1\data\aview" set count=1 /f "delims=" %%a in (input.sql) ( echo %%a > temp.sql call :processtemp_sql ) goto :eof :processtemp_sql %sql_exe% %sql_options% -i temp.sql -o output%count%.txt %sql_db% set /a count=%count%+1 goto :eof :eof input.sql has sql query select * status; i've no idea mysql syntax - , on-line manual isn't help.... since you've gone trouble of establishing sql_db - shouldn't using somewhere?

c++ - Same and Different Random Numbers generation -

i creating game involves generating random numbers. have add option (at end of game) restart same game or create new game. how can generate same , different random numbers? save seed use in srand() generate identical random numbers, initialize seed based on time() generate new sequences every time.

android - Error: Error "No resource found that matches the given name: attr 'vpiTabPageIndicatorStyle'" when building with maven -

i've maven project viewpagerindicator added submodule. i'm trying add custom style tabpageindicator . here styles code: <style name="apptheme" parent="@android:style/android:theme.notitlebar"> <item name="android:textcolor">@color/text</item> <item name="android:background">@null</item> <item name="vpitabpageindicatorstyle">@style/customtabpageindicator</item> </style> <style name="customtabpageindicator" parent="widget.tabpageindicator"> <item name="android:textcolor">@drawable/text_tab_bar_color</item> <item name="android:dividerpadding">10dp</item> <item name="android:showdividers">middle</item> <item name="android:paddingleft">8dp</item> <item name="android:paddingright">8dp</item> <item name="

vba - Or loop doing the opposite of what I want -

i'm trying or loop work in vba instead of avoiding cells have letters in them, it's making whole array "-". if put in numbers or words replaces whole array dash. private sub commandbutton1_click() dim l double, c double l = 14 18 c = 10 12 if cells(l, c).value <> "w" or _ cells(l, c).value <> "w" or _ cells(l, c).value <> "x" or _ cells(l, c).value <> "x" or _ cells(l, c).value <> "y" or _ cells(l, c).value <> "y" or _ cells(l, c).value <> "z" or _ cells(l, c).value <> "z" cells(l, c).value = "-" end if next c next l end sub you need , conditions together. if cells(l, c).value <> "w" , _ cells(l, c).value <> "w" , _ cells(l, c).value <> "x" , _ cells(l, c).value <> "x" , _ cells(l, c)

visual studio 2010 - Listing all files in a folder, only first character of file name gets printed -

this question has answer here: filenames truncate show first character 3 answers i'm trying access images in designated folder, names, , pass them further processing (getting pixel values, precise, isn't relevant now). following test code should list name of every image found, however, reason lists first letter each image. #include <windows.h> int main(int argc, char* argv[]) { win32_find_data search_data; memset(&search_data, 0, sizeof(win32_find_data)); handle handle = findfirstfile(l"images\\*.jpg", &search_data); while(handle != invalid_handle_value) { printf("found file: %s\r\n", search_data.cfilename); if(findnextfile(handle, &search_data) == false) break; } return 0; } your program compiled unicode, printf format string expecting ascii string. change %s %s.

c++ - Using stable_sort, when sorting vector of objects -

i have class passanger has variables string name; string station; string ticket; , have class , within class have vector<passanger*> myqueue; now want use stable_sort sort myqueue . there possibility, how stable_sort , should key, according shall sort myqueue ? std::stable_sort(myqueue.begin(),myqueue.end(), maybesomethingelse() ); ? yes, need comparator class. this. class comparefoo { public: bool operator() (const foo* e1, const foo* s2) { return e1->name < e2->name; // strict weak ordering required } }; then pass instantiation of parameter stable_sort . std::stable_sort(myqueue.begin(), myqueue.end(), comparefoo());

mysql - inserting data into new table from union of two tables -

i have following query unions 2 tables table1 , table 2 resultset res = st.executequery(" select user_id, movie_id, movie_name, user_name, rating, genre table1 union select t1.user_id, t2.movie_id, t2.movie_name, t2.user_name, t2.rating, t2.genre table2 t2 join table1 t1 on t2.user_name = t1.user_name;"); output-- 1 12 pianist vishal 7 action 2 4 titanic rajesh 7 action 3 5 snakes on plane anuj 2 drama 4 9 oh god arun 5 drama 5 9 jumanji vishal 8 fantasy 6 68 rabbit hole vishal 4 mystery 1 249 fast , furious vishal 0 action 2 356 sun , horse rajesh 0 fantasy 2 423 scream rajesh 0 comedy 2 391 alone rajesh 0 tragedy 2 739 price , pauper rajesh 0 drama 4 451 7 arun 5 comedy 5 9 ghosts vishal 0 horror 5 216 face off vi

vb.net - (VB) toggle labels on/off -

i have button when clicked labels show, code used when button clicked again hidden: private sub form3_load(byval sender system.object, byval e system.eventargs) handles mybase.load label4.hide() label5.hide() label6.hide() end sub private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click msgbox("all shortcuts require shift+(letter) combination", vbokonly, "shortcuts active") label4.show() label5.show() label6.show() end sub simply check visible property private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click if label4.visible = false msgbox("all shortcuts require shift+(letter) combination", vbokonly, "shortcuts active") label4.show() label5.show() label6.show() else label4.hide() label5.hide() label6.hide() end i

non blocking php system call - tshark -

i trying start tshark process capturing on interface wlan0 5 minutes. read in other threads tried direct output file this: $log = "sniff-".date("y-m-d-h-i-s").".txt"; system("sudo tshark -i wlan0 -a duration:300 > /var/www/log".$log); i expecting webserver start tshark process , move on. in error log of apache can see normal output of tshark: running user "root" , group "root". dangerous capturing on wlan0 6 packets captured what have change tshark output log file , not interrupt php script? & suffice , if yes, have put it? solution: system("sudo tshark -i wlan0 -a duration:300 > /var/www/log".$log." &"); by putting & @ end of bash cmd should disconnect running session, try using php threads or php fork run process off parallel process, providing server has relevant settings , modules installed enable this. system("sudo tshark -i wlan0 -a duration:300 &&

actionscript 3 - Connecting blocks together but prevent intersection -

Image
edit have had rethink: going use easier implement tree structure grid each block can have 4 neighbours. i trying attach blocks on stalk (series of blocks) of flower. green blocks existing stalk , blue block 1 attached mouse. the block attached mouse correctly snap nearest edges (i'm allowing diagonals now) blocks able go 'inside' stalk (image 2) snapping block above or below. my question is, how can stop this? considered iterating list again ignoring block tried attach to; think result in same problem attaching block 'inside' stalk. find block intersecting , connection point it, repeat until there no intersections; seems better option messy when intersecting more 1 block @ time i should note plan on having smoother snap, not arbitrarily edge, grid pretty out of question. pretty confident there must elegant solution, i'm not seeing it! here snapping code stands var mousepos:point = new point(mousex, mousey);// new point(e.stagex, e.stage

html - javascript cursor image position -

i change cursor background image file , cursor in top of image $(".maindiv").attr("style", "cursor: url(./images/myimage.png) ,auto"); how set cursor in bottom of image ? use .css() instead: $(".maindiv").css({cursor: 'url(./images/myimage.png) ,auto'});

java - How to put my variables in the object's constructor -

i have class has 20 attributes can devided in 10 groups having 2 attributes of type minvalue , maxvalue . i wondering how define object's constructor. have 2 options: first one, public myclass(minvaluetype1, maxvaluetype1, minvaluetype2,maxvaluetype2,....,minvaluetype10, maxvaluetype10) second one, public myclass(type1arr[],type2array[],......,type10array[]) where each array has length of 2 minvalue , maxvalue . which way think better? here 1 way class myclass { private map<string, minmax> others; public myclass(map<string, minmax> in) { others=in; } } class minmax { private int min; private int max; public boolean iswithinrange(int input) { return input >= min && input <= max; } }

mysql - SQL - From [spoiler:abcdefgh] to [spoiler] -

i've string in many records [spoiler:abcdefgh] . abcdefgh variable characters. want became [spoiler] . want remove :abcdefgh . i know query is: update post set pagetext = replace(pagetext, ‘text want replace’, ‘replacament text’); how can replace variable characters? for example, if have [center:uezfbb79]texttt[/center:uezfbb79] want became: [center]texttt[/center] "uezfbb79" not fixed, these random characters. the following code should trick, assuming tags formatted. please test throroughly before running against production copy. update post set pagetext = replace(pagetext, substr(pagetext, instr(pagetext,':'), instr(pagetext, ']') - instr(pagetext,':')), '') pagetext '[%:%]'; here's sql fiddle used very limited testing. edit this script should deal preceding [] situation: update post set pagetext = replace(pagetext, substr(pagetext, @c1:=instr(pagetext,':'), locate(']',

.net - TcpClient connection error -

i used tcpclient , tcplistner classes chat application. worked perfect on lan. use same approach on internet didn't work , gives me following error a connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond 112.134.252.38:13000 how solve this? it looks network problem. tcp ports might not open on firewalls. firewalls blocking traffic on ports different 80 , 443 on internet. should contact network administrators of remote machine trying access , ensure port trying connect not blocked.

java - loading graph chart in a layout -

i try load graphic in layout, mathematical graphic using achartengine. downloaded demo zip site , realized need sin-cosin grahp style. so, code wrote: package com.myproject; import org.achartengine.chartfactory; import org.achartengine.graphicalview; import org.achartengine.chart.pointstyle; import org.achartengine.model.xymultipleseriesdataset; import org.achartengine.renderer.xymultipleseriesrenderer; import android.os.bundle; import android.app.activity; import android.content.intent; import android.graphics.color; import android.view.view; import android.webkit.webview; import android.widget.linearlayout; import android.widget.linearlayout.layoutparams; import com.myproject.clases.abstractdemochart; public class mainactivity extends activity { private webview ventana; private graphicalview mchartview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); set

php - Getting an error message when putting Laravel test project online -

i getting message when attempt put site online unhandled exception message: error rendering view: [home.index] trying property of non-object location: /home/bluelynx/public_html/storage/views/4f62cf9f53fafa06c72f532abef2ee2b on line 161 stack trace: #0 /home/bluelynx/public_html/laravel/laravel.php(42): laravel\error::native(8, 'trying p...', '/home/bluelynx/...', 161) #1 /home/bluelynx/public_html/laravel/view.php(386) : eval()'d code(161): laravel\{closure}(8, 'trying p...', '/home/bluelynx/...', 161, array) #2 /home/bluelynx/public_html/laravel/view.php(386): eval() #3 /home/bluelynx/public_html/laravel/blade.php(71): laravel\view->get() #4 [internal function]: laravel\{closure}(object(laravel\view)) #5 /home/bluelynx/public_html/laravel/event.php(199): call_user_func_array(object(closure), array) #6 /home/bluelynx/public_html/laravel/event.php(138): laravel\event::fire('laravel.view.en...', array, true) #7 /home/bluelynx/pub

websocket - How to get access to onclose event codes in Javascript onclose function? -

i have simple websocket problem <!doctype html> <meta charset="utf-8" /> <title>websocket test</title> <script language="javascript" type="text/javascript"> var wsuri = "ws://echo.websocket.org/"; var output; function init() { output = document.getelementbyid("output"); testwebsocket(); } function testwebsocket() { websocket = new websocket(wsuri); websocket.onopen = function (evt) { onopen(evt) }; websocket.onclose = function (evt) { onclose(evt) }; websocket.onmessage = function (evt) { onmessage(evt) }; websocket.onerror = function (evt) { onerror(evt) }; } function onopen(evt) { writetoscreen("connected"); dosend("websocket rocks"); } function onclose(evt) { writetoscreen("discon

java - How to add services to desktop Apache Felix application -

i'm new apache felix. want create simple desktop application based on apache felix framework. found this simple example how create simple main method starts framework application i'm not aware how add services application. package com.paint.servicebased; import java.util.map; import java.util.serviceloader; import org.osgi.framework.bundle; import org.osgi.framework.bundlecontext; import org.osgi.framework.bundleexception; import org.osgi.framework.launch.framework; import org.osgi.framework.launch.frameworkfactory; /** * class provides static {@code main()} method bundle can * run stand-alone host application. in such scenario, application * creates own embedded osgi framework instance , interacts * internal extensions providing drawing functionality. * launch stand-alone application, must run bundle's * installation directory using "{@code java -jar}". locations of * additional extensions have started, have passed command * line arguments metho

php - Reroute all links on page to localhost -

i doing minor re-work on friend's site. have downloaded has currently, of links absolute links, whenever navigate within locally hosted site, pushed live site. instead of overwriting of links (on each page, in database, etc.), "reroute" links going "www.google.com" example "localhost/project". there easy way htaccess file? should mention wordpress site, if there other way go this. there several ways: 1) edit /etc/hosts.txt file , add line "127.0.0.1 www.google.com". (that file in system32, think windows) don't forget remove entry when you're done. 2) search-and-replace on files while editing. perl -i.bak -pe 's/www.google.com/localhost/' *.html work. 3) use proxy can modify data. https://github.com/evaryont/mousehole 4) use greasemonkey or similar modify page via javascript.

python - HDF5 - concurrency, compression & I/O performance -

Image
i have following questions hdf5 performance , concurrency: does hdf5 support concurrent write access? concurrency considerations aside, how hdf5 performance in terms of i/o performance (does compression rates affect performance)? since use hdf5 python wonder wow it's performance compare sqlite. references: http://www.sqlite.org/faq.html#q5 locking sqlite file on nfs filesystem possible? http://pandas.pydata.org/ updated use pandas 0.13.1 1) no. http://pandas.pydata.org/pandas-docs/dev/io.html#notes-caveats . there various ways do this, e.g. have different threads/processes write out computation results, have single process combine. 2) depending type of data store, how it, , how want retrieve, hdf5 can offer vastly better performance. storing in hdfstore single array, float data, compressed (in other words, not storing in format allows querying), stored/read amazing fast. storing in table format (which slows down write performance), offer quite wri

windows - WINAPI Hook - determine whether a new directory was created -

is there way create callback reacts after user created new folder in explorer? there few different apis let recieve notifications folders being created. shchangenotifyregister allows see folders created in explorer. findfirstchangenotification notify of changes under sub folder (although won't tell folder has been created). you'll detailed information readdirectorychanges , it's complicated use. blog entry has details on pros , cons of each.

osx - Installing dnsmasq with Homebrew -

i have installed dnsmasq using homebrew. seemed go fine installing. after installing followed instructions... cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf sudo launchctl load /library/launchdaemons/homebrew.mxcl.dnsmasq.plist the problem: dnsmasq doesn't seem to bes working. when run: sudo dnsmasq i get: dnsmasq: failed create listening socket 127.0.0.1: address in use when run: sudo launchctl stop /library/launchdaemons/homebrew.mxcl.dnsmasq.plist i get: launchctl stop error: no such process any ideas going on or how tell if installed , running correctly? launchctl stop takes job label, not path (same launchctl's stop , list commands). assuming label homebrew.mxcl.dnsmasq , can check daemon's status sudo launchctl list homebrew.mxcl.dnsmasq (if has pid listed, it's running), , if necessary stop sudo launchctl stop homebrew.mxcl.dnsmasq . if that's not right label, check in /library/launchdaemons

c# - Sorting a generated table in my view (visual studio .net) -

<h2>documenten</h2> <table border="1""> <tr> <th"> title </th> <th> description </th> <th> download </th> </tr>* @foreach (var item in model.trajects.components) { if (item.gettype() == "document") { <tr> <td> @item.title </td> <td> @item.description </td> <td><a href='@url.action("download","component", new {componentid=item.componentid,l=request["trajectcode"],g = model})'> <img src='@url.content("../../images/play.png")' alt="home page"> </a> </

.htaccess - Relative links with htaccess -

how can convert links within html relative links using .htaccess? for example: http://www.mydomain.com/info.html /info.html .htaccess commands cannot change content of html files urls live. you need post process html files on server before sent client. how depends on how generate html files.

How to get a value out of a hash in Ruby? -

i have following hash ( @myhash ) in ruby: [ { "id" => "123456789", "name" =>"random name", "list_type" =>"random type of list" } ] how can take value of id out of hash? (basically result should be: 123456789) when try doing @myhash[:id] following error "can't convert symbol integer" when try doing @myhash['id'] following error "can't convert string integer" i've tried adding .to_i , .to_s , etc. nothing helps. what have there not hash. it's array of hashes (well, array of 1 hash, precise). first have address proper element in array (first one), address value key. @myhash[0]['id'] # => '123456789' # or @myhash.first['id'] # => '123456789' i following error "can't convert symbol integer" you think you're working hash, in reality, it's array. arrays

Double Entry in Database when inserting from form using PHP & MySQL -

i trying create web application. new php & mysql. when insert data table using php, double records of entry made table. using xampp. please me fix this. attached screenshot of double entry. my database dump: -- phpmyadmin sql dump -- version 3.5.2.2 -- http://www.phpmyadmin.net -- -- host: 127.0.0.1 -- generation time: may 18, 2013 @ 11:58 pm -- server version: 5.5.27 -- php version: 5.4.7 set sql_mode="no_auto_value_on_zero"; set time_zone = "+00:00"; /*!40101 set @old_character_set_client=@@character_set_client */; /*!40101 set @old_character_set_results=@@character_set_results */; /*!40101 set @old_collation_connection=@@collation_connection */; /*!40101 set names utf8 */; -- -- database: `gccdb` -- -- -------------------------------------------------------- -- -- table structure table `tbl_rol` -- create table if not exists `tbl_rol` ( `id` int(11) not null auto_increment, `rol_cd` varchar(10) not null, `rol_desc` varchar(25) not

php - Mysql update statement won't execute -

can me this? when i'm trying update table nothing happens , can't figure out what's wrong. i've tried different query's not 1 worked. my code: http://pastebin.com/8zdpm0ah doesn't work line 23 <?php foreach($db->query("select * blog id '$id'") $row){ echo "titel: <input type='text' size='50' name='titel' value='$row[titel]'><br>"; echo "post:<br>"; echo "<textarea name='editblog'>"; echo $row[post]; echo "</textarea>"; echo "<input type='hidden' name='id' value='"; echo $row[id]; echo "'>"; } ?> <input type="submit" value="edit post" name="postedit"> </form> <script> ckeditor.replace( 'editblog' ); </script> <?php if(isset($_post['postedit'])){ $titel = $_po

build - Project dependencies not loading in Visual Studio 2012 -

i'm not sure if add-on/extension issue i'm having heck of time visual studio 2012 on 2 computers. believe devexpress coderush causing problems seems work fine when uninstall i'm not 100% sure. i startup vs 2012, answer yes latest tfs 2012 , solution right-click solution node in solution explorer , choose project dependencies... - shows nothing checked. of course build fail. close , restart vs 2012 , shows. typically through course of devexpress option clear solution cache causes solution reload. does have suggestions may cause project dependencies lost yet after restart fine again? there need delete , rebuild try , resolve this? the fix (so seems) not check option in vs source control settings latest when opening solution. seems prevent solution initializing properly. consider reporting microsoft connect.

css - how to make navigation bar stretch across the page (HTML) -

i'm having problems navigation bar, not stretching across page. here's code: #nav { list-style: none; font-weight: bold; margin-bottom: 10px; width: 100%; text-align: center; } #nav ul { list-style-type: none; margin: 0px; padding: 0; } #nav li { margin: 0px; display: } #nav li { padding: 10px; text-decoration: none; font-weight: bold; color: #ffffff; background-color: #000000; float: left } #nav li a:hover { color: #ffffff; background-color: #35af3b; } <div id="nav"> <ul> <li><a href="#">home</a> </li> <li><a href="#">music</a> </li> <li><a href="#">education</a> </li> <li><a href="#">fun</a> </li> <li><a href="#">entertainment</a> </li> <li><a hr

html - Is it a Must to Validate Global Codes? -

there global codes not valid according w3c standards example can consider youtube embed code or facebook plugins. in such cases, shall do? <iframe width="560" height="315" src="http://www.youtube.com/embed/6mxng9hsyyo" frameborder="0" allowfullscreen></iframe> what suggest me in such cases? edit codes ensure w3c validation or leave these when entire website w3c validated? best regards, touhid the validation error given (when checking in html5) is: the frameborder attribute on iframe element obsolete. use css instead. basically means frameborder no longer supported in html5 (and can achieved through css). reason still included, however, because not browsers have html5 support - works fall-back. you shouldn't have problems removing attribute if want site pass validation tests, it's unlikely issues ever arise leaving attribute there.

Theoretically, would it be possible to allow multiple C++ templates to have the same name? -

this question has answer here: why not possible overload class templates? 2 answers it function overloading. e.g. ok this: void foo(int i) { ; } // function overload ftw. void foo(int i, int j) { ; } but not (yet) ok this: template<typename t> class foo { }; // fail! template<typename t1, typename t2> class foo { }; does feature not exist in order avoid confusion? or there reason wouldn't make sense? no not possible in c++ that. the template looked first, parameters make impossible know template which. it seem duplicate one: why not possible overload class templates?

MPI datatype for structure of arrays -

in mpi application have distributed array of floats , 2 "parallel" arrays of integers: each float value there 2 associated integers describe corresponding value. sake of cache-efficiency want treat them 3 different arrays, i.e. structure of arrays, rather array of structures. now, have gather these values first node. can in 1 communication instruction, defining mpi type, corresponding structure, 1 float , 2 integers. force me use array of structures pattern instead of structure of arrays one. so, can choose between: performing 3 different communications, 1 each array , keep efficient structure of arrays arrangement defining mpi type, perform single communication, , deal resulting array of structures adjusting algorithm or rearranging data do know third option allow me have best of both worlds, i.e. having single communication , keeping cache-efficient configuration? you take take @ packing , unpacking. http://www.mpi-forum.org/docs/mpi-11-html/nod

Arduino buttons moving in lock step -

i have arduino project (it's mintduino, it's same microcontroller) has 3 buttons, setup tutorial ( http://arduino.cc/en/tutorial/buttonstatechange ) common + , - between them. buttons individually connected a0, a1, , a2. here code use read them: void setup() { pinmode(a0, input); pinmode(a1, input); pinmode(a2, input); serial.begin(9600); } void loop() { serial.print("b1: "); serial.print(digitalread(a0)); serial.print(" b2: "); serial.print(digitalread(a1)); serial.print(" b3: "); serial.print(digitalread(a2)); serial.println(""); } when button unpressed, get: b1: 1 b2: 1 b3: 1 and when press any button, get: b1: 0 b2: 0 b3: 0 so can tell button pressed, , can not tell button was pressed. how can tell 1 button press another? i think know why it's happening, can't think of solution doesn't involve using 3 different batteries can individual circuits. most got wiring wron

r - How to recreate same DocumentTermMatrix with new (test) data -

suppose have text based training data , testing data. more specific, have 2 data sets - training , testing - , both of them have 1 column contains text , of interest job @ hand. i used tm package in r process text column in training data set. after removing white spaces, punctuation, , stop words, stemmed corpus , created document term matrix of 1 grams containing frequency/count of words in each document. took pre-determined cut-off of, say, 50 , kept terms have count of greater 50. following this, train a, say, glmnet model using dtm , dependent variable (which present in training data). runs smooth , easy till now. however, how proceed when want score/predict model on testing data or new data might come in future? specifically, trying find out how create exact dtm on new data? if new data set not have of similar words original training data terms should have count of 0 (which fine). want able replicate exact same dtm (in terms of structure) on new corpus. any ideas/

css drop down menu displays as a bullet list in IE8 -

i created dropdown css menu , working in firefox not in ie8. need work in browsers, can help?. don't have url yet, creating site in old version of frontpage. here css script: #cssmenu{ height:37px; display:block; padding:0; margin:20px auto; border:1px solid; border-radius:5px; } #cssmenu > ul {list-style:inside none; padding:0; margin:0;} #cssmenu > ul > li {list-style:inside none; padding:0; margin:0; float:left; display:block; position:relative;} #cssmenu > ul > li > a{ outline:none; display:block; position:relative; padding:12px 20px; font:bold 13px/100% arial, helvetica, sans-serif; text-align:center; text- decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.4); } #cssmenu > ul > li:first-child > a{border-radius:5px 0 0 5px;} #cssmenu > ul > li > a:after{ content:''; position:absolute; border-right:1px solid; top:-1px; bottom:-1px; right:-2px; z-index:99; } #cssmenu ul li.has-sub:hover > a:after{top:0; bot

binding - Clojure and JavaFX 2.0 -- How to access element's ID from clojure callback function -

following javafx tutorial here: http://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm , trying make run in clojure. i'm doing lein run after setting :aot :all , stuff (:gen-class) etc. took few days of figuring out, seems working. in src/jfxtwo/clojureexamplecontroller.clj : (defn -handlesubmitbuttonaction [^actionevent event] (let [actiontarget (text.)] (println "event button pressed") (println "event instance:" event) (println "event class:" (class event)) (.settext actiontarget "sign in button pressed..."))) in resources/fxml_example.fxml : <gridpane fx:controller= "jfxtwo.clojureexamplecontroller" xmlns:fx= "http://javafx.com/fxml" alignment= "center" hgap= "10" vgap= "10" styleclass= "root" > ... <button text= "sign in" onaction= "#handlesubmitbuttonaction" /> ... <text

multithreading - Python: [Help] Best use of asynchronous timer (Non Blocking Timer) -

my question if have thread program runs in infinite loop , each loop simulation step, @ every loop there might request timer something. sounds easy confusing thing want loop continue , not wait timer , "do something" statement happen if timer fired. clarification: class thread1(threading.thread): def __init__(slef): threading.thread.__init__(self) def run(self): while true: #do step 1 #do step 2 #if input available:>start_timer(seconds) #if timer(user input seconds) finished step 3 #continue looping again problem have i've tried use timer threading library (from threading import timer) show execution error, while sleep function sleeps , whole simulation stops wont good.

c++11 - Returning different template specialisations from a function -

i have created c++11 class in want parse string , return object based on data in string. object want return defined as: // container topic data , id template <typename t> class topic { public: topic(string id, t data) : _id(id), _data(data) {} private: string _id; t _data; }; the function returns object defined as: // parses string , splits components class topicparser { public: template <class t> static topic<t> parse(string message) { t data; // string, vector<string> or map<string, string> string id = "123"; topic<t> t(id, data); return t; } }; i (think i) able call function in way: string message = "some message parse..."; auto = topicparser::parse<topic<vector<string>>>(message); auto b = topicparser::parse<topic<string>>(message); but compiler complains that: no matching function call ‘topic<std::vector<std::basic_string<char&

performance - Why is my app using so many instances when I have so few requests? -

Image
my webapp gets 0.4 requests per second. need 2-3 instances running day long? why "active" line in graph lower "billed"? note: i'm using f4 frontend instances... not sure how factors this. if using f4 instances, being billed 4x.

viewport - jQuery elements (images and divs) are not resizing, when browser windows is resized -

i facing small problem when browser window resized. able viewport's width , height , can set image size per browser window. when resize browser window, image or div not getting resized. here have tried viewport's width , height , applied same respective image (element). <script type="text/javascript"> // global vars $(document).ready (function (){ var winwidth = $ (window).innerwidth(); var winheight = $ (window).innerheight(); // set initial div height / width $('div.background img').css({ 'min-width': winwidth, 'height': winheight }); $('.leftstatbar').css({ 'width': '200px', 'min-height': winheight }); $(' #firstmenu').css({ 'width': '150px', 'min-height': winheight }); $(window).resize(function(){ $('div.background img').css({ 'min-width': winwidth, 'height': winheight}); });

mysql - Sum of a joined table -

it possible has been answered somewhere couldn't find it. appreciate if me sql statement again. this sql statement have far: select * , round( (rate * time_to_sec( total ) /3600 ) , 2) revenue (select event.eventid, event.staffid, event.role, timediff( time, pause ) total, case when position = 'teamleader' (teamleader) when position = 'waiter' (waiter) else '0' end rate event, rates, eventoverview storno =0 , event.eventid= eventoverview.eventid , event.clientid = rates.clientid group event.eventid, event.clientid)q1 group q1.staffid the table getting giving me total rate per staff , event. achieve sum of rates per staff. sum of revenue. hope can me. in advance you can enclose query in subquery , in outer query this: select *, sum(revenue) ( select * , round( (rate * time_to_sec( total ) /3600 ) , 2) revenue ( select event.eventid, event.staffid, event.role, time

.net - EF 5 Code first Entities FirstOrDefault method returns null -

this example based on programming code first ef. please @ below classes. when personrepository calls in instantiated , insertorupdate method called null value returned. of know iquariable's fitstordefault should not return null. what wrong here. help public class person { public int personid { get; set; } public int socialsecuritynumber { get; set; } public string firstname { get; set; } public string lastname { get; set; } //public int myproperty { get; set; } public list<lodging> primarycontactfor { get; set; } public list<lodging> secondarycontactfor { get; set; } public personphoto photo { get; set; } } photo class public class personphoto { public int personid { get; set; } public byte[] photo { get; set; } public string caption { get; set; } public person photoof { get; set; } } dbcontext class public class domaincontext:dbcontext,idisposable { public domaincontext(string connectio

ruby on rails - rake db:test:prepare does not setup test databse -

i using rails 4.0.0.rc1 sqlite3 , trying setup test database testing. bundle exec rake db:test:prepare did not create tables in test database. after following this question managed setup test database running bundle exec rake db:schema:load rails_env=test -t can reason task bundle exec rake db:test:prepare not setup database. below output of 2 rake tasks. indika@indika-f3e:~/documents/my_app$ bundle exec rake db:test:prepare -t ** invoke db:test:prepare (first_time) ** execute db:test:prepare indika@indika-f3e:~/documents/my_app$ indika@indika-f3e:~/documents/my_app$ bundle exec rake db:schema:load rails_env=test -t ** invoke db:schema:load (first_time) ** invoke environment (first_time) ** execute environment ** invoke db:load_config (first_time) ** execute db:load_config ** execute db:schema:load -- create_table("questions", {:force=>true}) -> 0.2590s -- initialize_schema_migrations_table() -> 0.0025s -- assume_migrated_upto_version(201305181811

PHP Solr giving a Catchable fatal error -

the following code adds documents , fires query using solr. it's showing error: solrinputdocument number 1 not valid solrinputdocument instance catchable fatal error: argument 1 passed solrclient::query() must instance of solrparams, string given in /var/www/ps/test.php on line 85 <?php require_once( 'bootstrap.php' ); $options = array( 'hostname' => solr_server_hostname ); $client = new solrclient($options); // create 2 documents represent 2 auto parts. $parts = array( 'spark_plug' => array( 'partno' => 1, 'name' => 'spark plug', 'model' => array( 'boxster', '924' ), 'year' => array( 1999, 2000 ), 'price' => 25.00, 'instock' => true, ), 'windshield' => array( 'partno' => 2, 'name' => 'windshield', 'model' => '911', &

Error installing any ruby version with RVM on OSX -

guys i'm kill myself one! i had problems rvm installing multiple versions of ruby, , following thread on stackoverflow decided remove completely. after reinstalling rvm, unable install ruby version @ all. mac os x rvm 1.20.10 stable homebrew 0.9.4 here logs: rvm install 2.0.0-p0 or: rvm install 2.0.0-p195 --autolibs=enabled searching binary rubies, might take time. no binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p0. continuing compilation. please read 'rvm mount' more information on binary rubies. installing requirements osx, might require sudo password. up-to-date. installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libxml2, libxslt, libksba, openssl… error running 'requirements_osx_brew_libs_install autoconf automake libtool pkg-config libyaml readline libxml2 libxslt libksba openssl', please read /users/admin/.rvm/log/ruby-2.0.0-p0/1368903329_package_install_autoconf_automake_libtool_

java - Apply color to tabs in excel using apache poi -

is there way tabs can given specific colors using apache poi through java?. using hssf workbook. you can change sheet tab color using following: sheet.settabcolor(int colorindex) is used that, , if use sheet.settabcolor(colornum); colornum = 0 : set black color in tab. colornum = 1 : set white color in tab. colornum = 2 : set red color in tab. colornum = 3 : set green color in tab. colornum = 4 : set blue color in tab. colornum = 5 : set yellow color in tab. and on.

A join operation using Hadoop MapReduce -

how take join of 2 record sets using map reduce ? of solutions including posted on suggest emit records based on common key , in reducer add them hashmap , take cross product. (eg. join of 2 datasets in mapreduce/hadoop ) this solution , works majority of cases in case issue rather different. dealing data has got billions of records , taking cross product of 2 sets impossible because in many cases hashmap end having few million objects. encounter heap space error. i need more efficient solution. whole point of mr deal high amount of data want know if there solution can me avoid issue. don't know if still relevant anyone, facing similar issue these days. intention use key-value store, cassandra, , use cross product. means: when running on line of type a, key in cassandra. if exists - merge records existing value (b elements). if not - create key, , add elements value. when running on line of type b, key in cassandra. if exists - merge b records existing value (a

css - Content extending off the edge of the screen -

i have layout have 2 rows of 4 boxes on top of each other standard layout. want change layout on mobile devices (media-screen), in single row (i.e. 8 boxes on same line), extending off right edge of screen. user can swipe horizontally (pushing row of content off left side of screen) browse through it? each box div (clicking each box reveals more content within box) , think re-aligning them easy enough (display: inline-block), don't know how extend off screen when scroll horizontally, doesn't move whole page - moves content across viewing area. the effect i'm trying achieve bit similar how group of photos displayed on news feed on ios facebook app (ipad @ least). any tips on making possible appreciated.

scala - Field in a trait is not initialized in time -

i can't figure out why field encryptkey in following code not initialised 3 time class constructor called: trait logger{ println("construction of logger") def log(msg: string) { println(msg) } } trait encryptinglogger extends logger { println("construction of encryptinglogger") val encryptkey = 3 override def log(msg: string){ super.log(msg.map(encrypt(_, encryptkey))) } def encrypt(c: char, key: int) = if (c islower) (((c - 'a') + key) % 26 + 'a').tochar else if (c isupper) (((c.toint - 'a') + key) % 26 + 'a').tochar else c } class secretagent (val id: string, val name: string) extends logger { println("construction of secretagent") log("agent " + name + " id " + id + " created.") } val bond = new secretagent("007", "james bond") encryptinglogger in understanding, linearization of created object be: secretagent -> encr