Posts

Showing posts from June, 2015

asp.net - mdf file and connection error -

i m running asp.net example code in vs 2005. using following datasource. have no sql express edition, have developer edition of sql server 2005. <asp:sqldatasource id="srcfiles" connectionstring="server=.\sqlexpress;integrated security=true; attachdbfilename=|datadirectory|filesdb.mdf;user instance=true" selectcommand="select id,filename files" insertcommand="insert files (filename,filebytes) values (@filename,@filebytes)" runat="server"> <insertparameters> <asp:controlparameter name="filename" controlid="upfile" propertyname="filename" /> <asp:controlparameter name="filebytes" controlid="upfile" propertyname="filebytes" /> </insertparameters> </asp:sqldatasource> i have .mdf file , got following error message. a network-related or instance-specific error occurred while establishin

emacs - I want to try org-mode. What's the shortest path from zero to typing? -

i want give emacs' org-mode try. shortest path me accomplish that? assume no previous experience emacs. (i'm aware other editors, vim , textmate, have similar task lists. i'm interested in learning emacs org-mode) my laptop runs win7 home premium x64 i use emacs (when i'm on windows) official binaries @ http://ftp.gnu.org/gnu/emacs/windows/emacs-22.3-barebin-i386.zip unzip directory , double click "runemacs". in commands follow, c stands ctrl . create file ending in .org. if using recent emacs, automatically start org-mode. can create file using c-x c-f . start creating outlines this: * level 1 ** level 2 collapse/uncollapse outline levels tab todo's can cycle hitting c-c c-t that's basics, , pretty know, use extensively :) have @ tutorials on http://orgmode.org/worg/org-tutorials/

validation - Good resources for coding forms with jQuery -

i've been trolling around couple days looking resources on form validation , submission jquery. of course, i've been able find specific blog posts on sites nettuts , themeforest, i'm looking best practice information. what best way(s) validate user form information? plugins? scratch? again, i'm looking best practices, or accepted, methods of validation , submission wider community. if have specific links or articles, pass on peruse. thanks! one of favorite jquery form validation plugins has happy.js . it's lightweight , extensible, , requires little effort working.

jquery - iframes - auto resize to heigh of content? -

i have built page has iframe in it. have page header , footer displayed on page, shown way of include file statements. iframe between header , footer , set display page not on website. the inserted page has hyperlinks on page user can click, , height of content displayed changes. is possible set iframe auto size frame window page size of inserted page displayed, if changes. have had set height of iframe large display biggest page of content user can display using frame (800). problem pages shown in frame small, part users dont see page footer. one last point, dont want use scroll bar achieve above. is possible this, , if how? if pages on same domain, it's relatively straight forward. if it's on different domain, can't done without co-operation other sites. the problem javascript prevented accessing frames/iframes other domains. solution have iframed page create own hidden iframe. iframed page loads hidden iframe specially crafted url pointing page on

android - streching spinner icon -

Image
when using own background theme spinner stretching icon. my spinner code : <spinner android:id="@+id/spinnercategory" style="@style/spinner" android:entries="@array/category_array" android:prompt="@string/category_prompt" android:background="@drawable/spinner" /> my spinner.xml is: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/btn_dropdown_normal" /> <item android:state_pressed="true" android:drawable="@drawable/btn_dropdown_pressed" /> <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/btn_dropdown_selected" /> <item android:state_enabled="true" android:dra

javascript - How to select child tag by closest tag in jQuery -

i have select element in jquery used clicked. try parent that's not worked try closest tag in jquery $(this).closest('.posts').children('.cbl h1').html('1') i try , it's work fine selection means select tag .cbl h1 successfully. tell me how can change text 1. structure <div class='posts'> <div class='cbl'> </div> <div><div>$(this) element here</div></div> </div> you can use .text() method. something like $(this).closest('.posts').children('.cbl h1').text('1');

asp.net - Assign TextBox Value to the session in MVC -

in mvc application used input type textbox , need assign value session how? im using code like <input type="text" id="textbox1" name="namebox" /> <input type="text" id="textbox2" name="agebox" /> <% httpcontext.current.session["name"] =textbox1; %> <% httpcontext.current.session["age"] = textbox2; %> but got error pls on this.... why prefer session instead of hidden input box? well, think should use name rather id of textbox. try , let me know if there problem. <input type="text" id="textbox1" name="namebox" /> <input type="text" id="textbox2" name="agebox" /> <% httpcontext.current.session["name"] = namebox; %> <% httpcontext.current.session["age"] = agebox; %>

MPMoviePlayerController tutorial needed -

can please recommend tutorial mpmovieplayercontroller. need play video of uibutton. although not tutorial, shows code play video using mpmovieplayercontroller: play video mpmovieplayercontroller in ios 3.0 , 3.2/4.0

c# 2.0 - How to convert Dictionary<string, object> to Dictionary<string, string> in c# -

i have below code in c# dictionary<string, object> dobject = new dictionary<string, object>(); i want convert dobject dictionary<string, string> . how can this? use todictionary method: dictionary<string, string> dstring = dobject.todictionary(k => k.key, k => k.value.tostring()); here reuse key original dictionary , convert values strings using tostring method. if dictionary can contain null values should add null check before performing tostring: dictionary<string, string> dstring = dobject.todictionary(k => k.key, k => k.value == null ? "" : k.value.tostring()); the reason works dictionary<string, object> ienumerable<keyvaluepair<string,object>> . above code example iterates through enumerable , builds new dictionary using todictionary method. edit: in .net 2.0 cannot use todictionary method, can achieve same using old-fashioned foreach: dictionary<string, string> sd = new

How to convert 31/03/2011 00:00:00 date format to 31 Mar 2011 in C# -

i have got below date format in result,i using c# 2.0 expirydate = "31/03/2011 00:00:00"; spnexpirydate.innerhtml = expirydate; now when going show in html should converted 31 mar 2011 format. please suggest! first, parse string datetime , , format using datetime 's tostring : datetime mydatetime = datetime.parse( "31/03/2011 00:00:00" ); spnexpirydate.innerhtml = mydatetime.tostring("dd mmm yyyy");

java - Is Drools applicable in my scenario? If not what else? -

scenario- 1. end user should able create rules front end. rule have conditions (i not figure out way in drools dynamically modify .drl file on basis of rules created users) rules should able defined in hierarchy , same rule can belong multiple hierarchies the end user should able trigger execution of rules. caveat here facts might not available in knowledgesession, rules converted relevant queries per underlying database , triggered on underlying db. so idea rules created limited knowledge of entities -> when rule triggered works underlying db create queries relevant entities present in underlying db would able drools, rules engine instead of building custom implementation? it looks you're going not easy. drools should way make easier. i'll assume "hierarchy" mean rule flows, , not rule-flow groups, think answer applies anyway other scenario. i think tool might want check drools guvnor, stores rules in db , provides ui change them. i think

javascript - Jquery Ui tabs url problem with page base -

i have problem jqueryui tabs. i have code : //the jquery tabs $( "#tabs" ).tabs(); //code open correct tab if write hash on url. works fine var hash = window.location.hash; var index = $("#tabs a").index($('#link-'+hash.replace('#',''))); if(index>=0) $("#tabs a").eq(index).click(); it works fine if don't put in page base href=... can open tab in new page right button of mouse , page opens correct tab selected. if put in page base href=http://$_server['http_host']/ when open tab in new window right button of mouse, page opened incorrect. base of page, lose of url. help please. sorry english i don't understand if put in page /" /> bit, but 2 last lines reduced 1 think: $('#link-'+hash.replace('#','')).click();

jquery - Show popup if the mouse is hovered over an element for a period of time -

i'm wondering how show popup/tipbox when mouse has been hovered on element period of time, e.g. pseudo code: if mouseover if hovered more 2 seconds --> show popup/tipbox else ---> cancel mouseover else if mouseout --> reset timer/cancel mouseover i've done far, doesn't work effectively, if hover , move mouse quickly, still show popup/tipbox. $('a[rel=tip]').live('mouseover mouseout', function(e) { if(e.type == 'mouseover') { var mousetime = settimeout(function() { $('.tipbox').slidedown('fast'); }, 1000); } else if(e.type == 'mouseout') { if(mousetime) { canceltimeout(mousetime); mousetime = null; $('.tipbox').slideup('fast'); } } }); edit: bounty added. this seems work me: http://jsfiddle.net/eydmc/3/ html <span id="som

c# - Use Jquery's jConfirm like JS's confirm method -

i have anchor on click of want call jquery's jconfirm method , having problem in using directly confirm method in javascript <a id="ctl00_cphmain_lnkdeleteimage" name="ctl00$cphmain$lnkdeleteimage" onclick="return confirm('are sure ?');">test</a> and in jquery doing this <a id="ctl00_cphmain_lnkdeleteimage" name="ctl00$cphmain$lnkdeleteimage" onclick="return jconfirm('are sure?', 'update test')">test</a> i want anchor click occur when user selects ok in confirm window currently have done in asp.net function confirmwindow() { jconfirm("are sure?", "update test", function(r) { if (r == true) { __dopostback("ctl00$cphmain$lnkdeleteimage", ""); } }); return false; } <a onclick="return confirmwindow()&quo

c++ - maximum and minimum value? -

i have made matrix using vector , iterator, how can find maximum , minimum value it. like: vector<int> > matrixes(10); typedef std::vector<std::vector<int> >::iterator it; rows = matrixes.begin(); if (rows->size() == 10) ++rows; rows->push_back(res); } for(size_t q=0; q < matrixes.size(); ++q) { for(size_t r=0; q < matrixes[q].size(); ++r) cout << matrixes[q][r] << " "; cout << endl; } i want find maximum , minimum value through it, how possible? just add 2 variables hold maximum , minimum value. update portion display it. vector<int> > matrixes(10); typedef std::vector<std::vector<int> >::iterator it; rows = matrixes.begin(); int maxval,minval; if ( matrixes.size() > 0 && matrixes[0].size() > 0 ) maxval = minval = matrixes[0][0]; for(size_t q=0; q < matrixes.size(); ++q) { for(size_t r=0; q < matrixes[q].size(); ++r) { cout

bash - Spell checking - Ignore set of words -

i doing bash script check spelling on number of files. i came across problem of telling aspell ignore set of words allow appear. this same "ignore all" in interactive mode. not work need hand. how can tell aspell ignore given set of words. there parameter can that. wish there option pass file words. or might out there more efficient way scripting spell checking in bash? easy: put words in personal dictionary: ~/.aspell.en.pws first line personal_ws-1.1 en 500 (500 number of words, doesn't need exact, aspell fix if add words aspell). if need dictionary elsewhere, use options these: aspell --home-dir=/dir/to/dict --personal=dict-file.txt

php - Appserv mcrypt with windows 7 -

i have uncomment in php.ini have put libmcrypt.dll in system32/ have check appserv/php5/ext/ contains php_mcrypt.dll have restart pc many time , im using pc but still cant load it any solution?? open php.ini file, c:\windows\php.ini , , change ;extension=php_mcrypt.dll extension=php_mcrypt.dll (just removing ; beginning of line). copy file c:\appserv\php5\libmcrypt.dll folder c:\appserv\apache2.2 . restart apache.

Android-Where does image taken get saved? -

something weird happening in application im not sure if worth uploading code... intent pictureintent = new intent(android.provider.mediastore.action_image_capture); pictureintent.putextra( mediastore.extra_output, imageuritosavecameraimageto ); startactivityforresult(intent.createchooser(pictureintent, stravatarprompt), take_avatar_camera_request); i use code take photo. photo gets saved in dcim folder , imageurisavecameraimageto points sdcard/folder...the image given name image1.jpg..once run works. then delete files dcim , sdcard/folder , run application again , take different photo...for reason old photo appears in folder...it must caching or storing copy of else where...does know , how can delete it?thanks i can't give exact answer, feeling mediastore contentprovider, may able call contentresolver.delete(uri).

Memory Leaks in iPhone -

greetings of day, in application, not able remove following memory leaks: [nscfstring appendstring] [nscfstring copywithzone]; [nsdecimalnumberplaceholder initwithdecimal] [sbjsonparser scanrestofarray] [sbjsonparser scanrestofdictionary] [nsplaceholdermutablestring initwithcapacity] could me remove these leaks thanks in advance manjot singh these not leaks caused system libraries. leaks tool points possible cause of leak. example, if write this: nsstring* str = [[nsstring alloc] initwithcstring: "some_str"]; in example str allocated never released. leaks tool show there leak in [nsplaceholderstring initwithcstring:] in fact there leak because didn't send release message str. so little tip: search problem in own code , not in frameworks you're using.

caching - Unable to cast object of type 'NHibernate.Caches.SysCache.SysCacheProvider' to type 'NHibernate.Cache.ICacheProvider' -

i'm using nhibernate 2.1.2 via castl activerecord. wanted set second level cache using syscache . got error: unable cast object of type 'nhibernate.caches.syscache.syscacheprovider' type 'nhibernate.cache.icacheprovider'. how can correct this? i'm guessing have assemblies locally in project , others in gac have version mismatch mauricio saying. make sure nhibernate.caches.syscache.dll in bin folder (for website), correct version , check don't have in gac.

mfc - CMFCPropertyGridCtrl add editable string property -

i derived class cmfcpropertygridctrl add simple interface needs. want add new string value can edit it: void cpropertygrid::addstring(const char* tag, const char* defaultvalue) { colevariant valuetype(defaultvalue); cmfcpropertygridproperty *stringproperty = new cmfcpropertygridproperty(tag, valuetype); stringproperty->allowedit(true); addproperty(stringproperty); } this adds new string in property grid, can't edit it. there way make editable? thanks! notify value must set true able edit values

iphone - Is a pointer used with a NSTimeInterval? -

do use pointer nstimeinterval though defined int? instance use: nstimeinterval *time or nstimeinterval time thank you! nstimeinterval double , double-click symbol while holding cmd see typedef . use directly, can use pointer example able change value in method call: - (void) dosomethinglongandreturnduration: (nstimeinterval*) duration { cfabsolutetime start = cfabsolutetimegetcurrent(); … cfabsolutetime end = cfabsolutetimegetcurrent(); *duration = end-start; } this weird example, idea.

java - Need to get ip informat -

i using printservice class details of attached printer have requirement ip of attached printer. i able names of attached printer not able ip. printservice[] printservices = printservicelookup.lookupprintservices(null, null); system.out.println("number of print services: " + printservices.length); (printservice printer : printservices) //system.out.println("printer: " + printer.getname()); system.out.println("printer: " + printer.getname()); } can let me know how can ip of printer? give inetaddress.getbyname try. can't know sure printer name in case true network/dns name if does, that'll need. string ip = inetaddress.getbyname(printer.getname()).tostring()

java - How to set the content type with Grails mail plugin? -

the grails mail plugin documentation shows how set content type gsp templates: <%@ page contenttype="text/html"%> but don't use gsp (and not!) , produce string freemarker. there way set content type without using gsp? if use html statement in sendmail method plugin set content type you. sendmail command can used without requiring gsp template. mailservice.sendmail { "recipient@recipient.com" "someone@place.com" subject "email without gsp" html "some markup" }

flex4 - Flex 4 - Sending string (such as JSON) using HTTPService -

when use httpservice.send(paramter) post request, web server not appear see variable "parameter" if string. server sees parameter if it's object, i'm looking use httpservice.send(json.encode(object)); possible? why not use actual request objects. in service define request objects , post them or send them if please. sample code here: http://pastebin.com/ft7qw2vg then call .send on service. on server can simlpy process if request.form (asp) failing why not append url binding expression. (you need encode since more or less faking url or behaviour).

jquery - fancybox link not working on IE8 -

i tried getting latest versions , editing links etc. i'm kind of lost guess. project has been going on months , has lots of plugins , scripts on though it's not ideal. i've used fancybox in many projects, never had issue before. so here's link doesn't work on ie8: http://www.africanbushcamps.com/abc/image-galleries/safari-pictures/ here click on gallery image , should open gallery in fancybox iframe. would appreciate help. thank you. it doesn't work because have javascript error before attach fancybox specified selectors. script hangs there, hence fancyboxes not firing.

linux - Cannot connect to tomcat externally -

Image
i install tomcat server on opensuse port 8080, can connect http://127.0.0.1:8080 in local machine. do have linux firewall iptables configured? if it's iptables can fix this statement iptables -i input -p tcp --dport 8080 -j accept (you change iptables config accept external tcp connections, please make shure know doing if editing firewall ports)

CUDA FORTRAN: function gives different answer if I pass variable instead of number -

i'm trying use ishft() function bitshift 32-bit integers in parallel, using cuda fortran. the problem different answers ishft(-4,-1) , ishft(var,-1) though var = -4 . test code i've written: module testshift integer :: test integer, device :: d_test contains attributes(global) subroutine testshft () integer :: var var = -4 d_test = ishft(var,-1) end subroutine testshft end module testshift program foo use testshift integer :: call testshft<<<1,1>>>() ! carry out ishft on gpu test = d_test ! copy device result host = ishft(-4,-1) ! carry out ishft on cpu print *, i, test ! print results end program foo i compile , execute: pgf90 testishft.f90 -mcuda ./a.out 2147483646 -2 both should 2147483646 if working correctly. right answer if replace var 4 . how fix problem? help when remove gpu-specific code above program 2147483646 2147483646 g95 compiler, e

java - How to format output in JSTL -

i've got span this <span>${bean.name}</span> and returns john brown how can format shows brown, john in jstl? so, point, want apply following modifications on string : split in 2 parts on whitespace (what if there more whitespaces?) show 2nd part of split in uppercased flavor. show comma , space. show 1st part of split. this doable jstl functions . <c:set var="parts" value="${fn:split(bean.name, ' ')}" /> ${fn:touppercase(parts[1])} , ${parts[0]} summarized: <c:set var="parts" value="${fn:split(bean.name, ' ')}" /> ${fn:touppercase(parts[1])}, ${parts[0]} you've problem when name contains more 1 space.

jsf - ui: repeat + p: datatable question -

i displaying multiple p:datatable 's through ui:repeat , following code snippet illustrates doing: <ui:repeat id="searchtables" value="#{searchbean.mapkeys}" var="mapkeys"> <p:datatable id="recordtable" value="#{searchbean.resultmap[mapkeys].resultlist}" var="recordtable" paginator="true" rows="10"> <f:facet name="header"> <h:outputtext value="#{searchbean.resultmap[mapkeys].name}"/> </f:facet> <p:columns value="#{searchbean.resultmap[mapkeys].resultcolumns}" var="column" columnindexvar="colindex"> <f:facet name="header"> <p:outputpanel>

html - ActiveX Calendar Control Not Working In Windows 7 -

we have classic asp application uses following calendar object: <html> <body bgcolor="lightgrey"> <object id=calendar1 style="left: 0px; top: 0px" classid="clsid:8e27c92b-1264-101c-8a2f-040224009c02" viewastext> <param name="_version" value="524288"> <param name="_extentx" value="7620"> <param name="_extenty" value="5080"> <param name="_stockprops" value="1"> <param name="backcolor" value="-2147483633"> <param name="year" value="2002"> <param name="month" value="10"> <param name="day" value="29"> <param name="daylength" value="1"> <param name="monthlength" value="2"> <param name="dayfontcolor" value="0">

arduino - Error while filehandling in Blender using Python -

i'm trying read data in blender external device connected arduino , save onto file. gives error syntaxerror: invalid syntax python script error controller "contr#contr#1": traceback (most recent call last): file "serialbge.py", line 6, in <module> f=open('abc.dat', 'r') ioerror: [errno 2] no such file or directory: 'abc.dat' my code correct, , don't understand problem. serial.py : import gamelogic import pickle import os os.system('dane.py') f=open('abc.dat', 'r') print "abc.dat = " x=pickle.load(f) print x print "end of abc.dat" f.close(); y=x[:] z in x: y.remove(z) print "removing " + str(z) print str(y) + " , " + str(x) f=open('abc.dat', 'w') pickle.dump(y, f) f.close() contr = gamelogic.getcurrentcontroller() location=contr.actuators["loc"] y = 0.001*(ord(z)-128) location.dloc

android - How to programmatically add certificates to a truststore and use that also for verifying server authentication -

i app want use https connection user-specified server uses self-signed certificate. gathered is, that self signed certificates rejected (as expected) the android keystore/truststore not used apps, apps have build , use own truststore, there's "keytool" in jdk build truststore can supplied app resource, not solution since not know server (and certificate beforehand) since https server user specified, not know server's certificate beforehand , want add server certificate programmatically app's truststore (by showing certificate user , have him accept it). once added truststore, app shall use truststore authenticate server. i not want accept every self-signed certificate without user checking fingerprint examples on web suggest. now problem i'm new java , android , struggling understand inner workings of androidhttpclient or defaulthttpclient. have basic http working in app, haven't found example on how add certificates truststore inside app o

Cleaning Up Oracle Sequences -

i've worked extensively sql server have little experience oracle. i've been given task of "cleaning up" sequences in oracle database , not sure how go safely. i need determine maximum value in table (say id = 105). , see next sequence id is. if 106, good. if 110, need reset 106. can safely drop sequence recreate or muck existing primary key? i'm guessing wouldn't problem before jacked else's system, wanted ask. this command going use drop sequence blah.foo_seq create sequence blah.foo_seq start 106 min 1 max 2147483647 yada yada i'd wary need "clean up" oracle sequence. since oracle sequences cannot used generate gap-free values, if 110 cause problem application, there bigger problems need addressed. dropping sequence has no impact on primary key. invalidate objects reference sequence , remove privilege grants. can recompile code after you've re-created sequence, it's dropping of privileges potentially proble

Data warehouse for user data - design Q -

Image
how best store user data vs date/time dimension? usecase trying store user actions per day, per hour. such number of shares, likes, friends etc. have time table , date table. time easy - have each row = user_id , colunms = 1 24 each hour of day. problem dates. if give each day = 1 colunm have 365 colunms year. cannot archive data way either because analytic needs past data too. other strategies? dimdate : 1 row per date dimtime : 1 row per minute at beginning have state " grain " of fact table , stick it . if grain 1 day, timekey points key of "23:59". if grain 1 hour, timekey points entries of "hh:59". if grain 1 minute, timekey points respective "hh:mm" if grain 15 minutes, timekey points respective "hh:14", "hh:29", "hh:44", "hh:59" and on... -- how many new friends did specific user gain -- in first 3 months of years 2008, 2009 , 2010 -- between hours 3 , 5 in morning --

c# - 'Class' is a 'type' but is used like a 'variable' -

i'm coding application uses fingerprint reader capture images of someone's fingerprints , save in database. i'm busy converting vb logic c#, i'm stuck here... within main form have 2 classes: fingerprints , fingerimage respectively. my issue following: from fingerprints class, needed reference fingerimage class. here's code clarity: this method derived fingerprint class, references fingerimage class: public byte[] getimagefromfinger(string finger) { foreach (fingerimage fi in fingerimage) { if (fi.finger == finger) return fi.image; } return null; } my problem error can't seem fix...fingerimage 'type' used 'variable'. i need loop through class 10 times, once each finger, i'm doing wrong , think it's small. appreciated. furthermore, here's code fingerimage class, in case... public class fingerimage : frmfingerpr

objective c - Bind value to nth object of array -

i have nsview , nsarraycontroller , i'd bind values inside view object in array controller's arrangedobjects array. how this? thought creating property "currentobject" , bind that. seems ugly me.. (i have 1 view objects user should able click on next , backward.) what trying accomplish? "detail view" bound array controller's selection , not object @ given index. if you'll wired same object, use nsobjectcontroller, set content object desired 1 , bind view it instead.

What docs/tutorials/guides are there that a Kohana newbie should know about? -

as former codeigniter user, migrate framework. options fuelphp or kohana, , fuel isn't there yet docs/tutorials/guides should know me speed? i aware docs not great, example can't seem find related how use session class, how configure use database driver, etc... http://forum.kohanaframework.org/discussion/4691/resources-for-learning-kohana there resources learning 3.0.x , lower. check out url 3.1: http://forum.kohanaframework.org/discussion/8024/kohana-v3.1.0-released 3.1 , 3.0.x similar , can use 3.0.x docs learn 3.1, make sure see whats difference. api isn't same.

testing - transaction processing scenario simulation in a web application -

i looking transaction processing , cannot find way simulate multiple queries (http methods) resource (script) act on shared data. e.g http representing access resource user1 param1 , http access user2 param2 for example 2 users trying book limited resource "at same time" or access url triggers actions should have acid properties. is there way test such scenarios in web application? should stick in "programmable" scenario (a scenario code) can run using stress test tool ? what method(s) use in such cases? you can use apache jmeter set test scripts run multiple simulated users, varying test content , on. can run slaves test more 1 physical test clients if need increase load. requests can created templates including user-specific data, pick random prepared requests or run scripts create data each request.

How to translate execution commands from bash script to C? or How to properly use popen() in "W" mode? -

hey all. i'm trying translate simple bash script executes program (called pdb2gmx) c commands can include function in larger program, i'm having trouble making happen. the bash script: #!/bin/sh /usr/local/gromacs/bin/pdb2gmx -f ${1}.pdb -o ${1}.gro -p ${1}.top << eof 14 6 so what's going when running program, stops , asks user input @ 2 separate points, 1 right after other. in bash script, putting down 14 , 6 seems fulfill input requirement, can't seem pull off same trick in c (also, i'm not sure eof doing there, i'm following else's example that, , script won't work without it). this have far in c: #include <stdio.h> #include <stdlib.h> int main() { file * pdb2gmx; pdb2gmx = popen( "pdb2gmx -f 1beo.pdb -o 1beo.gro -p 1beo.top" , "w" ); fprintf( pdb2gmx, "eof" ); fprintf( pdb2gmx, "14" ); fprintf( pdb2gmx, "6" ); pclose( pdb2gmx ); } but when cod

javascript - Userscript reload trigger -

i'm writing userscript chrome. userscript written site has special navigation. sends ajax request, data, , location.reload(true); no onreadystatechange/onload/onchange or other events occur. how can make trigger location reload? ps: no jquery.

c# - Getting HMACSHA1 correctly on iPhone using openssl -

argh, head hurts! context i need write c/objective-c code decrypt files stored on remote server. encryption open-source , written in c# i'm using libssl.a , libcrypto.a project; https://github.com/x2on/openssl-for-iphone my first hurdle getting hmacsha1 of string correct :( sha1 seems correct according reference site here - http://hash.online-convert.com/sha1-generator hmac not. ok, code; nsstring *input = @"wombats"; // define strings etc need unsigned char *instrg = malloc(256); instrg = (unsigned char *)[input utf8string]; unsigned long lngth = [input length]; unsigned char result [evp_max_md_size]; unsigned char hmacresult [evp_max_md_size]; unsigned char newpassphrase[25]; memset(newpassphrase, 0, 25); unsigned char salt[] = "\x01\x02\x03\x04\x05\x06\x07\x08"; // real code requires re-hash input 1000 times. lets // check 10 (hey first wrong). (int i=0; i<10; i++) { // use openssl sha_ctx shacontext; sha1_init(&shacontex

php - How to enforce API calls are coming from authorized site -

what need (what request parameter) need check make sure calling api indeed domain associated key, , key isn't being used on multiple domains? $_server 'remote_addr' or 'remote_host' $ip = $_server['remote_addr']; $host = $_server['remote_host'];

c# - How to create recurring calendar events? -

i using asp mvc 3, jquery full calendar, ms sql sever 2008 , c#. i wondering if knows how make recurring events? i unsure how make them. for instance in google calendar can make appointment repeat yearly forever. doubt generate appointment x times in database. i wondering how have 1 row in db , somehow know call when needed. also google calendar , outlook have lots of repeating options repeat on 1st month, last month , etc. is there libraries build have this? or got make scratch? p.s i on shared host solution has work limited rights. generating possible repetitions of event (in theory) fill storage events never ever seen user (congrats on 999,999,999,999,999,999,999th birthday!). it takes bit more work, solution store table (or tables) of repetition rules link calendar entries build calendar: "for every day of week being shown, check events repeat on days" "for every week of month being shown, check events repeat in weeks" &quo

java - Is it possible to use JDBC as an abstraction layer for RDBMS? -

jdbc provides api, may used connect different rdbms or similar datastores. datastores differ in implementation (e.g. sql dialects). is possible use jdbc in such way, queries , statements work on common rdbms (e.g.: oracle, postgresql, sql server, mysql)? that question interesting me @ 2 aspects: * common sql (insert, update, select etc.) * accessing meta data (getting information tables , columns) i experimenting self written persistence framework , want plug jdbc datastore under it. if write jdbc datastore adapter, nice, if work on common rdbms. thanks in advance no not possible because serve 2 different purposes. jdbc abstraction of dbms communication protocol , whereas sql query language. the queries written in sql sent server using communcation protocol , results of queries returned through protocol (in dbms independent way). there seems blurry line between communication protocol , queries jdbc api specifies calls retrieve meta data server (or result). d

wpf - Converter Uri to BitmapImage - downloading image from web -

i have problem converter uri bitmapimage. uri url of image on web. use converter on item in listbox. i download image webpage , create stream bitampimage problem if listbox consist 100 - 250 items, app freeze, try call webrequestmethod in thread don’t work. here root part of code: private static bitmapimage getimgfromazet(int sex, uri imguri) { try { if (imguri == null) { if (sex == (int)sex.man) { return new bitmapimage(new uri(@"pack://application:,,,/spirit;component/images/defaultavatars/man.jpg", urikind.relativeorabsolute)); } else { return new bitmapimage(new uri(@"pack://application:,,,/spirit;component/images/defaultavatars/woman.jpg", urikind.relativeorabsolute)); } } else { bitmapimage image = null; task.factory.startnew((

asp.net mvc - How can I update the VS 2010 MVC project template to include JQuery 1.5? -

right now, when create new mvc project in vs2010, automatically adds jquery 1.4.4 files. how go updating template includes 1.5 version in place of 1.4 version? possible? take here starters: http://www.thecodinghumanist.com/blog/archives/2007/5/22/how-to-edit-visual-studio-templates

objective c - iPhone Method Questions (dealloc an viewDidUnload) -

i have been working on app, , book read said put these statements viewdidunload , dealloc methods. other information should go here? have buttons , labels in program. need them? i want efficiently running application. here's code: - (void)viewdidunload { // release retained subviews of main view. // e.g. self.myoutlet = nil; self.doublepicker = nil; self.color = nil; self.choice = nil; [super viewdidunload]; } - (void)dealloc { [doublepicker release]; [color release]; [choice release]; [super dealloc]; } you should release iboutlets , other ui elements in viewdidunload. other data allocated in view controller (as iboutlets) should released in dealloc method. that's because view can loaded , unloaded multiple times during lifetime of view controller. example, view can unloaded if not visible, data behind (in view controller) still needs kept in memory. when both v

haskell - Print all possible world configurations -

just starting out haskell! exercise, current problem i'm trying implement follows: we have n squares, print possible world configurations : (1) each square have "p" (pit) or not (2^n possibilities). (2) there can @ 1 "w" (wumpus) in n squares (n+1 possibilities). representing 2 squares 2 strings, here output example n=2. have (2^n)·(n+1) = (2^2)·(2+1) = 12 configurations. [[" w"," "],[" "," w"],[" "," "], [" w","p"],[" ","pw"],[" ","p"], ["pw"," "],["p"," w"],["p"," "], ["pw","p"],["p","pw"],["p","p"]] condition (1) implemented. looking around, i've found few ways express : p 0 = [[]] p n = [x:xs | x <- [" ","p"], xs <- p (n-1)] or p n = mapm (\x -> [" ",&quo

ios - Getting random "facebookErrDomain error 10000" -

i using latest facebook ios sdk, , getting random "facebookerrdomain error 10000" , when using requestwithgraphpath . can trigger request ui , runs fine, gives me error. has ran similar issue? the error object returned has details what's happening. suggest implement method more infos: - (void)request:(fbrequest *)request didfailwitherror:(nserror *)error { nslog(@"%@", [error localizeddescription]); nslog(@"err details: %@", [error description]); }; for example problem gived me info, , i've fixed it: 2011-05-27 11:19:57.313 challengein[7704:207] operation couldn’t completed. (facebookerrdomain error 10000.) 2011-05-27 11:19:57.314 challengein[7704:207] err details: error domain=facebookerrdomain code=10000 "the operation couldn’t completed. (facebookerrdomain error 10000.)" userinfo=0x6878b90 {error=<cfbasichash 0x6879be0 [0x141c400]>{type = mutable dict, count = 2, entries => 2 : <cfstring 0x6

php - Why should I make database wrapper? -

i'm wondering why should need database wrapper php. wrapper mysqli or pdo. it's class calls pdo/mysqli class. why should need it? advantages? try make 1 - don't main goal. why need it?? =] abstractions pdo intend make things more secure. database execution want "strongly typed" means prevented: $mydangeroussql = "select * dba x ='"+$somevariable+"'"; the above result in called sql-injection . when using pdo explicitly "x of type string" or whatever type use in database. in way statement can "prepared" , cannot "inject" new sql-code it. makes more secure. this 1 of reasons though, biggest one. , don't write own wrapper/abstraction if it's not learning purpose, there lot of ones out there already. here post talking database abstraction in php .

ruby on rails - Can't run rake db:schema:load unless the database is already loaded -

tricky. rails models include lines like: scope :unread, where(arel_table[:read].eq(false)) this line can't run, however, unless arel_table[:read] defined, , it's undefined unless column exists. (this line rewritten not use arel, scopes cannot.) however, when try run rake db:schema:load , nomethoderror resulting fact arel_table[:read] undefined. in short, it's catch-22. can't load database schema without running environment, , can't load environment unless database loaded. is there better answer "comment out lines uncomment when done"? there's number of offending lines. that's problem using arel on scope. may affect migration. simple solution go raw sql. scope :unread, where('read = false') the longer answer class somehow loaded when running migration (it's not loaded). if can find causes loading of class during migration , work around it, can still use arel_table in scope. it's not worth it.

PHP how to autoinclude? -

i have following project structure: \ |- foldera | |- folderb | | |- index.php | |- index.php |- index.php |- config.php i want config.php loaded automatically (without 'include' directive inside index.php) whenever access: http:://mysitename/index.php http:://mysitename/foldera/index.php http:://mysitename/foldera/folderb/index.php or other php file in project. how can achieve that? the way make works use auto_prepend_file php.ini directive: auto_prepend_file = /path/to/config.php or in .htaccess : php_value auto_prepend_file config.php

how to put android on low power state -

i have highly data computation intensive application has process data received via bluetooth every 60 seconds , stay in low power state next 60 seconds. checked out powermanager api unable use it. there way accomplish task? you cannot "put android on low power state". android naturally go sleep mode after period of inactivity, if nothing holding wakelock force cpu stay running.

mapreduce - I think I may be trying something impossible - complex Couchdb "JOIN" scenario -

i think trying here may impossible, worth shot. i have 2 doc types, operator , event . in example below, emitting 3 keys. [place_id, operator_id, zone_name] operator_id , zone_name common fields in both documents. how want join between 2 document types. what want place_id first key first emit(), , event doc._id second emit(). that way, can specific startkey place_id want list of event._id s for. function(doc) { if(doc.doc_type == 'operator') { for(var in doc.zones) { for(var ii in doc.zones[i].origs) { if(doc.zones[i].origs[i]) emit([doc.zones[i].origs[i], doc._id, doc.zones[i].name], null); } } } else if (doc.doc_type == 'event') { for(var in doc.rates) { if(doc.rates[i].zone) { emit([0, doc.operator_id, doc.rates[i].zone], doc._id); } } } } the problem join wont work first value of 0 in second emit(); i have tried emiting keys [operator_id, zone_name] allows join work, reduce() function takes long , throw

order - Scala SortedSet - sorted by one Ordering and unique by something else? -

say have set of strings want ordered length unique normal string uniqueness. mean i have more 1 string of same length in set , should sorted length. i want express ordering this: val orderbylength = ordering[int].on[string](_ length) which think looks nice. if throw sortedset, this: scala> val s = sortedset("foo", "bar")(orderbylength) s: scala.collection.immutable.sortedset[java.lang.string] = treeset(bar) i 'bar'. because ordering represents total ordering , when compare returns 0 elements considered identical. therefore i'm thinking need make chained ordering , compare strings if lengths equal. used "pimp library"-pattern this: trait chainableorderings { class chainableordering[t](val outer: ordering[t]) { def ifequal(next: ordering[t]): ordering[t] = new ordering[t] { def compare(t1: t, t2: t) = { val first = outer.compare(t1, t2) if (first != 0) first else next.compare(t1, t2) }

php - How do I set a CSS class on a table row based on a property of an ATK node attribute in ATK-Framework? -

i have atk-framework i'm inheriting previous (departed) developer, , i'm finding documentation sparse , poorly structured. we have subscription system customer register account, , there can multiple subscriptions on account. classes accounts , subscriptions inherit atknode. i want able highlight row in table of subscriptions easier see, @ glance, when particular subscription has expired. expiry date of subscription property of node. i can find code node created in framework's modules - try hard can, can't find corresponding html template display information, , can't find anyway add in required logic highlight these rows. -- update: after more clicking around, i've found templates - they're in main atk framework directory (including custom templates predecessor has created). they appear smarty-like templates, modifying/extending them shouldn't hard. -- so, found following in template: {foreach from=$rows item=row} <tr id=&quo

android - Displaying pictures in a gridview -

hi i'm trying display images using gridview. i'm getting error when import android.widget.adapterview.onitemclicklistener says main cannot resolved or not field. code below: import import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.adapterview; import android.widget.gridview; import android.widget.toast; import android.widget.adapterview.onitemclicklistener; //error here: main cannot resolved or not field public class mainactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); gridview gridview = (gridview) findviewbyid(r.id.photogrid); gridview.setadapter(new imageadapter(this)); gridview.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view v, int position, lo

internationalization - What Languages does Django support? I can't find a comprehensive list -

ok i'm writing international django app, , docs doing localization great except can't seem find complete list of supported languages anywhere. they? want use list populate choices on model, if there way programmatically best. thanks! this may you're looking for: http://code.djangoproject.com/browser/django/tags/releases/1.2.4/django/conf/locale

asp.net mvc 3 - Razor view engine, how to write inbetween html? -

i have problem razor syntax. know how write inbetween html.. see sample.. <ul> @foreach (var x in model) { <li> @x.subject - tags:&nbsp; @if (x.tags != null) { foreach (var t in x.tags) { @t.name } } else { no tags } </li> } </ul> i should able write "no tags" doesnt work... no tags seem included in code (which not want. thanks you need explicitly tell razor you're writing html , writing @:no tags or <text>no tags</text> .

css - Jquery change width of div -

i want change width of elements rendered using following code. have tried adding style width:xxpx element in definition , try defining new css class invail. want both containers under main container of same size. following code rendering approximately 40-60. using style sheets jquery ui(jquery-ui-1.7.1.custom.css). this.container = $('<div class="ui-multiselect ui-helper-clearfix ui-widget" ></div>').insertafter(this.element); this.availablecontainer = $('<div class="ui-widget-content list-container available"></div>').appendto(this.container); this.selectedcontainer = $('<div class="ui-widget-content list-container selected"></div>').appendto(this.container); help? var newwidth = this.container.width() / 2; //i assume want child divs half size of parent? this.availablecontainer.width(newwidth); this.selectedcontainer.width(newwidth); this how asked, change width of divs j

sql server - Can't I select from actual table and the declared table at the same time? SQL ERROR -

i have tables declared , did work. my final state is.. declare @tmptblc table( rowindex int identity(1,1) not null, officer varchar(40), date varchar(20), total_served int, total_serving_time varchar(16), avg_serving_time varchar(16), log_in_time varchar(16), log_off_time varchar(16), served_by_hour int, total_tran_served int, total_tran_time varchar(16), avg_tran_time varchar(16), avg_tran_per_cus float); i declared @tmptblc table declare @dt datetime; set @dt=cast('01-01-1980' datetime); insert @tmptblc select loginname 'officer', convert(varchar(10), regdate, 105) 'date', count(distinct(queueno)) 'total_served', convert(varchar(6), sum(datediff(second,nexttime,endtime))/3600)+ ':' + right('0' + convert(varchar(2), (sum(datediff(second,nexttime,endtime)) % 3600) / 60), 2)+ ':' + right('0' + convert(varchar(2), sum(datediff(second,nexttime,endtime)) % 60), 2) 'total_serving_time', convert(varchar(6), a

android - MyGestureDetector extends SimpleOnGestureListener -

i implementing mygesturedetector extends simpleongesturelistener. borrowed class from: http://www.codeshogun.com/blog/tag/view-flipper/ allow swipe action in viewflipper. can not if function on emulator. suggestions? below of code: the main.java import android.app.activity; import android.os.bundle; import android.view.gesturedetector; import android.view.keyevent; import android.view.motionevent;import android.view.view; import android.view.gesturedetector.simpleongesturelistener; import android.view.animation.animation; import android.view.animation.animationutils; import android.webkit.webview; import android.widget.viewflipper; public class main extends activity { private static final int swipe_min_distance = 120; private static final int swipe_max_off_path = 250; private static final int swipe_threshold_velocity = 200; private gesturedetector gesturedetector; view.ontouchlistener gesturelistener; private animation slideleftin; private animation slideleftout; privat