Posts

Showing posts from September, 2010

Rapleaf for companies - API to get corporate info? -

is there api or tool getting company information, such as: location revenue number of employees location(s) and conversely, given constraints on above parameters, return matching businesses? for publicly traded companies, can lot of information http://www.mergent.com/servius for companies, use http://compass.webservius.com - can work in both modes (given business return location/sales/number of employees/etc, , given these parameters can return list of businesses)

php - Convert HTML page to an image -

i want change html page image. there way in php change or save html page image? this not easy; nulluserexception says in comment, need render html page on server-side, not php (or other server-sided language) has built in. the approach comes mind write program (probably not in php, rather c# or c++) runs on server, fires web browser, , series of screen captures (possibly combined page scrolls). nontrivial , bug-prone process, suggest looking third-party components capable of doing this. you execute program php, , when it's done running, display results file output.

opengl - Mipmaps+PBO: strange issues -

i'm using pbos load textures faster in application. if use opengl 3 or better video card can build mipmaps call glgeneratemipmap , works fine. on older opengl 2.1 card (radeon x800), function not available must use 1 of 2 legacy methods: gltexparameteri(gl_texture_2d, gl_generate_mipmap, gl_true); glteximage2d(gl_texture_2d, 0, gl_rgba8, w,h, 0,gl_rgba,gl_unsigned_byte, src); or glubuild2dmipmaps(gl_texture_2d, gl_rgba8, w,h, gl_rgba,gl_unsigned_byte, src); the first method doesn't work fine whitout pbo, introduces strange artifacts. second one, whitout pbo builds correct mipmaps, , pbo generates segfault. can help?? for completeness attach code use pbo: uint pixelbuffer; glgenbuffers(1, &pixelbuffer); glbindbuffer(gl_pixel_unpack_buffer, pixelbuffer); glbufferdata(gl_pixel_unpack_buffer, size*4, null, gl_static_read); char *pixels = (char*)glmapbuffer(gl_pixel_unpack_buffer, gl_write_only); ... transfer data glunmapbuffer(gl_pixel_unpack_buffer); ... , use...

Serializing dictionary in Django to use with Dajaxice or ajax -

i'm trying write monitor site temperature devices gets updated every x seconds. far have function returns dictionary using dajaxice. ajax.py: def temperature(request): temperature_dict = {} filter_device in temperaturedevices.objects.all(): get_objects = temperaturedata.objects.filter(device=filter_device) current_object = get_objects.latest('date') current_data = current_object.data temperature_dict[filter_device] = current_data table = str(temperature_dict) return simplejson.dumps({'table':table}) and callback: function my_callback(data){ if(data!=dajaxice.exception){ document.getelementbyid('test').innerhtml = data.table; } else{ alert('error'); } } dajaxice.toolbox.monitor.temperature('my_callback'); originally, html looks this: <div id="test"> <tr> {% label, value in table %} <td>{{ label }} </td> <td>{{ value ...

c - Given a char* with the prototype, can we cast a void* to a function pointer? and run it? -

i've declared many functions in 1 driver, , passing pointers functions driver in list node format: struct node { char def_prototype[256]; //example:(int (*)(wchar, int, int)) void *def_function; }; is there way typecast def_function prototype given in def_prototype ? currently i'm using simple switch , strcmp, wanted generalize if possible. ps: know casting between void pointer , function pointer unsafe (as mentioned in various places in so), desperate times call desperate measures , have taken lot of care. edit: sorry lack in clarity. want call function (not cast it), making function pointer @ runtime based on char[] provided. edit again: since i'm working @ kernel level ( windows driver ), don't have access resources, so, i'm sticking current implementation (with changes kill back-doors). help. a implementation of similar ideas libffi . implements gory details of declaring , calling functions arbitrary calling conventions , signatures...

java - How to show collection elements as items in selectManyListbox? -

i have bean: public projectserviceimpl { public list<project> getallprojects () { ... } } i want list these projects items in <h:selectmanylistbox> . when user selects 1 or more items , press submit button, selected items should converted projects. i'm confused little how list items , how correspondent converter should like? you need implement converter#getasstring() desired java object been represented in unique string representation can used http request parameter. using database technical id (the primary key) very useful here. public string getasstring(facescontext context, uicomponent component, object value) { // convert project object unique string representation. return string.valueof(((project) value).getid()); } then need implement converter#getasobject() http request parameter (which per definition string ) can converted desired java object ( project in case)`. public object getasobject(facescontext context, uicompo...

html - How to know the height the space left on a browser by the menus, bookmarks and tabs? -

i want make page (html + css) fits space left on browser without horizontal , vertical scrollbars. now readind question on web browser and, probably, can see horizontal scrollbar. want use space without using horizontal , vertical scrollbars. i think looking window.innerwidth , window.innerheight , friends. check out this great table on quirksmode.org overview on variables supported browser. edit: pure css in css have width: 100% , height: 100% . if work scenario, use them. avoid scroll bars, can use overflow: hidden on body, careful because prevents scrolling completely. depends on want do.

pipe - Fetching via wget to memory & bypassing disk writes -

is possible download contents of website—a set of html pages—straight memory without writing out disk? i have cluster of machines 24g of installed each, i’m limited disk quota several hundreds mb. thinking of redirecting output wget kind of in-memory structure without storing contents on disk. other option create own version of wget may there simple way pipes also best way run download in parallel (the cluster has >20 nodes). can’t use file system in case. see wget download options : ‘-o file’ ‘--output-document=file’ the documents not written appropriate files, concatenated , written file. if ‘-’ used file, documents printed standard output, disabling link conversion. (use ‘./-’ print file literally named ‘-’.) if want read files perl program, can invoke wget using backticks. depending on really need do, might able using lwp::simple 's get . use lwp::simple; $content = get("http://www.example.com/"); die ...

gcc - Preventing recursive C #include -

i understand rules #include c preprocessor, don't understand completely. right now, have 2 header files, move.h , board.h both typedef respective type (move , board). in both header files, need reference type defined in other header file. right have #include "move.h" in board.h , #include "board.h" in move.h. when compile though, gcc flips out , gives me long (what looks infinite recursive) error message flipping between move.h , board.h. how include these files i'm not recursively including indefinitely? you need forward declarations , have created infinite loops of includes, forward declarations proper solution. here's example: move.h #ifndef move_h_ #define move_h_ struct board; /* forward declaration */ struct move { struct board *m_board; /* note it's pointer compiler doesn't * need full definition of struct board yet... * make sure set something!*/ }; #en...

Doing time subtraction with jQuery -

i have 2 time values on page: 8:00 22:30 i need subtract 8 22:30 , 14:30. is there straight forward way in jquery? plug-ins fine me if they're necessary. update : second number grand total like 48:45 anything subtract should subtract value total, not date related calculations. you can in javascript. suppose have start = '8:00' , end = '22:30' . code follows: <script type="text/javascript"> var start = '8:00'; var end = '23:30'; s = start.split(':'); e = end.split(':'); min = e[1]-s[1]; hour_carry = 0; if(min < 0){ min += 60; hour_carry += 1; } hour = e[0]-s[0]-hour_carry; diff = hour + ":" + min; alert(diff); </script> in end, diff time difference.

java - Is it unnecessary to put super() in constructor? -

isn't 1 automatically put compiler if don't put in subclass's constructor? that means don't need care it? in articles put out. and if i've got 1 constructor arguments, constructor, or take constructor without argument list? firstly terminology: no-args constructor: constructor no parameters; accessible no-args constructor: no-args constructor in superclass visible subclass. means either public or protected or, if both classes in same package, package access; and default constructor: public no-args constructor added compiler when there no explicit constructor in class. so classes have @ least 1 constructor. subclasses constructors may specify first thing constructor in superclass invoke before executing code in subclass's constructor. if subclass constructor not specify superclass constructor invoke compiler automatically call accessible no-args constructor in superclass. if superclass has no no-arg constructor or isn't acce...

map - Key repeats and ranges in Vim mappings -

i want define mapping in .gvimrc such if last key pressed held, triggered action repeated. specifically, want like map <space>t :set transparency-=1 map <space>t :set transparency+=1 for macvim, want transparency continue decreased/increased when t/t held (don't want have keep pressing spacebar). if have suggestion nicer way adjust transparency, appreciate also. separately, nice able able type 20 space t , have transparency decreased 20; however, when try an e481: no range allowed. how enable range specification? thanks lot. i not sure first part of question, 20 <space> t able job: :map <space>t :<c-u>exe "set transparency-=".v:count1<cr> with <c-u> remove line range added ex command when type 20 in normal mode. with exe execute 'dynamic' vimscript. v:count1 count given last normal mode command (20 in example). , if there no count given defaults 1. for additional information s...

image processing - Calculating displacement moved in MATLAB -

i need compare 2 or more images calculate how point shifted in x , y direction. how go doing in matlab ? what looking "optical flow" algorithm. there many around, faster less accurate, slower , more accurate. click here find matlab optical flow implementation (lucas kanade).

debugging - PHP - recognize when the function was called -

i'm thinking how find function called. problem need find php calling mail() function. 1 way use register_tick_function() , i'll need open each file , check on each line. project huge, take long parse each file in php. other way? or option how override mail() function? to override built-in mail function, take @ override_function part of advanced php debugger pecl extension - can use debug_backtrace find out caller details... //define code override mail function (note i've used php5.3 nowdoc syntax avoid //the need escape dollar symbols!! $code=<<<'code' $trace=debug_backtrace(); $caller=array_shift($trace); echo 'mail() called '.$caller['function'] if (isset($caller['class'])) echo 'in '.$caller['class']; code; //install override override_function('mail', '$to,$subject,$msg,$hdrs,$params', $code);

jpa - Why EclipseLink is adding discriminator column for joined inheritance strategy? -

i using joined inheritance strategy eclipselink jpa implementation. have noticed eclipselink adding discriminator column, named default dtype, database schema. understand, discriminator needed 1 table inheritance strategy, why joined strategy? eclipselink needs column because i've got errors after removing it. column added performance reasons, etc? not particularly happy since point of view of database schema column unnecessary clutter. hibernate based jpa not similar. from joined table inheritance : in joined table inheritance, each class shares data root table. in addition, each subclass defines own table adds extended state. following example shows 2 tables, project , l_project, 2 classes, project , largeproject: ... the discriminator column determines type , joined table use need discriminator column in parent table.

asp.net 3.5 - Dynamic value in dropdownlist onchange call -

in following code snippet i'm trying set setprice argument dynamically. xhtml: <asp:dropdownlist id="cctype" runat="server" onchange="setprice('<%# eval("setpriceval") %>')" tabindex="16"> </asp:dropdownlist> code behind: dim setpriceval literal = ctype(findcontrol("setpriceval"),literal) setpriceval.text = "0" i error saying server tag not formed. have gone wrong way or there syntax error can't see? i believe it's: <asp:dropdownlist id="cctype" runat="server" onchange='<%# setprice(eval("setpriceval"))%>' tabindex="16"> </asp:dropdownlist>

Fixed: "Android: Detecting focus/pressed color" -

i'm trying detect focus/pressed color button , other elements. needed because i'm developing new components , it's important part of platform. colors orange on android sdk , green on htc senseui. if detect color component part of platform on both version. does knows how this? it's possible create "selector" uses custom image default state , platform default focus/selection. to follow steps: 1) create xml file selector in "res/drawable" (e.g. "red_button.xml"): <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@android:drawable/btn_default" > </item> <item android:state_focused="true" android:drawable="@android:drawable/btn_default" > </item> <item android:drawab...

c - Seg fault with open command when trying to open very large file -

i'm taking networking class @ school , using c/gdb first time. our assignment make webserver communicates client browser. underway , can open files , send them client. goes great till open large file , seg fault. i'm not pro @ c/gdb i'm sorry if causing me ask silly questions , not able see solution myself when looked @ dumped core see seg fault comes here: if (-1 == (openfd = open(path, o_rdonly))) specifically tasked opening file , sending client browser. algorithm goes: open/error catch read file buffer/error catch send file we tasked making sure server doesn't crash when sending large files. problem seems opening them. can send smaller files fine. file in question 29.5mb. the whole algorithm is: ssize_t send_file(int conn, char *path, int len, int blksize, char *mime) { int openfd; // file descriptor file open @ path int temp; // counter size of file send char buffer[len]; // buffer read file opening len big // open file if (-1 == (ope...

Write shell script that can only be run by a sudo user in Ubuntu -

i'm writing shell script supposed run users in sudo user list, what's appropriate way of doing this? what i'm thinking in shell script, try create dummy file in system dir such /var/run/ , remove it, users not in sudo list receive permission error, believe there gotta more appropriate way of doing this, helping you can check values of $uid , $euid in script. 0 being equivalent root. or, if not bash, can use id -u .

c# - Possible to construct form on background thread, then display on UI thread -

update: summarize question has boiled down to: i hoping constructing .net forms , controls did not create window handles -- hoping process delayed until form.show/form.showdialog can confirm or deny whether true? i've got large winforms form tab control, many many controls on form, pauses while loading couple seconds. i've narrowed down designer generated code in initializecomponent, rather of logic in constructor or onload. i'm aware can't trying interact ui on thread other main ui thread, i'd have application pre-load form (run constructor) in background, it's ready display on ui thread instantly user wants open it. however, when constructing in background thread, on line in designer: this.cmbcombobox.autocompletemode = system.windows.forms.autocompletemode.suggest; i'm getting error current thread must set single thread apartment (sta) mode before ole calls can made. ensure main function has stathreadattribute marked on it...

c# - How to make row in gridview bold and regular programatically -

hi have written program in c# outlook u can send, receive, reply , forward mails in text format through database used gridview retrieve mails. new task how mark unread message bold , read message regular in text. help needed you can loop through rows using. datagridviewcellstyle style = new datagridviewcellstyle(); style.font = new font(datagridview.font, fontstyle.bold); foreach(datagridviewrow dg_r in mydatagridview.rows) { dg_r.defaultcellstyle = style; // sets row style bold }

dataset - ActionScript: Library implementing a 'set' datatype? -

has implemented set class in actionscript? specifically, set similar python's set implementation (unordered, unique, o(1) membership, etc). i'd able iterate on using for each , perform operations union , intersection , list of contained items… possible implement using dictionary , proxy , i'd rather not reimplement if someone's done heavy lifting. this looks decent enough implementation. link collection class

Javascript this in jQuery -

i saw old code had: <input type="submit" name="submit" onsubmit="somefunction(this)" /> i jquery'ing script, how pure javascript (this) object in jquery? $("input[name=submit]").click(function() { somefunction(// ?? $(this) ); }); thanks! you can use this , refers clicked object, true jquery event handler: $("input[name=submit]").submit(function() { somefunction(this); }); or, better use this inside function, it's just: $("input[name=submit]").submit(somefunction); this won't cover when it's not submitted via button though, better @ <form> level or via .live() if it's dynamic. note doing this, it'll change this refer <form> instead of <input> , depending on function may need adjustments that.

How do I implement the Signals (from Django) concept in C# -

i'm trying implement signals django ( http://docs.djangoproject.com/en/dev/topics/signals/ ), or concept in c# reduce/eliminate coupling/method dependencies. so far, i'm replicating code fine, until point whereby realised methods ain't objects in c# in python. thought of pointers, , realised can't have pointers methods. c# version of delegates. then realised delegates have unique signature it, can't mix delegated methods (with diff signatures) list, or can i? i did bit more googling, , found reactive linq, far, linq looks awesome, still don't when use them. so question is, how implement signals concept in c#? thanks! oh did mention i'm new (1 day old) c#? have background of various other languages incl java/c/python. cheers :) what talking here typically handled events in c#, example; public class sometype { public event eventhandler someevent; protected virtual void onsomeevent() { eventhandler handler = someevent;...

android - Listener for ViewFlipper widget flipping events -

i have viewflipper implementation needs improved. viewflipper has 3 child views. basically, want indicator on child view active. viewflipper part of complex layout has list views, etc. switching of views automatic , done in specified interval. from android's sdk reference, haven't seen listener when viewflipper changes child view. do guys know of way can have listener event? or there alternative ways can implement feature besides using viewflipper ? thanks! if apply animation (out or in animation) on view switching, can set listener animation and, example, act on animation end. viewflipper.getinanimation().setanimationlistener(new animation.animationlistener() { public void onanimationstart(animation animation) {} public void onanimationrepeat(animation animation) {} public void onanimationend(animation animation) {} });

unit testing - phpUnit & Ant unrecognized option --log-xml -

i trying automate testing procedure using ant. error: test: phpunit 3.5.0 sebastian bergmann. unrecognized option --log-xml /var/www/nrka2/build/build.xml:30: exec returned: 1 build failed (total time: 1 second) and build.xml <?xml version="1.0" encoding="utf-8"?> <project name="eventmanager" default="build" basedir="../"> <target name="getprops"> <property file="${basedir}/build/ant.properties" /> <condition property="script-suffix" value="" else=""> <os family="unix" /> </condition> <echo message="---- build properties ----" /> <echo message="" /> <echo message="os ${os.name}" /> <echo message="basedir ${basedir}" /> <echo message="property file ${basedir}/build/ant.pro...

rotate uiview using touch (ipad and iphone) -

i trying design app , struggling think of best way it. i'm after advice please! if imaging bicycle wheel in middle of ipad (and iphone)... want user able click on tyre , spin left or right. depending on speed of swish drive speed of wheel rotation. it should rotate around centre of wheel , not move other direction. do need use graphics code, or listen touch, check area touched, rotate image around it's centre left or right? really i'm after pointers around methods use - i'm not being lazy , asking code, if knows of tutorials - immensely!! thanks info. your best bet use 1 of uigesturerecognizer subclasses, uipangesturerecognizer includes velocity. apple's simplegesturerecognizers project started.

How to set Emacs theme? -

i new emacs , wondering how load theme of choosing ( http://lambda.nirv.net/m/files/color-theme-chocolate-rain.el ) i on ubuntu, , have no idea doing (yet :p) in regards emacs, part. this should work (you need change color-theme-tty-dark color-theme-chocolate-rain : ;; enable color theme (require 'color-theme) (color-theme-initialize) (color-theme-tty-dark)

frameworks - frank.php templates -

happy see sinatra-like microframework in php http://github.com/brucespang/frank.php but, documentation scarce, , i'm not understading reading code (maybe i'm not able): you can define views directory set(array('views' => dirname(__file__) . '/templates')); but how can render file inside it? how passing parameters? there no templating, simple php? bye if take @ index.php file (i added comments myself): // when go */template get("/template", function(){ // calls template named "template" , passes variables render('template', array('locals' => array('name' => 'template'))); }); // setup "template" named template template("template", function($locals){ echo 'hello '.$locals['name']; }); it says directly in readme doesn't support templating languages yet: what frank.php missing: spiffy template languages haml ...

classloader - How to unload an already loaded class in Java? -

this question has answer here: unloading classes in java? 7 answers how unload class class loader, can use changed class on fly without restarting application (hot deployment)? possible that? java rebel reloads changed classes on fly. see the jrebel website details . don't know recommend production environment though, because of performance issues. jrebel on occasion bogs things down momentarily when you've recompiled server.

C++ syntax for explicit specialization of a template function in a template class? -

i have code works in vc9 (microsoft visual c++ 2008 sp1) not in gcc 4.2 (on mac): struct tag {}; template< typename t > struct c { template< typename tag > void f( t ); // declaration template<> inline void f< tag >( t ) {} // error: explicit specialization in }; // non-namespace scope 'structc<t>' i understand gcc me move explicit specialization outside class can't figure out syntax. ideas? // following not correct syntax, is? template< typename t > template<> inline void c< t >::f< tag >( t ) {} you can't specialize member function without explicitly specializing containing class. can forward calls member function of partially specialized type: template<class t, class tag> struct helper { static void f(t); }; template<class t> struct helper<t, tag1> { static void f(t) {} }; template<class t...

c# - Using Ninject IOC to replace a factory -

i've got factory method inside parser. load token handler token, or drop through default handler. i've implemented switch , dictionary<string,type> both approaches require me store mapping somewhere else handler class. we using ninject ioc , i've realized can using kernel.get<itokenhandler>(tokenname); but doesn't save me storing information on token handler can deal in 2 locations. there way can decorate handler gets mapped automatically? if follow question correctly, sounds want retrieve named binding. didn't mention version of ninject using, based on code snippet, guessing using ninject 2.0. if that's case think suffice binding in module: bind<itokenhandler>().to<yourconcretetypehere>().named(tokenname); you bind many concrete types same interface , differentiate them name, , retrieve them using precise syntax you've specified in question. if missing key, let me know.

java - how to implement a pop up confirmation window without javascript -

i want implement confirmation pop having ok , cancel button without javascript ,how can in java short answer- can't. ability close window (which is, assume want ok and/or cancel buttons do) javascript feature. if don't care closing window, can have link in web page points target="_blank" open new window.

WebLogic load balancing -

i'm developing project supported on weblogic clustered environment. i've set cluster, want load-balancing solution (currently, testing purposes, i'm using weblogic's httpclusterservlet round-robin load-balancing). there documentation gives clear comparison (with pros , cons) of various ways of providing load-balancing weblogic? these main topics want cover: performance (normal , on failover ); what failures can detected , how fast failover recovery; transparency failure (e.g., ability automatically retry idempotent request); how each load-balancing solution adapted various topologies (n-tier, clustering) thanks in advance help. is there documentation gives clear comparison (with pros , cons) of various ways of providing load-balancing weblogic? it's not clear kind of application building , kind of technologies involved. but... you find useful information in failover , replication in cluster , load balancing in cluster (also @ clu...

windows installer - How to create .msi setup package for Visual Studio 2008 Add-in? -

i've created add-in visual studio 2008. thing remaining create setup package others can install , use add-in. how can in visual studio? i tried creating simple setup package, inserting files add-ins folder in user's documents folder, , worked expected, except add-in didn't show in visual studio. i've found guide creating msi setup package visual studio add-ins. it's located here: http://www.codeproject.com/kb/install/addincustomaction.aspx

c# - Is it normal practise to have getters which call private methods in API design? -

is common, in api design, this: public readonlycollection getcollection { { // get's read collection here... } } in body of get, calls private method fills collection. expose one, consistent object clients. thing confuses me if right make class , members static? after all, returning object class immutable (i keep thinking immutable class should static?). aware static not insinuate stateless. right in thinking static right centralised 1 entity (e.g. company details)? thanks avoid static - trait of procedural programming. use utility methods , widely-accessibly constants. and no - static != immutable, have nothing in common. static global state, not thread-safe, , can't have more 1 occurrence of static data in application. immutable means object instance cannot change internal state. string example - once construct it, cannot change it. has nothing static-ness, though. as first question - fine getter expose internal collection, read-only copy of it. ...

How do you access the menu model from a Zotonic template? -

i want write own style of menu, prefer in templates rather making own menu scomp. i want able like: {% if m.menu %} <ul> {% top_level_id in m.menu %} {% m.rsc[top_level_id] top_level %} <li><a href="{{ top_level.page_url }}">{{ top_level.title }}</a> {% if top_level.menu %} <ul> {% mid_level_id in top_level.menu %} {% m.rsc[mid_level_id] mid_level %} <li><a href="{{ midlevel.page_url }}">{{ mid_level.title }}</a></li> {% endwith %} {% endfor %} </ul> {% endif %} </li> {% endwith %} {% endfor %} </ul> {% endif %} how access menu model zotonic template? to add previous answer. standard _menu.tpl receives list menu items. list result of depth-first tree walk of complete menu. every menu record with {menurscid, depthofmenu, nrinsubmenu, hassubmenuflag} where top level men...

php - A way to play mp3 samples -

i currentyl developing site client requires artist upload music play samples of it, sorta itunes. site has php backend , using basic mp3 flash player play mp3s. my question there flash player can configured play samples or there way through php or method load portion of song , have play in player? you have few options: you programatically interface tool silverlight or flex access media player control , set properties. you use tool ffmpeg programatically create clipped version of file, similar bitpim creating ringtones, serve up. i go second approach.

javascript - Differring behaviour of Date.parse? -

alert(date.parse('mar 1 1990')); in jsfiddle, returns datetime integer, expected. on machine, returns... timestamp string? thu mar 01 1990 00:00:00 gmt-0500 (est) vs 636267600000 ecmascript language specification 15.9.4.2 date.parse (string) the parse function applies tostring operator argument , interprets resulting string date , time; it returns number , utc time value corresponding date , time. string may interpreted local time, utc time, or time in other time zone, depending on contents of string. function first attempts parse format of string according rules called out in date time string format (15.9.1.15). if string not conform format function may fall implementation-specific heuristics or implementation-specific date formats. unrecognizable strings or dates containing illegal element values in format string shall cause date.parse return nan . what did wrong 2 tests not same: alert(date.parse(...

c++ - Compilation error: `Class' does not name a type -

i have pretty simple class called simulator in simulator.h #include <iostream.h> #include <stdlib.h> class simulator { private: short int startfloor; short int destfloor; public: void setfloors(); void getfloors(short int &, short int &); }; now when compile it, error: simulator.h:4: error: `class' not name type what have got wrong here? you need make class lowercase (and should stop using deprecated iostream.h header): #include <iostream> #include <cstdlib> class simulator { // stuff here }

html - How I can overlap a DIV on to other DIV? -

i trying make overlapping div onto other visually . trying { position:absolute; top:-10px; } in css, found top attribute not working in firefox. dear fellas, how that? please me codes or examples. thx in advance here's easy way css .top { position: relative; } .topabs { position: absolute; } html <div class='top'> <div class='topabs'> i'm top div </div> </div> <div>no styles, frowns :(</div>​ the relative positioned div collapses there no contents, causing coordinates 0,0 coordinates of absolute positioned div of div underneath. fiddle http://jsfiddle.net/y5szw/

iis - Share data between web services -

i want create 2 web services, , b, hosted in iis. used updated variable x , b retrieve value of x. the question whether can make work declaring x static class variable. if not, can ? ps: combining them single service not option me. the answer yes. 1 can use static variable since instances of web service executed in same app domain.

asp.net mvc - Call Controler not with full name -

i new asp.net mvc.we create controller 'admincontroller' call name of admin. how asp.net mvc handle don't need call controller full name? the controller name specify in url not same class name, action name not same actual method on controller. there internal mapping between controller/action , class/method mvc when determining code needs executed. the generic mapping rule is: for controllers, take controller name ( admin ) , add suffix controller , search class name ( admincontroller ). for actions, take name of action ( details ) , search method on controller same name ( actionresult details() {} ). however, mvc supports explicit mapping of action method different name through actionname attribute. thus, have action called edit mapped method actionresult edituser() {} example. it possible future versions of mvc add similar controllername attribute allows explicit mapping of particular controller name particular class. (in fact, hope do, solve p...

How do I set the path to a DLL file in Visual Studio? -

i developed application depends on dll file. when debug application, applicationwould complain that: "this application has failed start because xxx.dll not found." so have copy dll file same directory .vcproj file. is there way set project dll file in (preferably) relative path or (not preferred) absolute path? similar concept how set include , library path in project settings. i mean when debug application (hitting f5 ) above error pop up. go project properties (alt+f7) under debugging, right there's environment field. add relative path there (relative vcproj folder) i.e. ..\some-framework\lib appending path=%path%;$(projectdir)\some-framework\lib or prepending path path=c:\some-framework\lib;%path% hit f5 (debug) again , should work.

sql - Is it possible to insert data into a MySQL view? -

i made mysql view 4 tables. possible insert data view , have mysql automatically pass data right table? if using inner joins, , view contains columns in base tables, view might updatable. however, multiple-table updatable view, insert can work if inserts single table. split insert operation multiple insert statements. you may want check out following article more information on topic: mysql reference manual :: updatable , insertable views consider following example: create table table_a (id int, value int); create table table_b (id int, ta_id int, value int); insert table_a values (1, 10); insert table_a values (2, 20); insert table_a values (3, 30); insert table_b values (1, 1, 100); insert table_b values (2, 1, 200); insert table_b values (3, 2, 300); insert table_b values (4, 2, 400); now let's create view: create view v select a.id a_id, b.id b_id, b.ta_id, a.value v1, b.value v2 table_a inner join table_b b on (b.ta_id =...

How to clear all activities in Android app -

my app has many activities can called in order example activity history: -> b -> c -> d -> -> b -> e now in activity e, 'deregistering' device (logging user out, , deleting data might have downloaded sdcard). desire behavior app 'starts over' , user prompted login activity , hitting return user home screen. so now, activity e should clear activity stack in way. currently, setting flag_activity_clear_top when launching a's intent e. problem is, when user had visited , gone intermediate activities , revisited before going e, there still activities on stack. a -> b -> c -> d -> a so user has been logged out , can't use activities b-d, if user hits activity a, can access activities b-d. there simple way have activities other login activity cleared stack? update: so i've tried updating baseactivity (each activity in app subclasses one) contain static flag isderegistering tells activity destroy if true. problem ...

.net - Operating System Version Prerequisite -

i have application requires @ least windows xp sp3. how can go checking either in application itself, or in msi, , automating installation? in msi author launchcondition using operating system properties you want check versionnt > 501 or ( versionnt = 501 , servicepacklevel > 2 ) (tweak meet exact needs ) in windows installer xml looks like: <product...> <condition message="[productname] setup requires windows xp sp3 or greater install">versionnt > 501 or ( versionnt = 501 , servicepacklevel > 2 ) or installed</condition> ... </product>

ruby on rails - How to modify the create & update method in RoR? -

i know after create or update methods done, have method respond_to |format| format.js end since change form remote form non remote form, won't use format.js anymore, want refresh page, after user create/update product, have code: respond_to |format| page.reload end but don't work, try not use respond_to do, have page.reload. show me site this: http://localhost:3000/products/50 i want reload page after create/update, why can't in way? the reload method reloads browser's current location using javascript. suggest want server-side redirect after creating or updating resource. one of these alternatives: redirect_to product_path(@product) # redirect 'show' page product redirect_to products_path # redirect products' index page

Reading corrupted file in python -

i've got file, looks alt text http://img40.imageshack.us/img40/4581/crapq.png there 5 lines shown. running script with open('hello.txt', 'r') hello: line in hello: print line, gives num 1 ctl00$header1$login1$txtusername=ыют;cbШ▌ and that's all. how can read entire file? tia entire_file = open('hello.txt', 'rb').read() print 'number of \\n: %d, number of bytes %d' % ( entire_file.count('\n'), len(entire_file))

ruby on rails - Need help optimizing this database query -

i hoping optimizing query rails site: vacation has_many :departures has_many :photos departure belongs_to :vacation photo belongs_to :vacation i need find list of vacations ordered , displayed departure. if vacation has 2 departures, should show in list twice (once each departure). @dates = departure.find(:all, :order => "start_at", :include => [{:vacation => :photos}], :conditions => ["vacations.duration > 1 , start_at > ?", time.now]) the issue need collect future departures each vacation, results in new query each departure listed. any ideas on how better accomplish this? you don't have limit on query, wouldn't have need pulled memory? have array every future departure each vacation want display. so use array have. vacation_id = 3 # or whatever - in loop. @dates_for_vacation = @dates.select{|d| d.vacation_id == vacation_id}

c - Segmentation fault occurring when modifying a string using pointers? -

context i'm learning c, , i'm trying reverse string in place using pointers. (i know can use array; more learning pointers.) problem i keep getting segmentation faults when trying run code below. gcc seems not *end = *begin; line. why that? especially since code identical the non-evil c function discussed in question #include <stdio.h> #include <string.h> void my_strrev(char* begin){ char temp; char* end; end = begin + strlen(begin) - 1; while(end>begin){ temp = *end; *end = *begin; *begin = temp; end--; begin++; } } main(){ char *string = "foobar"; my_strrev(string); printf("%s", string); } one problem lies parameter pass function: char *string = "foobar"; this static string allocated in read-only portion. when try overwrite *end = *begin; you'll segfault. try with char string[] = "foobar"; and should notic...

Single Sign-on across Tomcat servers without clustering -

we have several tomcat servers serving content single domain (via apache httpd front end.) balance memory usage on 1 of our servlets. is, each server provides same web application, different data set. we'd implement single sign-on on our website. in other words, have httpd configured visitor http://example.com/reports/a/ goes reports.war on tomcat server a, while http://example.com/reports/b/ goes reports.war on tomcat server b. each url separate report, , can't fit both reports in ram on single server. as understand it, can't use tomcat clustering because that's designed server replication, i.e. identical servers identical data. i've looked session sharing via tomcat's persistentmanager , jdbc store, appears designed caching sessions, rather sharing them. am missing something, or going require fair amount of custom coding? (i'm willing try open source servlet container, such jboss or glassfish, if have built in.) as on same domain...

The correct place to put a markdown extension file in a django project? -

i've created markdown extension file (called mdx_xxx.py) django project i'm working on can't decide put it. the documentation says file should reside on pythonpath , i've seen several blog posts inviting put file in root directory of project. however, seems odd place me rather see in related application directory it's not on pythonpath anymore. could experienced django programmer shed light on issue? thanks requiring extension files live directly on python path, , not inside package, (imo) unfortunate limitation of python markdown implementation. if extension specific project, think putting in project root best option available. on other hand, if extension reusable in other cases, package simple setup.py , install virtualenv using pip, other dependencies.

c - SIMD (SSE) instruction for division in GCC -

i'd optimize following snippet using sse instructions if possible: /* * data structure */ typedef struct v3d v3d; struct v3d { double x; double y; double z; } tmp = { 1.0, 2.0, 3.0 }; /* * part should "optimized" */ tmp.x /= 4.0; tmp.y /= 4.0; tmp.z /= 4.0; is possible @ all? i've used simd extension under windows, have not yet under linux. being said should able take advantage of divps sse operation divide 4 float vector 4 float vector. using doubles, you'll want sse2 version divpd . forgot, make sure build -msse2 switch. i found page details sse gcc builtins. looks kind of old, should start. http://ds9a.nl/gcc-simd/

WiX Stock Images -

wix has ability replace stock images custom ones http://wix.sourceforge.net/manual-wix2/wixui_dialog_library.htm is there freely available sets of images installers use if wix stock ones don't suit our style. as being programmer should play strengths , not try graphic designer when i'm not. i'm not aware of any. rolled own using paint.net iswix provide images clients ( or management ) , let them fancy. it's branding after not mine.

javascript - General reasons not to deal with Document's and Element's prototype -

are there general reasons not deal document's , element's prototype? i create own little framework, because current project doesn't need mass of features of existing frameworks. i don't need support browsers don't support element/document-constructor , not execute scripts not under control. so recommend extend prototype or should go usual way , create own objects element/document? do plan extend default dom elements? if so, please don't. juriy zaytsev (aka kangax) describes why not in what’s wrong extending dom .

mercurial - How to set "hg diff" output shows in gvim? -

i use mercurial , want see modified change in vim or gvim. there hg diff show modified changes in diff format. want see in vim original version , modified version side-by-side. i try extdiff in extdiffextension doesn't work , gvim open blank file. i know there gvim -d localfile otherfile don't know how config mercurial. check this: using vimdiff view single diffs hg cat <filename> | vim - -c ":vert diffsplit <filename>" -c "map q :qa!<cr>";

java - Unit testing controllers with annotations -

i'm trying write unit tests controllers in spring mvc web app. have got comprehensive set of unit tests domain model, completeness want test controllers too. the issue i'm facing trying test them without loading spring context. thought around mocking, method in controller has @transactional annotation attempts open transaction (and fails nullpointerexception because no spring context loaded). code example: public class userscontroller { @autowired private usermanager usermanager; @transactional @requestmapping(method = requestmethod.post) public modelandview create(user user) { usermanager.save(user); modalandview mav = new modelandview(); mav.addobject("user", user); mav.setviewname("users/view"); return mav; } } so want test behaviour without loading context , persisting user. does have ideas on how can achieve this? cheers, caps i'd mocking way go here. @transactional annotation have n...

registry - Disable the internet without touching the hardware -

how go disabling internet on computer without touching hardware (modem, router, etc) , without disabling network connections of control panel. there way tweak on registry instead? i'm wanting achieve control younger sister's usage of our computer @ home. she's kinda getting addicted mom suggested make application can such thing when time hit. e.g. when time 10pm internet gets disabled automatically won't have , shut down comp instead. i know how deal checking time , such thing i'm missing registry tweak required it. thank who'd answer. what using command line commands described here:http://www.asp101.com/articles/stanley/nicsettings/default.asp change ip address won't work or bogus dns server? have time-checking application call batch file or execute command.

php - HTML Radiobutton form not POSTing -

i have written small html form , added page. goal post value of checked button php page have written. php page not getting value reason. not getting php errors. codes below. form.php <form action="http://www.zbrowntechnology.com/insanebrain/quiz.php" method="post"> <font color="white" size="3"> <?php $con = mysql_connect("host", "user", "pass"); if(!$con) { die('unable connect mysql: '.mysql_error()); } mysql_select_db("zach_insaneb", $con); $result = mysql_query("select name quiz"); while($row = mysql_fetch_assoc($result)) { $qname = $row['name']; echo "<input type='radio' name='button1' id='$qname'>"; echo "<label for='$qname'><font color='white'/>$qname</font></label>"; } ?> </font> </div> </div> <div id="oobj12"> <di...

batch file - Errorlevels set by commands on Windows -

i have batch program calls several child batch programs , make extensive use of various windows commands. in case of error, provide logging information error details user. how know various error codes (a number in range 0 256) these commands can return , interpretations in english? if on dos (which highly doubt) way is command if errorlevel 255 echo 255 if errorlevel 254 echo 254 if errorlevel 253 echo 253 ... if errorlevel 1 echo 1 if errorlevel 0 echo 0 the interpretations in natural language you, should know did try there. note on windows can do command echo %errorlevel%

javascript - Google maps - pass information into an event Listener -

i think scope problem. since event triggered after have added listeners num_markers has been overridden next cycle in loop. is there way can pass variables event function? i tried approach didn't me. google maps: event listener remembering final value of variable var map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); var info_window = new google.maps.infowindow(); var markers = []; function load_markers() { var bounds_url = map.getbounds().tourlvalue(); $.ajax({ url:'/retailer-markers?bounds='+bounds_url, datatype: 'json', success: function(data) { for(i = 0; < data.length; i++) { var marker_pos = new google.maps.latlng(data[i]['lat'], data[i]['long']); //every time listener event calle...

html - Problems with form and POST -

i facing problems form, wrote app in python3.1 , when make or post via ajax works pefectly when i' ve try same thing form-way environ['wsgi.input'] give me this: -----------------------------4974611941277794205934495116--\r in first time think because file try upload after eliminate file element , give me same thing means let code of form: <iframe id="hidden-frm" name="hidden-frm" style="display: none;"> </iframe> <form enctype="multipart/form-data" action="gate.py?bt=upload" method="post" name="input" target="hidden-frm"> <input id="testtxt" type="text"/> <input type="submit" value="presiona aqui!"/> </form> thanks in advance. that encoding result of enctype="multipart/form-data , when suspect expecting default encoding of application/x-www-form-urlencoded (ie. key=value&key2=v...

c++ - Speed of finite state machines - OO vs procedural -

hey all, designing program accept input series of tokens , feed them finite state machine have designed. have designed test finite state machine in object-oriented style, structs machine , transitions, etc. application writing 1 speed important. so far, using machine, adding new states , like, has proven easy , not complicated. easy comprehend , leaving month , coming code not disorienting. however, not sure speed trade off current oo approach. allocation of objects, storage of data, etc. take away of speed had using bunch of labels , goto statements? rather thinking in terms of oo being slower functional or procedural programming think in terms of operations. calling function, branching, fetching, storing etc... take time , idea of performance of each solution you'd need tally how of each of these you'll need do. the best way use oo test solution , see if it's fast enough. if not profile it, work out branches or stores costing , see if can avoid or str...

Cakephp getting session variable in model without using Auth component -

i want session variables in model. im not using auth component. there alternate way ? thanks binoy you need use session helper do, $this->session->write('key','value'); but comment states, you'll wanting set variable in model , use session write same value variable in model, rather accessing session in model. class mymodel extends appmodel{ var $username; var $password; } then in controller use along lines of, $this->mymodel->username = $this->session->read('user.id'); $this->mymodel->password = $this->session->read('user.password');

asp.net - Decoding the web.config httpmodules -

i started learning httpmodules , made first one. wondering if explain why modules in the web.config include lot of info , others not. example: not info <add name="errorlog" type="elmah.errorlogmodule, elmah"/> example lot of info <add name="urlroutingmodule" type="system.web.routing.urlroutingmodule, system.web.routing, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> what publickeytoken, version, culture. need special use those? thanks! these part of assembly's qualified name. version should self-explanatory. culture culture assembly compiled for. publickeytoken value cryptographically derived key used sign assembly, or (null) if assembly unsigned. for more information, see here .

c# - How to return autoincrement value in insert query in SQLite? -

in project use system.data.sqlite . database has table tags , contains autoincrement primary field id (type integer ). when write: using (sqlitecommand command = conn.createcommand()) { command.commandtext = "insert tags(name) values(@name) returning @id"; command.parameters.add("@id", dbtype.int32).direction = parameterdirection.output; command.executenonquery(); } visual studio said operation not supported. how fix it? error occurs on line: command.parameters.add("@id", dbtype.int32).direction = parameterdirection.output; i found working query: select last_insert_rowid()

Creating a Linq statement to create objects -

if created linq statement shown below, works fine. var jobs = in ctx.myexport select new { filename = a.filepath, jobid = a.id, }; if want use class rather anonymous type following error "cannot convert lambda expression type 'string' because not delegate type". here code want work: var jobs = in ctx.myexport select new myclass { filename = a.filepath, jobid = a.id, }; and here class: public class myclass { public string filename { get; set; } public guid jobid { get; set; } } can tell me doing wrong , how fix it? the above code correct , getting error message because of code didn't showed us. you trying assign unmaterialized query string variable result in error. changing type ienumerable materialize query whether use or not taken out data base.so solution not recomended. the answer materialize query...

sql - MySql takes a long time optimizing a join-less query -

we have simple query looks like: select a,b,c,d table a=1 , b in ('aaa', 'bbb', 'ccc', ...) no joins @ all, 5000 contsant values in in clause. now, query takes 1-20 seconds run on strong (16 core) server. table has index on (a,b), , tried reversing index (b,a). server has tons of memory, , nobody writing table - 5 processes running selects described above. we did profiling , saw queries spend 3.5 seconds in "join::optimize" (.\sql_select.cc 977). remind you, queries not use joins @ all. what cause large time spent optimizing joins on join-less table? here result of explain select: id select_type table type possible_keys key key_len ref rows 1 simple table range ix_a_b ix_a_b 65 \n 5000 using try putting 5000 values in temporary table: declare @t table (b varchar(10)) insert b select 'aaa' union select 'bbb' union select 'c' .... select table.* table join @t t on table.b ...

How to break lines in LaTeX Bibliography -

i have long url in bibliography it's not broken appears outside margins. how fixed id? breakline stuff? thanks! you should use url package here , automatically allow linebreaks. you mention in comment using package. have @ section 5.2, then, , allow linebreaks.

redcloth - What does this construction mean, in Ruby? -

the method below exists in redcloth gem. my question is: construction "to(redcloth::formatters::html)" mean? "to" isn't method in class, nor in superclass (wich string class). cheers. christian. def to_html( *rules ) apply_rules(rules) to(redcloth::formatters::html) end when search entire redcloth source def to , besides finding couple of methods start to , you'll find exact method to in ext/redcloth_scan/redcloth_scan.rb.rl . there's 2 things happen here. first, file preprocessed ragel . question, may safely ignore fact , read past weird syntax in file. focus on ruby bits. second, class redcloth::textiledoc reopend here. means class in file , in lib/redcloth/textile_doc.rb same. to instance method available piece of code quoted.