Posts

Showing posts from September, 2011

c# - Custom ErrorPage is not Working with [HandleError(ExceptionType = typeof(NotImplementedException), View = "CustomErrorView")] -

i trying handle exception in asp.net mvc application using [handleerror] . i changed in web config <customerrors mode="on" /> its not working cutom error notimplementedexception i have kept customerrorview in shared folder. please help.... namespace mvcapplicationerrorhandling.controllers { [handleerror(order = 2)] [handleerror(exceptiontype = typeof(notimplementedexception), view = "customerrorview")] public class homecontroller : controller { public actionresult index() { viewbag.message = "welcome asp.net mvc!"; return view(); } public actionresult about() { return view(); } public actionresult throwexception() { throw new applicationexception(); } public actionresult errordemo() { string strtemp; object obj = null; strtemp = obj.tostring();

Key Listener called again and again if I click on Browser's back Button with Activity and Places in GWT -

i creating search page , have use activity , places in gwt. have used key listener when user press enter redirect user on result page. problem when user use browser button , again press enter key listener call twice same if user again click button next time call trice , on. there solution this? you're adding listener when activity starts never remove (e.g. when activity stops). the full solution depends how code activity (do reuse activity instances? have separate view activity acting presenter/controller? if so, view singleton, or @ list lives longer activity , can reused activity instance? etc.)

How do I make this code (or its concept) work. it includes html, javascript, and php -

so i'm not familiar either javascript or php want create automated voter site. simple. have url increases vote count one. have verified entering url counts vote. site cookie must deleted before vote can take place.this have tried far (ps: hoping make work in chrome. if has alternative browser make work in thats fine to.): <html> <body> <script type="text/javascript"> function clearcookies() { chrome.cookies.getall({domain: "domain.com"}, function(cookies) { for(var i=0; i<cookies.length;i++) { chrome.cookies.remove({url: "domain.com" + cookies[i].path, name: cookies[i].name}); } }); } </script> <?php set_time_limit(0); while(true){ echo "<script type=\"text/javascript\"> clearcookies(); </script>"; $useragent="mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.31 (khtml, gecko) chrome/26.0.1410.64 safari/537.31"; $ch = curl_init(); curl_setopt($ch, curlopt_url, "specif

perl - If a sentence starts with a specific word, how to change a word in that sentence if it does exist? -

so, searching lines in .txt file , if starts word such "this", how swap targeted word in sentence if exist? open doing bash, perl or awk. perl -pi -e "s/^this\b/that/" myfile or, if want change different word within line, perl -pi -e "s/\btargeted\b/swap/ if /^this\b/" myfile

c# - Accessing Outlook ost file -

i have seen difference between pst , ost files , working on accessing outlook pst file through following code given below. there way use same code accessing ost file? can refer me this? private datatable getinboxitems() { datatable inboxtable; //try //{ filter = "[receivedtime] >= '" + dtpstartdate.value.tostring("dd/mm/yyyy 12:00 am") + "' , [receivedtime] <= '" + dtpenddate.value.tostring("dd/mm/yyyy 11:59 pm") + "'"; outlook.application outlookapp = getapplicationobject(); outlook.folder root = outlookapp.session.defaultstore.getrootfolder() outlook.folder; enumeratefolders(root); //string filter = "[receivedtime] > '" + dtpstartdate.value.tostring("dd/mm/yyyy") + "'"; //inbox outlook.mapifolder inboxfolder = outlookapp.session.getdefaultfolder(outlook.oldefaultfolders.olfolderinbox); inboxtable = createtable();

c++ - glDrawElements() draw my .obj models wrong -

Image
i'm having problem "gldrawelements" function in opengl. when drawing model function i'm seeing artifacts:   i didn't add light or texture. i wrote class c++: //the obj-catcher.h //just ignore chinese in code.... #include <gl\glut.h> #include <gl\glaux.h> #include"stdlib.h" #include"string.h" #include"cstdio" #include"math.h" #include"time.h" #define max_line_length 1024 //Ã¥­Ã§¬¦Ã¤¸²Ã¥¤Ã¥¶Ã¦Ã¥¤§Ã©¿Ã¥Âº¦ aux_rgbimagerec *loadbmp(char *filename) // loads bitmap image { file *file=null; // file handle if (!filename) // make sure filename given { return null; // if not return null } file=fopen(filename,"r"); // check see if file exists if (file) // file exist? { f

java - accessing the spring context -

something confuses me spring. understand 1 of main functions promote modularity , loose coupling providing way modular components (classes) wired without having knowledge of other modules' implementations, contracts expose. however, in practice, find myself in following situation. one class has spring application context. let's in main(); so load spring in main, , rest of objects nicely injected beans , can interact without being tightly coupled. but if 1 of objects has method every time it's called, needs create fresh bean? object needs reference spring application context. it's no longer pojo, it's coupled spring? i guess in practice, create global object contains spring application context easy access classes need this, still seems bit messy , counter spring philosophy of loose coupling? is 1 of things? it's not perfect it's still lot better having classes tightly coupled? edit: , if use global object hold spring application context, how

javascript - Get Position of Drag & Drop Element -

i using following code: http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-a-group-with-kineticjs/ drag & drop. my question is: how can actual position (x,y) of group after being dragged , dropped? you can use events of kinetic objects - http://www.html5canvastutorials.com/kineticjs/html5-canvas-path-mouseover/ in case - 'dragend'. group.on('dragend',function(){ console.log(group.getposition()); }); example: http://jsfiddle.net/lavrton/xesdz/

sql server ce - How to get the maximum value from local database in windows phone? -

i need maximum value table should belongs particular category. code follows : private int gethighscores(int _playmode) { int maxscore = 0; using (hangmanscoredatacontext hangmandb = new hangmanscoredatacontext(@"isostore:/hangmanscoredb.sdf")) { iqueryable<tblehangmanscore> sqlquery = hangmandb._tblehangman; sqlquery = sqlquery.where(p => p.playmode == _playmode); maxscore = sqlquery.asqueryable().max(p => p.score); } return maxscore; } i getting error an unhandled exception of type 'system.stackoverflowexception' occurred in unknown module. except maximum value rest of things working . how can solve issue ? edit : problem arises when table contains 0 numbers of records. same problem when trying minimum value also.

login to http website java -

Image
i trying login http website first time , having hard time understanding proper format sending arguments. have looked @ other examples , don't seem work me thought see if can explain me. @ point code seems absolutely nothing here is... httpurlconnection url= (httpurlconnection)new url("http://www.myameego.com/index2.php?do=login").openconnection(); url.setdooutput(true); url.setrequestmethod("post"); outputstreamwriter writer = new outputstreamwriter(url.getoutputstream()); writer.write("x-mapping-fjhppofk=6a991610ba398b3a39f4b491d5382bb4; phpsessid=kbo25e08t3qvu08l1shkq8kk94; username=coled; pass=ed45d626b07112a8a501d9672f3b92796a6754b8d8d9cb4c617fec9774889220; clientid=129; x-mapping-fjhppofk=dce62fe972e1ef2f12d0060ec74c3681; phpsessid=ukeo21oldb5pqsntu7kl8j3b96"); writer.flush(); i downloaded http sniffer thinking read browser sending. how got write() line, cookie sent explorer. viewed source code login screen , found block of code near botto

php - Get font name from Google Fonts URL with regular expression -

please tell me how preg_match font names google fonts url. for example, want extract font name from: http://fonts.googleapis.com/css?family=oswald:400,300 http://fonts.googleapis.com/css?family=roboto+slab in order font names oswald , roboto slab . here's example of might preg_replace() , careful data mining google. <?php $urls = array("http://fonts.googleapis.com/css?family=oswald:400,300", "http://fonts.googleapis.com/css?family=roboto+slab"); $patterns = array( //replace path root '!^http://fonts.googleapis.com/css\?!', //capture family , avoid , following attributes in uri. '!(family=[^&:]+).*$!', //delete variable name '!family=!', //replace plus sign '!\+!'); $replacements = array( "", '$1', '', ' '); foreach($urls $url){ $font = preg_replace($patterns,$replacements,$url); echo $font; } ?>

c - Why can we use function pointers both as (*func_ptr)() and func_ptr() to invoke a function,but not so for array pointers? -

suppose have function pointer func_ptr of type void (*func_ptr)() .then know using can invoke function using pointer both : (*func_ptr)(); func_ptr(); but again, suppose have pointer integer array int (*arr_ptr)[5] , why can't refer array arr_ptr[] , , consequently elements arr_ptr[0] , arr_ptr[1] etc? why can use (*arr_ptr)[0] , (*arr_ptr)[1] ? the type of arr_ptr[0] int [5] ; type of (*arr_ptr)[0] int . if wanted to, use arr_ptr[0][0] . #include <stdio.h> int main(void) { int (*arr_ptr)[5]; int a[2][5] = {{1, 2, 3, 4, 5}, {11, 12, 13, 14, 15}}; arr_ptr = a; printf("%d %d\n", (*arr_ptr)[2], arr_ptr[1][2]); return 0; } you can see code "running" @ ideone . that function pointer can used either way ( nice ) sintactic sugar.

php - Simple HTML DOM Parser - Get all plaintex rather than text of certain element -

i tried solutions posted on question . although similar question, it's solutions aren't working me. i trying plain text outside of <b> , should inside <div id="maindiv> . <div id=maindiv> <b>i don't want text</b> want text </div> $part object contains <div id="maindiv"> . tried this: $part->find('!b')->innertext; the code above not working. when tried this $part->plaintext; it returned of plain text i don't want text want text i read official documentation, didn't find resolve this: query: $selector->query('//div[@id="maindiv"]/text()[2]') explanation: // - selects nodes regardless of position in tree div - selects elements node name 'div' [@id="maindiv"] - selects divs having attribute id="maindiv" / - sets focus div element text() - selec

java - How to get the default value from XML ( not working ) -

when starting service need check particular setting ( boolean ). please check following code: xml code: <checkboxpreference android:title="enable sleep" android:defaultvalue="false" android:key="checkbox_preference"/> java code: sharedpreferences prefs = preferencemanager.getdefaultsharedpreferences(this); boolean sleepenabled = prefs.getboolean("checkbox_preference", true); if(sleepenabled) { // code } even tho, default value in xml "false" got "true" on every service start. know because i'm setting parameter in "getboolean()" method "true", need there actual value of checkbox .. why getting "true" when starting service? p.s if go settings , change value of checkbox it's fine. when starting service again pulls actual value. how actual default value set in xml? change this: boolean sleepenabled = prefs.getboolean("checkbox_preference"

numpy - Zero padding multiple values in Python -

in so, solution adding single 0 between values in numpy.array : import numpy np arr = np.arange(1, 7) # array([1, 2, 3, 4, 5, 6]) np.insert(arr, slice(1, none, 2), 0) # array([1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) how add more zeros between each value in original array? example, 5 zeros: np.array([1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 6]) you can create 2dim array, , flatten it: import numpy np = np.arange(1,7) num_zeros = 5 z = np.zeros((a.size, num_zeros)) np.append(a[:,np.newaxis], z, axis=1) array([[ 1., 0., 0., 0., 0., 0.], [ 2., 0., 0., 0., 0., 0.], [ 3., 0., 0., 0., 0., 0.], [ 4., 0., 0., 0., 0., 0.], [ 5., 0., 0., 0., 0., 0.], [ 6., 0., 0., 0., 0., 0.]]) np.append(a[:,np.newaxis], z, axis=1).flatten() array([ 1., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0., 3., 0., 0.

java - Hibernate criteria group by date without time -

this code give me list of 2 items datetime , count. need group date without time. can give me clue how it? thanks! criteria criteria = getsession().createcriteria(parcel.class); projectionlist projectionlist = projections.projectionlist(); projectionlist.add(projections.groupproperty("datecreated")); projectionlist.add(projections.rowcount()); criteria.setprojection(projectionlist); list<object[]> results = criteria.list(); result: 2013-04-27 11:08:00.0 | 32 2013-04-27 11:10:00.0 | 5 2013-04-28 15:03:27.0 | 12 i need: 2013-04-27 | 37 2013-04-28 | 12 you may find projections#sqlgroupprojection method useful. allows employ sql function date() extracts date form datetime column. basically, instead of calling projectionlist.add(projections.groupproperty("datecreated")); use projectionlist.add(projections.sqlgroupprojection("date(datecreated) createddate", "createddate&quo

cassandra rack replication fixed to (dead) nodes [RF and CL confusion] -

Image
1 cluster, 3 nodes, in 2 physical locations, grouped in 2 racks rf 2 propertyfilesnitch cl quorum the problem is: first node's (in rac1) replication pointed third node rac2 , not change if node down, reads , writes fails. if start third node , shut down second node, reads , writes works. both second , third node replicate first node, , if first node down, reads , writes fails. the question is: is possible make automatically detect dead nodes , point replication active detected nodes? if first node down, second , third node replicate data between each other if second or third node down, first node should detect active , replicate it update1: made tests: shut down first node - reads second , third node fails ( unable complete request: 1 or more nodes unavailable. ) shut down second node - reads first , third node works shut down third node - reads first , second node fails very strange ... update2: i think found answer. how now: 3 nodes, rf

php - force download on restler function call -

i got following function in restler /** * updatefiles name * * 1 last update file * * @status 201 * @return file */ function getupdatefile($filename) { $file = 'plakat.jpg'; if (file_exists($file)) { header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename='.basename($file)); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate'); header('pragma: public'); header('content-length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } else { return "<h1>content error</h1><p>the file not exist!(".dirname(__file__).'/'.($file).")</p>"; } } the problem file there permissions co

objective c - Automator Stack Like Interface with Cocoa -

Image
i've been attempting create automator styled interface similar this: my approach has been nstableview view based cells, along way i've met many pitfalls cell row sizing , interaction troubles, way go (nstableview) or there better approach i'm missing? update: hear view based table views (rather cell based) on lion onwards , i'd have support snow leopard; cell based easy enough add interaction or there better option?

java - Using a value to fire Jcombobox actionlistener instead of getselectedindex? -

here jcombobox has 2 items name , id public void comboitem() { chooser.removeallitems(); chooser.additem("please select..."); try { string sql="select * patients_details"; pst = conn.preparestatement(sql); rs=pst.executequery(); while (rs.next()) { string id = rs.getstring("patient_id"); // id string name = rs.getstring("name"); // name comboitem comboitem = new comboitem(id, name); // create new comboitem chooser.additem(comboitem); // put combobox string tmp=comboitem.getid(); } } catch (sqlexception sqle) { system.out.println(sqle); } jcombobox actionlistener code private void chooserpopupmenuwillbecomeinvisible(javax.swing.event.popupmenuevent evt) { object selectedvalue = chooser.getselectedindex(); try{ string sql="select * pat

c++ - SDL: Undefined symbols for architecture x86_64 -

i'm working on simple wrapper sdl function sort of game engine. @ moment have simple temporary main function looks this: #include <iostream> int main(int argc, char * argv[]) { std::cout << "still in development!\n"; return 0; } along simple functions wrapper: #include "sdl.h" namespace snowshoe { void initialize() { sdl_init(sdl_init_everything); } void release() { sdl_quit(); } void update(sdl_surface * screen) { sdl_flip(screen); } } but when try compile 2 following error: undefined symbols architecture x86_64: "_sdl_flip", referenced from: snowshoe::update(sdl_surface*) in snowshoe-iru.o "_sdl_init", referenced from: snowshoe::initialize() in snowshoe-iru.o "_sdl_quit", referenced from: snowshoe::release() in snowshoe-iru.o ld: symbol(s) not found architecture x86_64 collect2: ld returned 1 exit status befo

App Engine Datastore - consistency and 1 write per sec limitation - who will it work in the following scenarious -

i'm trying wrap head around eventuality consistency , 1 write per sec principles in gae datastore. have scenario , 2 questions: #python pseudo-code class user: user_id = stringproperty last_update_time = datetimeproperty class comment: user_id = stringproperty comment = stringproperty ... def addcommentandreturnallcomments(user_id): user = db.gqlquery("select * user user_id = :1", user_id) user.last_update_time = datetime.now() user.put() comment = comment(parent=user(user_id)) comment.put() comments = db.gqlquery("select * comment user_id = :1", user_id) return comments questions: will exception here because make 2 writes same entitygroup within 1 second (user.put , comment.put)? there simple way around it? if remove parent=user(user_id), 2 entities no longer belong same entitygroup. mean list of comments returned function might not contain last added comment? am doing inherently wrong? i know

javascript - Can I Load CSS Using the "load.js" Library? -

i found out load.js , can't seem find indication of whether or not possible... (note: can't find 'load.js' tag..) i've got load.js loading js files, know works. has got working loading css files well? update: remyabel's solution worked loading physical files, seems there few quirks process... for reason, order in css files loaded , whether they're done in 1 load(file1,file2); or in stages load(file1).then(file2); seems affect how style rules applied markup. i'm going set few test cases on local machine try work out how or why happens, @ least files being loaded. final note: following on solution posted below, i've decided use head.appendchild(script); instead of head.insertbefore(script, head.firstchild); add css elements dom (still uses original method js files). this doesn't affect order in files fetched , processed, makes load.js insert css links in same order listed , @ end of header instead of beginning. direct

javascript - Auto-resizing the inside images if the div is starting to fill up? -

Image
i have idea, add "online users" thingy site. don't know how thingy. let me explain. if there online users, it'll show on div. but if there alot of online users, gonna crowd div, want images inside automatically resize, accomodate users. anyone? ps: can't post images yet. this should started: http://jsfiddle.net/3kuvt/ the logic involves calculating total available area in beginning , calculating new size (for each user element) whenever new user added. please note 2 minute fiddle , will need fine tuning side before can use on production. :) code: see demo above complete picture // can fit 8 of them without shrinking, pre-calculate available area var availablearea = 8 * 40 * 40; function adduser() { // after adding new one, how many there be? var newcount = $('#holder > .user').length + 1; // calculate new dimension of each user var neww = 40; // use same var w , h since square if(newcount > 8) {

apache - Using custom module with Python CGI script -

i'm running python cgi script on localhost needs import , use python module wrote. placed cgi script in apache cgi-bin directory (i'm running on windows). i've tried placing custom module in same directory, doesn't seem able import module. prefer not have custom module cgi script called via exec(). you need put python module somewhere python's import can see it. easy ways are: make directory module, , add directory pythonpath environment variable. copy module python site-packages directory, under python installation directory. in either case, need make sure module's name not same name of other module might imported python in cgi script.

git - can't delete file permanently from repository -

i'm trying delete huge, 100mb binary file repository. followed these instructions, detailed here: http://stevelorek.com/how-to-shrink-a-git-repository.html the instructions based on command: git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch filename' --prune-empty -f -- --all when ran script again, after allegedly removing file, indeed gone. then, when cloned repository again, after pushing changes, file again. how can apply changes after deleting big file? git push origin --force --all simply won't cut it. edit: file has been deleted 2 years ago, there's nothing commit/delete. tried creating dummy commit file addition, still no go. i ended converting local, clean repository bare repository, mentioned here , replacing old bare repository it. still no idea why couldn't apply changes central repository.

How do we use FileMode.Append on C#? -

i've been trying come way code open file or create 1 (if given file name non-existent). afterwards, run program end creating array , want contents of array converted string , appended file creating , opening. i've got right except 'append' part. in end "object reference not set instance of object." can please enlighten me on one? appreciated. try { filestream fs = new filestream("inventory.ini", filemode.openorcreate, fileaccess.read); streamreader reader = new streamreader(fs); while (!reader.endofstream) { string line = reader.readline(); string[] data = line.split('|'); int code = int.parse(data[0]); string name = data[1]; double price = double.parse(data[2]); item item = new item(code, name, price); app.array[inventorycount++] = item; }

Image resize codeigniter issue not working -

i've been attempting resize images no luck! have resize inside upload function not sure happening wrong! code below shows upload function (and resize within it): function do_upload() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['max_size'] = '2048'; $this->load->library('image_lib', $config); $this->load->library('upload', $config); $fullimagepath = ''; if (! $this->upload->do_upload()) { $this->upload->display_errors('<p style="color: maroon; font-size:large;">', '</p>'); $error = array('file_error' => $this->upload->display_errors()); // print_r($error); $this->load->view('layout/header

Java object not added to ArrayList -

i have problem. writing code ecosystem fish , trying add new fish object existing fish arraylist . however, when check arraylist turns out empty? thoughts? public void addfish(fish f){ arraylist<fish> fishplusone = new arraylist<fish>(fish.size()); if (landscape[f.getrow()][f.getcol()] != rock) { (fish otherfish: this.fish) { if(otherfish.getrow() == f.getrow() && otherfish.getcol() == f.getcol()) { throw new illegalfishpositionexception(illegalfishpositionexception.two_fish_in_one_place); } else { fishplusone.add(otherfish); } fishplusone.add(f); fish = fishplusone; } } you create new arraylist each time: arraylist<fish> fishplusone = new arraylist<fish>(fish.size()); isn't easier checks first , add existing list?

osx - how to increase the xset rate on mac os? -

i want increase speed of cursor in vim (installed via homebrew, not vi or macvim). i'm not talking motion keys speed navigation speed of programmer, rather cursor scroll while hitting j , k go , down. for linux, suggested here @ http://objectmix.com/editors/149702-cursor-vim-7-0-slow.html#post518421 xset r rate 250 75 how achieve on mac osx iterm2 vim ? i'm not sure if there way in iterm2 can change keyboard repeat rate system preferences. go system prefrences -> keyboard -> keyboard (tab) change key repeat rate fast , change delay until repeat short.

php - how to check (read) crul CURLOPT field of handle? -

this question has answer here: how option set curl_setopt()? 2 answers 1) there method check if curlopt field of curl handle set , if value? reason - i'm writing class should recognize if curlopt_post set. if not dedicated method add url query in syntax perform request. 2) second reason read debug curl parameter fields of handle curl_exec had problem execute , returned error 3) confirmation of changed curlopt field of handle, assuming possible change field set before (is it?) for 1), this answer should you for 2) you'd better use curl_error curl errors for 3), curl_setopt overwrite defined options. returns true on success , false otherwise.

python - Creating a matrix based on 3 inputs -

i need create 2 n matrix x y 1 x1 y1 2 x2 y2 3 x3 y3 4 x4 y4 5 x5 y5 . .. .. n xn yn it needs created function 3 inputs: x , y , , n , let call make_m(x,y,n) the matrix needs follow criteria: the sum of numbers in column x = x the sum of numbers in column y = y in given row, x#/y# = x/y there must n number of rows now have function find possible pairs of x , y , return them in list of tuples, have no clue how approach question of finding tuples to put rows satisfy 4 requirements. here function: def find_r(x,y): return [(a, a*num2/num1) in range(1, num1) if (a*num2) % num1 == 0] yes, there examples wont work because of ratio, example: in [60]: find_r(100,891) out[60]: [] and there wont work numbers of n . example following not possible values of n higher 4 in [57]: find_r(100,364) out[57]: [(25, 91), (50, 182), (75, 273)] but not worry now. the real issue many resulting possibilities have large amount of possibilities, not nee

objective c - Obj-c/cocoa: When I click a button, an infinite loop starts, data appears corrupted? -

Image
question posted here: http://www.daniweb.com/software-development/objective-c/threads/453854/nstableview-is-not-updating-correctly has full code. gui: i'm using nsmutablearray store strings populate nstableview on form. using button action delete specified row. rows specified value stored in int, updates when click on table. when click button on form activates method: -(ibaction)removefromlist:(id)sender { nslog(@"count: %d, at: %d\n",count,at); if(at<count) { [list removeobjectatindex:at]; } [_table reloaddata]; at=count+1; count--; [_label setstringvalue:[self converttonsstring:at]]; } table points table, removefromlist called remove, int @ specifies row removed, list nsmutablearray, count total number of rows. _label points label @ bottom of screen, tells me @ pointing to. following output: 2013-05-04 02:32:17.874 todolist[571:903] count: 7, at: 2 2013-05-04 02:32:34.763 todolist[571:903] *** -[nscfarray o

call back to C# function from within VBScript run with msscript.ocx -

i want use msscript.ocx call vbscript c#, , allow vbscript code call functions in c# program. for example, in following vbscript code, clicktext custom c# function in same clsss using msscript.ocx run vbscript. for i=0 i=4 clicktext("auto") next the clicktext function shoud called 5 times. is there way it? this comvisible console application reference interop.msscriptcontrol: // !! http://sandsprite.com/blogs/index.php?uid=11&pid=83 using system; using msscriptcontrol; //class test has support idispatch addobject(). make assembly comvisible //via assemblyinfo.cs or [assembly: system.runtime.interopservices.comvisible(true)] namespace mssctest { public class cshelper { public int increment(int y) { return ++y; } } class program { public static msscriptcontrol.scriptcontrol sc = new scriptcontrol(); static void main(string[] args) { sc.language = "vbscript"; sc.addobject(

Ruby function to calculate average search time for a skip list -

i'm trying write ruby function determine average expected search time skip list. don't have strong math background , believe results i'm getting function not correct. n = number of elements in list base = denominator of promotion probability. i.e. if 1 of 4 nodes promoted base = 4 def lookup_eficiency(n, base) return (math.log(n, base)*(base/2.0)) end how express equation in ruby take number of elements in skip-list , base , return average search time? since complexity of skip list o(logbase(n/base)), how ? def lookup_efficiency(n, base) math.log(n/base)/math.log(base) end make sure base float don't end integer division !

asp.net - Save state of file upload control in mvc -

i using asp.net mvc framework. , trying save state of controls after postback request. values of simple controls (textbox etc...) can request, how value of file-input control in controller side form. let form as @using(@html.beginform("method","controller",new{enctype="multiple/form-data"})) { @html.textbox("name") <input type="file" name="f1" id="f1" /> } and controller as [httppost] public actionresult method() { viewbag.name=request["name"] //here have value of file-control i.e. path contained in it, store in viewbag } how value (i.e. path of file) request. please help. you cannot full original path file in browsers, , cannot set value of input type=file in event.

python - Variable value changes automatically -

i solved assignment # 2 course "an introduction interactive programming in python" @ coursera.org. assignment work ok according specifications. however, when user guess number correctly , game restarts, 1 chance automatically reduces. not happening when number of chances exhausted. logic both conditions same. can please explain , fix it. here code: # template "guess number" mini-project # input come buttons , input field # output game printed in console import simplegui import random # initialize global variables used in code secret_number=0 guess_counter=0 init_var = 1 # define event handlers control panel def range100(): # button changes range range [0,100) , restarts global secret_number, guess_counter, init_var secret_number = random.randrange(0, 100, 1) guess_counter = 7 print "" print "new game: range 0 100" print "number of guesses ", guess_counter #print secret_number def range1000(

facebook graph api - RestFB - Picture URL is not properly formatted -

i'm trying publish post on facebook page using restfb. my code follows: facebooktype publishresponse = facebookclient.publish(pageid + "/feed", facebooktype.class, parameter.with("message", message), parameter.with("picture", picture), parameter.with("link", link), parameter.with("description", description)); and parameters have following values: message: test+test+test picture: https%3a%2f%2fcom-smallteaser-local-photo.s3.amazonaws.com%2fskydivemag%25232fdefcfa-c7b2-4c0d-8504-9942ccd9a4b0%2523648%25230%25232592%25232592%2523292%2523292 link: http%3a%2f%2flocalhost%3a9000%2farticle%2f20130503-test-test-test description: this+is+just+a+test i getting exception: facebookoauthexception: received facebook error response of type oauthexception: (#100) picture url not formatted] i read here can add picture providing url , says meant 'app developers h

backbone.js - Changing state of to do list tasks with Backbone in Rails app -

i'm new backbone , i'm making list app learn basics. right can add task , rendered in list. each task has properties name (string) , complete(boolean). i'd make when checkbox (.toggle) checked, 'complete' property changed true. have 'x' button (.destroy), when clicked should remove task database. i'm having trouble getting markcomplete , clear events work correctly. here's tasks_index.js.coffee view: class backbonetodo.views.tasksindex extends backbone.view template: jst['tasks/index'] events: 'submit #new_task': 'createtask' 'click .toggle': 'markcomplete' 'click .destroy': 'clear' #i'd change complete true , put line through list item markcomplete: -> @collection.set(complete:true) initialize: -> @collection.on('reset', @render, this) @collection.on('add', @appendtask, this) render: -> $(@el).html(@template()) @collection.each(@appendtask

c# - DSP FFT fundamental frequency wav file -

i have fft algorithm in c# , generate sine wave in buffer @ frequency of 440, fs=1600 , window length of 2048. before sending signal fft, double window length , put imaginary values( 0es) between buffer data. after fft, compute amplitude , take index of max amplitude , multiply bin size. , works returns 442 hz :) now put same generated sine recorded .wav file matlab. when run fft c# returns 884 hz double expected. why?. i checked .wav file audacity , got 440 corrected value. so ideea why got doubled value? i figured out it, seems didn't read wav file correctly.

html - Showing required fields by bolding -

i have html form. show of fields required making them bold. in principle, should go css rather html? how it? <form action="doit" id="doit" method="post"> <label> name <input id="name" name="name" type="text" /> </label> <label> phone number <input id="phone" name="phone" type="text" /> </label> <label> year <input id="year" name="year" type="text" /> </label> </form> just of top of head, think if you're willing use html5 , use <input type="text" name="year" required> property, should able do: input:required{ font-weight:bold; } and of course, go wild here , start throwing around borders , sorts of stuff make stand out.

c# - How to remove items from a List of Structs that exist in another List -

public struct registryapp { public string vendorname; public string name; public string version; } i have 2 list<registryapp> hold applications installed on windows box. why two? have 1 list hold x86 applications , 1 hold x64 applications. list<registryapp> x64apps64list = new list<registryapp>(); list<registryapp> x64apps32list = new list<registryapp>(); once 2 populated appropriate data retrieved registry, try following make sure there no duplicates. worked decently on list<string> not working list<registryapp> . list<registryapp> listofallappsinstalled = new list<registryapp>(); ienumerable<registryapp> x86apps = x64apps32list.except(x64apps64list); ienumerable<registryapp> x64apps = x64apps64list.except(x64apps32list); foreach (registryapp regitem in x86apps) { if ((regitem.name != null) && (regitem.name.length > 2) && (regitem.name != ""))

python - Faster alternatives to Popen for CAN bus access? -

i'm using popen send instructions utility ( canutils ... cansend function in particular) via command line. the entire function looks this. def _cansend(self, register, value, readwrite = 'write'): """send can frame""" queue=self.canbus.queue cobid = hex(0x600 + self.nodeid) #assign nodeid indexbytelow,indexbytehigh,indexbytehigher,indexbytehighest = _bytes(register['index'], register['objectdatatype']) subindex = hex(register['subindex']) valuebytelow,valuebytehigh,valuebytehigher,valuebytehighest = _bytes(value, register['objectdatatype']) io = hex(command_specifier[readwrite]) frame = ["cansend", self.formattedcanbus, "-i", cobid, io, indexbytelow, indexbytehigh, subindex, valuebytelow, valuebytehigh, valuebytehigher, valuebytehighest, "0x00"] popen(frame,stdout=pipe) a=queue.get() queue.task_done() return i running iss

php - list only directories that contain certain files -

the following code below works fine listing directories , excluding don't want in array list, i'd add feature able list directories contain files. for example: list directories contain files: array('file1.php','file2.php'); $exclude = array('admin','inc'); foreach(glob('./*', glob_onlydir) $dir) { $dir = str_replace('./', '', $dir); if (!in_array($dir, $exclude)) { //list directories } } $exclude = array('admin','inc'); $required = array('file1.php', 'file2.php'); foreach(glob('./*', glob_onlydir) $dir) { $dir = str_replace('./', '', $dir); if (!in_array($dir, $exclude)) { foreach($required $r) { if (file_exists("$dir/$r")) { echo $dir, "\n"; break; } } } }

html - Make textarea border shadowy -

i have both textarea , input in form. border of input shadowy, while border of textarea solid. if put in border: none; textarea , there's no border @ all. want them same. can it? for "shadowy" borders, might better off getting rid of borders altogether , using box-shadow instead. here's simple example: input, textarea { border: none; box-shadow: 0 0 15px rgba(0,0,0,.4); }

LINQ group by and max clause usage -

i have below employee class has 3 important fields public class employee { public string name { get; set; } public string department { get; set; } public double salary { get; set; } } i have list of such employees. want find out name employee each department salary maximum in his/her department. i wrote below query not working. list<employee> list = new list<employee>(); list.add(new employee { name="hemant",salary=10,department="pts"}); list.add(new employee { name = "gunjan", salary = 11, department = "pts" }); list.add(new employee { name = "akshay", salary = 8, department = "pts" }); list.add(new employee { name = "omkar", salary = 10, department = "ebg" }); list.add(new employee { name = "hemant1", salary = 14, department = "ebg" });

java - When UserType represents Set of Objects in single line. How to query Hibernate custom UserType with like criteria? -

we using custom hibernate usertype store set of strings in single line. when trying query set like criteria, using jpa criteriabuilder hibernate throws illegalargumentexception parameter value string did not match expected type java.util.set is there workaround this? here usertype using: public class setstringtype implements usertype, literaltype<set<string>> { final private static string separator = "|"; final private static string separator_regexp = "\\|"; @override public int[] sqltypes() { return new int[] { types.varchar }; } @override public object nullsafeget(resultset rs, string[] names, sessionimplementor session, object owner) throws hibernateexception, sqlexception { hashset<string> resultvalues = new hashset<string>(); string value = rs.getstring(names[0]); if (value == null) return resultvalues; string[] values = value.split(separator_regexp); resultvalues.addall(arrays