Posts

Showing posts from September, 2014

migration - Drupal - Migrating to new server -

i have new drupal installation few hundred nodes. moved development server production server. however, when opened homepage, says page not found. after checking links, seems can't of content. exist in node database, content type tables. verified url aliases in place. in cases, can still see information views had created, when clicking see full node view, "page not found". i did trim cache tables before importing reduce size of db. has had these symptoms before? perhaps there particular table, when truncated, lead problem? **update: imported revision table again, , presto - although content came back, i'm still having sort of permissions problem. when anonymous visitor comes site, told don't have permission see items content type "page", yet in user permissions, looks (definitely before migration) perhaps deleted table? yes, node content information in revisions table, not node table. need revisions table. assume can remigrate again, ti...

ruby on rails - Loop Trick - How to show one attribute if...? -

i'm looking function can use in loop this: <% rink in @rinks_in_region %> <%= rink.city #show if city (n-1) != n %> <%= link_to_rink(rink.name+" ice rink",rink) %> <br> <% end -%> basically show city if it's different previous one. make sense? help! alextoul you use group_by method on @rinks_in_region group rinks city , use groupings display cities , rinks. returns hash mapping thing grouping by, city in case, values in original collection in group. so: <% @rinks_in_region.group_by(&:city).each_pair |city, rinks| %> <%= city %> <% rinks.each |rink| %> <%= link_to_rink(rink.name+" ice rink",rink) %> <br/> <% end -%> <% end -%>

c# - How to force all dlls to add to Current Domain? -

i have solution in c# has 1 main project kingrey (exe) , 1 project called dllreporter , called productreportclasses. when try list assemblies in exe dllreporter level: appdomain.currentdomain.getassemblies() i kingrey , dllreporter, not productreportclasses. but when di before getting assemblies in main code of kingrey: productreportclasses.classbasic b = new productreportclasses.classbasic(); and use appdomain.currentdomain.getassemblies() 3 assemblies supposed to. so question is: how assemblies or force assemblies listed in getassemblies? simple answer: if a) know assemblies want have loaded in appdomain , 2) know type each assembly can force them loaded doing following type temp = typeof(classinassemblya); temp = typeof(classinassemblyb); temp = typeof(classinassemblyc); somewhere near beginning of application's execution. seems bit hacky , is. works (as long qualify , 2 above , reference assemblies a, b , c) , simple do.

c# - How to convert enum to a bool for DataBinding in Winforms? -

is possible this? need use: this.controlname.databindings.add (...) so can't define logic other bind enum value bool . for example: (dataclass) data.type (enum) edit: i need bind data.type enum checkbox's checked property. if data.type secure , want securecheckbox checked, through data binding. winforms binding generates 2 important , useful events: format , parse . the format event fires when pulling data source control , parse event fires when pulling data control data source. if handle these events can alter/retype values going , forth during binding. for example here couple of example handlers these events: public static void stringvaluetoenum<t>(object sender, converteventargs cevent) { t type = default(t); if (cevent.desiredtype != type.gettype()) return; cevent.value = enum.parse(type.gettype(), cevent.value.tostring()); } public static void enumtostringvalue<t>(object sender, converteventargs ceve...

java - invoking as instance method -

what functionality going follwing class c = class.forname(handler); class partypes[] = new class[1]; partypes[0] = new string().getclass(); constructor ct = c.getconstructor(partypes); object arglist1[] = new object[1]; arglist1[0] = address; method meth[] = c.getmethods(); object arglist[] = new object[7]; arglist[0] = new integer(transid); arglist[1] = transobj; arglist[2] = data_vec; arglist[3] = company_name; arglist[4] = new boolean(flag_final_level_approval); flag_final_level_approval=true else false arglist[5] = con; arglist[6] = scon; boolean found = false; for(int i=0;i<meth.length;i++) { method m = meth[i]; if(m.getname().equals(functionname)) { result_vec = (vector)m.invoke(ct.newinstance(arglist1),arglist); } } someone using heinous reflection call methods on handler class. i'd curious know why arguments being put laboriously array of arguments couldn't have been...

what is Responder chain in iPhone SDK ?? How it works? -

what responder chain in iphone sdk ?? how works ? see documentation : if first responder [to event or action message] cannot handle event or action message, forwards “next responder” in linked series called responder chain . responder chain allows responder objects transfer responsibility handling event or action message other objects in application. if object in responder chain cannot handle event or action, resends message next responder in chain. message travels chain, toward higher-level objects, until handled. if isn't handled, application discards it.

actionscript 3 - AS3 XML, nodeName with attributes comes up blank -

i've tried many different ways of accessing name of attribute, can't working. the current function: protected function applyproperties(_axml:xml):void { var list:xmllist = _axml.properties; var list2:xmllist = list.attributes(); (var = 0; < list2.length(); i++) { trace(list2[i].nodename.tostring()); } } the xml it's referring to: <content type="media"> <target>warning.png</target> <properties x="20" mouseenabled="$false"></properties> </content> i have tried name, i've tried searching object, looked solutions on stackoverflow.. nothing has worked me far. had properties node such: fearing flash interpretting incorrectly. edit: seems xml interpretted rather printed out.. list2[i] xml object. xml objects not have nodename, thats xmlnode object. try list2[i].name().tostring();

asp.net - Is password input sanitization required? -

i'm trying sanitize data that's inputted making sure data valid particular field (e.g. name can't contain special characters/numbers etc..) however, i'm not sure when comes password field. need bother sanitization password hashed? if user inject malicious via password textbox, should bother checking suspicious? afaik, users may (should!) have special characters such '< >', trigger potential attack alert. should leave password field unsanitized? limiting input passwords last resort me, feel users should use sorts of characters in passwords. thanks as long hashing in application, should ok. a bit off topic considering using asp.net, notable exception if using php , mysql , doing this: update users set password = password('$pwd') userid = $uid in case want sanitize $pwd first.

ios - iPhone : Best way to detect the end of UIImageView image sequence animation -

we know uiimageview has nice support image sequence animation. can create array of uiimage objects, set animationimages property, configure animation duration, repeat count etc. , fire. there seems no way know when animation has ended. say have ten images , want run animation (repeat count = 1) them. , when animation over, want run other code. best way know animation has ended? i understand can create nstimer , schedule fire after animation duration. cannot rely on timer if need precision. so question is, there better way know uiimageview image sequence animation has ended without using timer? the code myimageview.animationimages = images; // images nsarray of uiimages myimageview.animationduration = 2.0; myimageview.animationrepeatcount = 1; [myimageview startanimating] the isanimating property on uiimageview should go no when it's done animating. it's not formal property, though, can't set observation on it. can poll on fine-grained t...

.net - Add dynamic dotnet webcontrol into attribute value of static html -

easy 1 explain. there way can this: <div id="header" style='<asp:literal runat="server" id="litbackgroundimage"></asp:literal>' > it looks valid, visual studio not recognise litbackgroundimage valid control in code-behind. setting div runat="server" won't work either because style property read-only. any suggestions gratefully received add runat="server" div , can access server-side, can set style attribute dynamically.

flash - null an object kill reference or the space in memory -

this might dumb question. think know answer, clarify. if declare object in varible1 , pass value varible2. if decide null varible2 kill reference or object well. want no, again, reference self, affects space in memory. these 2 varibles in class. private var objects:array; private var viewableobjects:array; above class varibles. later on in code add object objects array objects[0][4] = new enemy1(); when trace following [object enemy1] i add viewable objects array viewableobjects.push(objects[0]); next remove it. later on down lines. looping through code see "i" in first element. viewableobjects[i][4] = null; and when trace same first varible "objects[0][4]"... shows null setting reference null not affect object, unless it's last reference object (in case makes eligible garbage collection) you might want read more on how references work.

caching - Rails Cache Sweeper -

i'm trying implement cache sweeper filter specific controller action. class productscontroller < actioncontroller caches_action :index cache_sweeper :product_sweeper def index @products = product.all end def update_some_state #... stuff doesn't trigger product save, invalidates cache end end sweeper class: class productsweeper < actioncontroller::caching::sweeper observe product #expire fragment after model update def after_save expire_fragment('all_available_products') end #expire different cache after controller method modifying state called. def after_update_some_state expire_action(:controller => 'products', :action => 'index') end end the activerecord callback 'after_save' work fine, callback on controller action 'after_update_some_state' never seems called. looks missing controller name when trying call...

MDX: Calculating avg action time and change over time, for top 5 actions -

i have "actions" cube. dimensions "time" , "action id" , measurements "number of actions" , "total time" , calculated measurement "average action time". trying calculate top 5 actions avg time, , show change previous day. can in 2 separate queries: select {[measures].[avg action time]} on columns, non empty topcount( except([action id].members, {[action id].[all action ids]}), 5, [measures].[avg action time]) on rows actions [time].[2005].[1]; and: with member [measures].[change] ([time].currentmember, [measures].[number of actions]) / (parallelperiod ([day], 1, [time].currentmember), [measures].[number of actions]), format_string = 'percent' select [measures].[change] on columns, non empty [time].[2005].[1].children on rows [actions]; but can't figure out how combine them 1 mdx query. tried: with member [measures].[change] ([time].currentmember, [action id].currentmember, [measures].[avg action time]...

php - Remove store code from URL in Magento -

i have 2 sites on 1 magento install point different domains. site1 => www.site1.com site2 => www.site2.com each site shows store code in url of category, product, , cms pages (www.site1.com/store1/category). there way remove /store1/ url www.site1.com/category? guess can done .htaccess somehow. since have 2 different websites don't think need anyway, think there setting in system < config < web add store code urls , should try setting no , reindex.

Plot path from one location to other location on iphone MapView -

i want draw path 1 location other location. how plot path between 2 location. i have coordinates(latitude,longitude) both location. how can achieve functionality? thanks, jim. you can use google maps api obtain path elements of route , draw them on map. there's mapkit extension kishikawa katsumi available download on github provides functionality.

android - Find out which browsers are installed? -

i'm looking way find out browsers installed on android smartphone , package names. why need it? well basically, app reacts on urls, i.e. http://bit.ly , when click such choice in app open it. far working intended. if user sets app default kind of links, open in 1 without further asking user. far too. doing this, unable open links in browser. so need way send intent directly browser, have know app user has set default http/https scheme example (as user can change if there more 1 browser installed). sending intend intent.setcomponent(new componentname("com.android.browser", "com.android.browser.browseractivity")); should't problem think. problem is, can't send standard intent für urls, because app catch again if set default user. should't problem think hardwiring in package , class names of code not yours always problem. so need way send intent directly browser, have know app user has set default http/https sche...

delimiter - Determining delimeter for a structured section in a text file using a hex viewer -

i have text file structured data. after each text block says "end" , continues onto next block. looking @ hex viewer see 0a:45:4e:44:0a:20:20:20:20:20:20:20:20:20 which translates ?end? notice 9 spaces. how write delimeter in code? "end\n\n\n \n \n \n \n \n \n" this doesn't seem work. missing? most likely, "\nend\n " however forgot mention language you're using. did \n s from?

html - Remove outline from select box in FF -

Image
is possible remove dotted line surrounding selected item in select element? i have tried add outline property in css did not work, @ least not in ff. <style> select { outline:none; } </style> update before go ahead , remove outline, please read this. http://www.outlinenone.com/ i found solution, mother of hacks, serve starting point other more robust solutions. downside (too big in opinion) browser doesn't support text-shadow supports rgba (ie 9) won't render text unless use library such modernizr (not tested, theory). firefox uses text color determine color of dotted border. if do... select { color: rgba(0,0,0,0); } firefox render dotted border transparent. of course text transparent too! must somehow display text. text-shadow comes rescue: select { color: rgba(0,0,0,0); text-shadow: 0 0 0 #000; } we put text shadow no offset , no blur, replaces text. of course older browser don't understand of this, must provide fa...

Android - OnDateChangedListener - how do you set this? -

there event listener in android called datepicker.ondatechangedlistener . trying set datepicker view's on date changed listener follows: datepicker dp = new datepicker(getcontext()); dp.setondatechangedlistener(this); //where activity extends datepicker.ondatechangedlistener but guess what? date picker not have method called setondatechangedlistener . my question is: how set date changed listener in android? if not possible set date changed listener, purpose event? any documentation/tutorials helpful. once you've created datepicker , need initialise date want display @ first. that's point @ can add listener. see datepicker.init(int, int, int, ondatechangedlistener) .

mod rewrite - mod_rewrite error -

using rewrite rule giving me 500. wrong syntax? options +followsymlinks rewriteengine on rewritebase / rewriterule ^microsites/(.*)$ /microsites/index.php?uid=$1 [l] what want silently write http://site.com/microsites/anythingatall http://site.com/microsites/index.php?uid=anythingatall edit: following works , not throw error rewriterule ^([0-9])$ /microsites/index.php?uid=$1 [l] // end edit thanks advice! the mistake microsites/index.php matched ^microsites/(.*)$ . exclude destination , should work: rewritecond $1 !=index.php rewriterule ^microsites/(.*)$ /microsites/index.php?uid=$1 [l]

How to get a list of objects in Prolog -

i resolving prolog exercises when fond myself difficulties resolving following one: consider have fact base object: object(obj1). object(obj2). object(obj3). object(obj4). object(obj5). material(obj1,wood). material(obj2,wood). material(obj3, glass). material(obj4, glass). material(obj5, iron). type(obj1, able). type(obj2, chair). type(obj3, mesa). type(obj4, jar). type(obj5, rattle). weight(obj1, 10.5). weight(obj2, 1.5). weight(obj3, 1.6). weight(obj4, 0.5). weight(obj5, 1.8). now idea make predicate object_description(list) list joining of each object it's caracteristics, like: ([obj1-wood-table-10.5, obj2-wood-chair-1.5, …, obj5-iron-rattle-1.8] ) i tried using bagof , findall couldn't find right answer. thx in advance ?- findall(o-m-t-w,(object(o),material(o,m),type(o,t),weight(o,w)),res). res = [obj1-wood-able-10.5, obj2-wood-chair-1.5, obj3-glass-mesa-1.6, obj4-glass-jar-0.5, obj5-iron-rattle-1.8].

r - Post-hoc pairwise fisher exact test -

i used have 2 factor 2 level experiment got made 3 factor 2 level experiment. by using paste make 4 unique groups 2 factors , run fisher test outcome being whether organism lived or died. fisher.test(mortal$alv.dead,paste(mortal$strain,mortal$capsule)) but when wanted investigate pairwise comparisions between individual groups had make inelegant filtering 2 groups entered analysis @ time. have more groups tedious hand code each paring. here fisher test test groups in 1 analysis fisher.test(mortal$alv.dead,paste(mortal$strain,mortal$capsule,mortal$cassette)) how set method creates , tests possible pairings? fairly easy using function combn(). thing should take account, fact combn not return names of groups correctly when put fisher.test() call inside function. thus need adjust element in list accordingly : some toy data: mortal <- data.frame( alv.dead = sample(c("alv","dead"),30,replace=t), train = sample(letters[1:3],30,re...

objective c - Dynamically change the textview.keyboardType using segment control -

-(void)segmentaction { if(segmentedcontrol.selectedsegmentindex == 0) { textview.keyboardtype = uikeyboardtypenumberpad; } else { textview.keyboardtype = uikeyboardtypedefault; } } this objective c/iphone question. is function 'segmentaction' hooked segmentedcontrol in interface builder ? make sure gets called, instance, on 'valuechanged' segmented control, , should change keyboard. either segmentaction needs ibaction or needs called one. make sure segmentedcontrol hooked up, iboutlet. also, 'textview' coming from. textview delegate functions return variable called textview, if member variable called textview things going confusing you.

Best way to compare two large string lists, using C# and LINQ? -

i have large list (~ 110,000 strings), need compare similar sized list. list comes 1 system. list b comes sql table (i can read, no stored procs, etc) what best way find values in list a, no longer exists in list b? is 100,000 strings large number handled in array? thanks so have 2 lists so: list<string> lista; list<string> listb; then use enumerable.except : list<string> except = lista.except(listb).tolist(); note if want to, say, ignore case: list<string> except = lista.except(listb, stringcomparer.ordinalignorecase).tolist(); you can replace last parameter iequalitycomparer<string> of choosing.

Matching sub-classes of case classes in Scala -

why fail compile (or work?): case class a(x: int) class b extends a(5) (new b) match { case a(_) => println("found a") case _ => println("something else happened?") } the compiler error is: constructor cannot instantiated expected type; found : blevins.example.app.a required: blevins.example.app.b note compiles , runs expected: (new b) match { case a: => println("found a") case _ => println("something else happened?") } addendum just reference, compiles , runs fine: class a(val x: int) object { def unapply(a: a) = some(a.x) } class b extends a(5) (new b) match { case a(i) => println("found a") case _ => println("something else happened?") } this works, @ least in 2.8: scala> case class a(x: int) defined class scala> class b extends a(5) defined class b sc...

ruby on rails - Turn off layout for one of action -

my situation: view action of reportscontroller should render pure html, not file (to view in browser , save after). rendering use view template view.html.erb , neet turn off layouts action. in other actions of controller layouts should stay untouched. works turning off whole controller this: reportscontroller < applicationcontroller layout false but doing wrong :( actions tried use in action: def view @report = report.new(params[:report]) unless @report.valid? render :action => 'new' , return else render :layout => false end end what should do? try this: reportscontroller < applicationcontroller layout false layout 'application', :except => :view

django - Registration Form with only email + password -

i want registration form email + password. thinking insert automatically email in username field. so, eash user, have this: username: example@example.com password: mypassword email: example@example.com of course email + password used in login process. is solution having 2 fields same value ? or there more sofisticated solution ? thanks :) probably not idea circumvent the expected regex validation on username r'^\w+$' (so no @ or . , obviously). also, there's 30 character limit on username , lots of email addresses won't fit. you should write custom auth backend authenticates based on actual email field - many people this, can find samples on djangosnippets. two things keep in mind - default, email field non-unique. also, going break admin app, you'll need jiggery pokery if want use contrib.admin.

Post create instance code call in django models -

sorry crazy subj. i'd override django models save method , call additional code if model instance newly created. sure can use signals or check if model have empty pk field , if yes, create temporary variable , later call code: class emailmodel(models.model): email = models.emailfield() def save(self, *args, **kwargs) is_new = self.pk none super(emailmodel, self).save(*args, **kwargs) # create necessary objects if is_new: self.post_create() def post_create(self): # job, send mails pass but have beautiful code , avoid using temporary variable in save method. question is: possible find if instance of model newly created object after super save_base parent method call? i've checked django sources can't find how in right way. thanks we have related post for real - signals best approch in case. you use post_save() signal , in listener check if credit_set exist current model ...

sqlite - iPhone + sqlite3 + fmdb, What code do i need to put data into a UiTableView datasource? -

if adding data array uitableview datasource array i'd use this, in viewdidload. nsmutablearray *array = [[nsarray alloc] initwithobjects:@"head first design patterns", @"head first html & css", @"head first iphone", nil]; self.transactionsarray = array; [array release]; and in cellforrowatindexpath nsinteger row = [indexpath row]; cell.textlabel.text = [transactionsarray objectatindex:row]; but want link results select query, i'm using fmdb access database. heres how output data console fmdb @ moment. fmdatabase* db = [fmdatabase databasewithpath:@"/tmp/mydb.db"]; if (![db open]) { nslog(@"could not open db."); } fmresultset *rs = [db executequery:@"select * mytable", nil]; while ([rs next]) { nslog(@"%@, %@, %@, %@, %@", [rs stringforcolumn:@"pid"], [rs stringforcolumn:@"desc"], [rs stringforcolumn:@"due"], [rs str...

ant - maven antrun plugin -

i have following in pom: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-ant-plugin</artifactid> <version>2.3</version> <configuration> <target> <echo message="hello ant, maven!" /> <echo>maybe work?</echo> </target> </configuration> </plugin> yet, when run 'mvn antrun:run' this: [info] scanning projects... [info] searching repository plugin prefix: 'antrun'. [info] ------------------------------------------------------------------------ [info] building myproject [info] task-segment: [antrun:run] [info] ------------------------------------------------------------------------ [info] [antrun:run {execution: default-cli}] [info] executing tasks [info] executed tasks [info] ------------------------------------------------------------------------ [info] build successful [info]...

c# - How to get line number(s) in the StackTrace of an exception thrown in .NET to show up -

Image
msdn says stacktrace property of exception class: the stacktrace property holds stack trace, can use determine in code error occurred. stacktrace lists called methods preceded exception , line numbers in source calls made. so know information available. how line numbers show in stack trace? code throwing exception in difficult , complex piece of code goes through tons of objects, don't want step through bazillion times see exception happening. stack trace of exception shows method signatures , no line numbers. to line numbers in stacktrace, need have correct debug information (pdb files) alongside dlls/exes. generate the debug information, set option in project properties -> build -> advanced -> debug info : setting full should suffice (see advanced build settings dialog box docs other options do). debug info (ie. pdb files) generated debug build configurations default, can generated release build configurations. generating pdbs r...

c# - Working with hierarchical data in Mongo -

note: ended answering own question shortly after posting this. , sorry if spent time reading rediculously long post. introduction i'm sort of mongo noob, trying hang of things here. i looking @ trying create hierarchical data structure can add nodes/leaves dynamically. schema fixed, nodes on given tree should able change @ time. main thing i'm looking how add/remove nodes on nested nodes without rewriting whole tree. here'es example static analysis program, collection called "builds" . sparse document (_id's removed brevity's sake): { name: "build changeset #5678", assemblies: [ { name: "someassembly1.dll", warnings: [ { level: 0, message: "something doesn't conform our standard" } ] } ] } kick off, following; db.builds.insert({name: "build changeset #5678}) then, add assembly: db.builds.update({name: "build changeset #5...

Are there any iPhone/iPad tools for rapid development of catalogs? -

a number of apps build catalogs. consider website showcases housing http://www.zuccalahomes.com.au/search.php i number of requests build iphone/ipad apps have search system displays data in app. users search, click on results, see images etc of apps need load data fast, is, not via http requests. have build cms , turn sql lite database collated images, compiled app , placed on app store each release. plus there might cms based general pages. this seems must common development cycle. great if there tools helped automate process somewhat. if website consider these tools abstract cms umbraco or expression engine. partially use these tools cms side, there's massive translation system have write convert database sql lite. , no real on front end side of app development. anyone have suggestion (or two)?

vb.net - Open a file from a remote network share -

i trying open file server i have dim attachedfilepath string = "\\myserver\myshare\test.txt" file.open(attachedfilepath, filemode.open, fileaccess.read, fileshare.read) this not open file. however, if change path local there no issue. dim attachedfilepath string = "c:\...\test.txt" so, there way open file remote storage? file.open reading contents of file. use process.start launch default application file type dim path = "\\myserver\myshare\test.txt" system.diagnostics.process.start(path)

Vectors rotations 3D camera tiliting -

hopefully easy answer, cannot it. i have 3d render engine have written. i have camera position, lookat position , vector. i want able "tilt" camera left, right, , down. camera on fixed tripod can grab handle , tilt it up, down, left right etc. the maths stumps me. have been able forwards/backwards dolly , up/down/left/right panning, cannot work out vector math tilt. for left , right tilt want rotate lookat position around camera position, need take account vector, otherwise rotation doesn't know axis to turn around. the maths/algorithm need along lines of... camera=(cx,cy,cz) lookat=(lx,ly,lz) up=(ux,uy,uz) rotatepointaroundvector(lx,ly,lz,ux,uy,uz,amount) can assist maths involved? many thanks. you make point infront of camera, rotate around camera (using trig) , use lookat() rotate camera. this wont work once have start using roll (rotation around z). might wanna create quaternion based camera class. link helped me: gpwiki.org/quater...

python - In optparse module - command line option parser, how to confirm if an option was not provided? -

from python docs: "option.dest : if option’s action implies writing or modifying value somewhere, tells optparse write it: dest names attribute of options object optparse builds parses command line." can put check on name of attribute (dest) check if it's value provided? say, want perform action determine it's value when no value provided in cli, don't have fixed default value. checking against 'none' not work. you use default value of none such options, cannot entered on command line. can check like if opts.optional_value none: # action option not given else: # use value command line

Page Session Countdown Timer -

i wrote php code kills session after 5 minuets creation. i display timer in corner of page shows user how many minutes:seconds till session times out. there examples out there? something this? http://keith-wood.name/countdown.html there have simple example showing how use it: var newyear = new date(); newyear = new date(newyear.getfullyear() + 1, 1 - 1, 1); $('#defaultcountdown').countdown({until: newyear}); so need unix timestamp (time when session end). can modify this: var endofsession = new date(youtitmestamp * 1000); // timestamp in seconds , need miliseconds $('#defaultcountdown').countdown({until: endofsession}); hope helped!

what are all the different ways to include an external javascript file into a html? -

what different ways include external javascript file html? please give me examples. thanks in advance. three possible solutions standard way <script type="text/javascript" language="javascript" src="myfile.js"></script> via javascript (example) function loadcoolscript(){ var file=document.createelement('script') file.setattribute("type","text/javascript") file.setattribute("src", "http://siteb.com/cool-script-location/cool-script.js") document.getelementsbytagname("head")[0].appendchild(file) } non blocking loading via labjs <script> $lab .script("framework.js").wait() .script("plugin.framework.js") .script("myplugin.framework.js").wait() .script("init.js"); </script>

java - Pipe file disappears but still works -

i have 2 programs, both written in java. first launches several instances of second , communicates them via pipe files. when running 2 instances of program, (i'll call launcher , others b , c) works fine. pipe files in /tmp/[pid of a]/b , /tmp[pid of a]/c. if b or c close other should keep on working, except entire /tmp/[pid of a] folder disappears. the other program detects , try close because shouldn't work without pipe files. my questions why keep working if pipe files gone? , why disappear in first place? if c closes , b keep on running. code runs system.exit(0); , except processes messages received pipes doesn't anything. edit: as per request code creates directory , pipes. file dir = new file("/tmp/" + pid); dir.mkdirs(); file adir = new file(dir, "a"); adir.mkdirs(); file bdir = new file(dir, "b"); bdir.mkdirs(); runtime.getruntime().exec(new string[] {"mkfifo", pipe_name}, null, adir); runtime.getruntime()....

language agnostic - Drawing two-dimensional point-graphs -

i've got list of objects (probably not more 100), each object has distance other objects. distance merely added absolute difference between fields these objects share. there might few (one) or many (dozens) of fields, dimensionality of distance not important. i'd display these points in 2d graph such objects have small distance appear close together. i'm hoping convey how many sub-groups there in entire list. axes of graph meaningless (i'm not sure "graph" correct word use). what algorithm convert network of distances 2d point distribution? ideally, i'd small change distance network result in small change in graphic, incremental progress can viewed smooth change on time. i've made small example of sort of result i'm looking for: example graphic http://en.wiki.mcneel.com/content/upload/images/graphexample.png any ideas appreciated, david edit: it seems have worked. treat entire set of values 2d particle cloud, construct inverse squ...

Connect to web MySQL from c# desktop program? -

i've got webserver running quite standard apache/php/mysql , want connect mysql database desktop application written in c#/wpf. first, how can connect? need special sqlconnection library? second, how safe this? special need think security since database in web , not local? you connect mysql if allow connections (to mysql) ip addresses desktop (wpf) clients running from. create users , allow them connect directly database. it's not unsafe. mysql repository become harder maintain (you have lots of users, logging different subnets, etc.). i recommend create webservice or restful api in apache/php/mysql server, , connect service c#.

c - Assignment makes pointer from integer without cast -

coming java background i'm learning c, find vague compiler error messages increasingly frustrating. here's code: /* * purpose * case-insensetive string comparison. */ #include <stdio.h> #include <string.h> #include <ctype.h> int comparestring(char cstring1[], char cstring2[]); char strtolower(char cstring[]); int main() { // declarations char cstring1[50], cstring2[50]; int isequal; // input puts("enter string 1: "); gets(cstring1); puts("enter string 2: "); gets(cstring2); // call isequal = comparestring(cstring1, cstring2); if (isequal == 0) printf("equal!\n"); else printf("not equal!\n"); return 0; } // watch out // method *will* modify input arrays. int comparestring(char cstring1[], char cstring2[]) { // lowercase cstring1 = strtolower(cstring1); cstring2 = strtolower(cstring2); // regular strcmp return ...

iphone - How to make a UIWebView show its text with a custom font? -

it looks if font in uiwebview default kind of "times new roman". guess have figure out font apple uses [uifont systemfontofsize:15] ... or there intelligent way it? how inserting text in uiwebview? assuming setting html can change font either full css, inline css or deprecated font tags. <html> <head> <style> body { font-family: 'times new roman'; font-size: 15px; } </style> </head> <body> here text </body> </html> of course tweak style , size appropriately.

Creating Windows Account using C++ -

i give basic rundown of situation first. work game server rental company falling victim exploit inside of major game engine (source). basically, developers left not 1 2 exploits inside code, 1 send/recieve files, , 1 lets clients run plugins. whats happening clients running plugins, uploading custom plugins servers, servers running them, , result creating remote desktop accounts these exploiters using access machines. (theres video on youtube of breaking 1 of our boxes lol) i have spent day writing fix this, blocking sendfile() , recievefile() functions on server side, employer has asked while doing this, use exploit gain access box lost password to. have written of necessary code, except need able create temporary account these exploiters doing. code on creating windows account c++ appreciated. have been told there plenty of samples on google, apparently google skills not par. you need use netuseradd server name null (local computer). there's nice c++ example illus...

How do you write a get method that retrieves the title of an object, not its Id - w/ ASP.NET MVC -

so method in repository use records db via id public blogstable getblogposts(int id) { return db.blogstables.singleordefault(d => d.id == id); } and controller using method public actionresult details(int id) { blogstable blogpostdetails = repo.getblogposts(id); return view(blogpostdetails); } what need able write method allows me records db title, instead of id. have now also, how set route use method? have now routes.maproute( "default", "{controller}/{action}/{id}", new { controller = "blog", action = "index", id = "" } ); public blogstable getblogpostsbytitle(string title) { return db.blogstables.singleordefault(d => d.title == title); } public actionresult details(string id) { blogstable...

c# - How to use OrderBy in Linq using xpath -

i have 2 ienumerable<xpathnavigator> , want sort child value. item1 = xpathnavigator item in iterator1 select item; item2 = xpathnavigator item in iterator2 select item; item1 = item1.union(item2); item1.orderby(res => int.parse(getnavigatorvalue(res, "./item[@value='parentid']"))); static string getnavigatorvalue(xpathnavigator iterator, string xpath) { xpathnodeiterator inner = iterator.select(xpath); inner.movenext(); return inner.current.value; } it doesn't work. how use orderby in linq if need sort xpath? thanks, user460397 is problem? shouldn't be item1 = item1.orderby( ... ); ?

Simpler way to create a C++ memorystream from (char*, size_t), without copying the data? -

i couldn't find ready-made, came with: class membuf : public basic_streambuf<char> { public: membuf(char* p, size_t n) { setg(p, p, p + n); setp(p, p + n); } } usage: char *mybuffer; size_t length; // ... allocate "mybuffer", put data it, set "length" membuf mb(mybuffer, length); istream reader(&mb); // use "reader" i know of stringstream , doesn't seem able work binary data of given length. am inventing own wheel here? edit it must not copy input data, create iterate on data. it must portable - @ least should work both under gcc , msvc. i'm assuming input data binary (not text), , want extract chunks of binary data it. without making copy of input data. you can combine boost::iostreams::basic_array_source , boost::iostreams::stream_buffer (from boost.iostreams ) boost::archive::binary_iarchive (from boost.serialization ) able use convenient extraction >> operators read chunks of ...

c# - Deserialize xml into a Linq to SQL object -

i need read in xml data posted external systems, formatted follows: <applicant> <firstname>john</firstname> <lastname>smith</lastname> <address>12 main st</address> </applicant> this direct mapping of linq sql applicant class, excluding few properties. what's best way deserialize xml linq sql object, can insert directly database? i'd validate incoming xml , handle specific errors if possible. thanks in advance! if direct map, should able use directly, long types public , have public parameterless constructors, , properties (including lists) get/set. if need tweak names there xmlserializer constructor allows specify attributes. ideal scenario, must cache , re-use serializer if use constructor overload, otherwise leak memory (the dynamic assemblies not collected). here's full example removes 1 property ( xmlignore ), changes attribute, , leaves third element. using system; using system.io; usi...

SQL for price difference calculation -

i've got 2 tables i'm trying grab data from. first 'titles' table, represents product information (name, unique id, etc). second 'prices' table collects price information various currencies (each product can have multiple historic entries in prices table). i've written long-winded sql statement grab latest price changes across products, there issues more experienced users able me out with: select t.id, t.name, t.type, p.value, (select value prices prices.id = p.id , prices.country='us' , prices.timestamp < p.timestamp order prices.timestamp desc limit 1) last_value ...

Smooth animation on top of regular Android View -

i have app regular layout of buttons , widgets. on top of i'd draw animated sparks , particles , whatnot going on in response events, i've got in framelayout view on top draw animations. problem can't work out way of getting smooth movement out of it. i've tried few options: surfaceview : because of way takes on screen, can't see behind surfaceview background black. override view.ondraw , call invalidate() : works, invalidate isn't reliable way of getting redraw happen soon, motion jerky. animation framework : testing translateanimation , seems bit smoother using ondraw() , animations designed run specific duration , want draw indefinitely. anybody know tricks make 1 of these work properly, or different?

Efficient event listening in ActionScript 3 -

i have map of items , need know when mouse moves on item. should add event listener mouse on , mouse out each item (there may lot) or should add mouse on , mouse out listeners whole container , checking detect whether target has item on or not? in second way mean event occur on entering each map tile in container listening. seems bit pointless, heard somewhere should add little possible.. should do? well matter of preference. not performance issue in case. however, in event.enter_frame listener, should careful writing scripts executed per frame. i think should add mouse-listner item mentioned above. listener attached object/item, removed when item or object deleted garbage collector.

jquery - Is John Resig's OO JavaScript implementation production safe? -

for long time have been throwing around idea of making javascript more object oriented. have looked @ few different implementations of cannot decide if necessary or not. what trying answer following questions is john resig's simple inheritance structure safe use production? is there way able tell how has been tested? besides joose other choices have purpose? need 1 easy use, fast, , robust. needs compatible jquery. huh. looks more complicated needs be, me. actually looking more closely take exception doing providing this._super() whilst in method, call superclass method. the code introduces reliance on typeof==='function' (unreliable objects), function#tostring (argh, function decomposition unreliable), , deciding whether wrap based on whether you've used sequence of bytes _super in function body (even if you've used in string. , if try eg. this['_'+'super'] it'll fail). and if you're storing properties on fu...

java - jmx-term python subprocess poisons shell -

#!/usr/bin/env python subprocess import * p = popen( args=("java","-jar","jmxterm-1.0-alpha-4-uber.jar"), bufsize=0, stdin=pipe, stderr=pipe ) p.stdin.write("open localhost:12345\n") x = p.stderr.readline() this needs java process listening jmx client on port 12345. script "works": x correct (when print or @ in pdb). what's problem then? when script terminates, shell behaves strangely. on linux , os-x, typing in shell isn't visible (although output is), , on windows, first 2 characters typed per command ignored. executing terminal "reset" command seems fix it, don't want inflict on users of script. removing last line of script (accessing p.stderr.readline()) eliminates problem, script's utility. i've removed authentication simplify example. you'll note don't print x, eliminate writing nasty the shell culprit. versions: cpython 2.7 on snow leopard , various linuxes; cpy...

javascript - Does sifr 3 works in all desktop's A-Grade browsers? -

does sifr 3 works in a-grade browser if css, javascript enabled , flash player installed. a-grade browser http://easycaptures.com/fs/uploaded/448/6837085829.png and flash player version needed see sifr 3 text in browsers. in short, yes. see below links verification. from documentation: supported browsers how use (states use flash 8 in build settings, means 8 min version. flash penetration stats here )

facebook - rails accessing value from facebooker hash/array -

this first time using facebooker plugin rails, , i'm having trouble accessing user info. website uses fb connect authenticate users. i trying name of university logged in user attends. when use command <%= facebook_session.user.education_history[:name] %> , error "symbol array index". i have tried using education_history[1 ], returns "# facebooker::educationinfo:<some sort of alphanumeric hash value> " when use <%= facebook_session.user.relationship_status %> , returns relationship status fine. similarly, <%= facebook_session.user.hometown_location.city %> returns city name fine. i've checked out documentation facebooker, can't figure out correct way values need. any idea on how work? thanks! facebook_session.user.education_history returns array of facebooker::educationinfo objects. proper way access be: ed = facebook_session.user.education_history.last #will nil if not provided @ed_name =...

ruby on rails - RoR 3 - overriding the FormBuilder default f.submit into a button -

i have form, , layout (and future use), know how change default f.submit generates a: to html tag shouldn't give errors. what have extention on formbuilder in view: <%= form_for resource, :as => resource_name, :url => session_path(resource_name), :class => "form with-margin", :builder => appformbuilder |f| %> ... <%= f.submit %> <% end %> in lib/appformbuilder: class appformbuilder < actionview::helpers::formbuilder def submit(text, options = {}) options[:type] = "submit" @template.content_tag(:button, text, options) end end but gives me error: nameerror in devise/sessions#new showing d:/projects/websites/ruby on rails/fact-it/app/views/devise/sessions/new.html.erb line #11 raised: uninitialized constant actionview::compiledtemplates::appformbuilder 8: 9: <p class="message error no-margin alert"><%= alert %></p> 10: <p class=...

internet explorer - jQuery 1.4 change event bug in IE -

i have simple select: <select name="zlecenia_index_icpp" id="items_per_page"> <option value="10">10</option> <option value="25" selected="selected">25</option> <option value="50">50</option> </select> and on there's: $('#items_per_page').change(function(){ var controller_action = this.name.replace(/_/g, '/'); location.href = config.base_url + '/' + controller_action + '/'+this.value; }); it used work in jquery 1.3, in 1.4 change event fired click on select box. there solution besides going 1.3? this seems bug , has been reported jquery: http://dev.jquery.com/ticket/5869 there has been patch applied , part of jquery 1.4.1. http://github.com/jquery/jquery/commit/435772e29b4ac4ccfdefbc4045d43f714e153381 here's fix bug: http://github.com/mcurry/jquery/commit/a293f5938eb9efd41158b9...

Simple Javascript "undefined" question -

i'm iterating on bunch of child nodes , checking see if visible on page statement: if(child.offsetwidth == 0 || child.offsetheight == 0 || child.style.visibility == 'hidden' || child.style.display == 'none'){ child defined in loop that's not issue. what issue elements might not have style attribute defined , javascript returns "child.style" not defined. how do seemingly simple if statement without stopping because not defined? i tried doing this: if(undefined !== child.style){ var addquery = "child.style.visibility == 'hidden' || child.style.display == 'none'"; } if(child.offsetwidth == 0 || child.offsetheight == 0 || addquery){ console.debug(child); } but think addquery evaluating true , not working. if(child.offsetwidth == 0 || child.offsetheight == 0 || (child.style && (child.style.visibility == 'hidden' || child.style.display == 'none'))) since && short-...

powershell - How can I output Handbrake output to both the screen and to a file? -

so i've been using handbrake command line encode video collection store on nas can use on htpc. looking way output both screen can watch it's output it's encoding, file can go , @ particular encoding session. my solution use 1 powershell window run encoding , output file, powershell window read log file , display on screen. works, want improve it, it's not perfect. because read file script reads @ set interval, misses lines. if reduce interval, has effect on system performance, making encoding run bit slower. there way can redirect output of first window both file , screen? the first powershell script (the 1 starts encoding) called "convert1.ps1" (run handbrake install directory): net time \\odin |find "current time" ./handbrakecli.exe -i "<input file>" -o "<output file>" <handbrake parameters> the second powershell script output file, called "start_convert.ps1": d:\conversions\convert.ps1...

database - Googling DAL & DAO returns only C# .NET related results – Does a DAL/DAO type pattern exist in Java? -

the subject line says all. googling dal & dao returns c# .net related results. there dal/dao equivalent pattern in java world? there reference implementations available? of course applies java well: don't repeat dao! have @ fowler's patterns of enterprise application architecture . core j2ee patterns refers dao. it'd interesting check dates on c#/.net references. i'd bet idea started on java side , adopted later .net. microsoft had persistence technology "best practice". if recall correctly, vb used tie ui elements closely columns, without intermediate layer in-between separate view database.

svn - How do I revert a file in a working copy to an older revision and then commit it back to the repository? -

what process reverting files , folders earlier revision in svn using windows tortoisesvn client? i've have tried right-clicking file in working copy , selecting "update revision..." command , specifying revision number want, can't commit change repository thinks nothing has changed in working copy. if make minor change file in question errors when attempting commit repository saying it's out of date? so i'm unsure of process of reverting files, 1 of main benefits of having version control system seems pretty major don't know how it!? update revision merely makes working copy show revision have selected, not modify current revision. want use revert . to this, view log file ( right-click/tortoisesvn/show log ), right-click on revision want in log messages window, , select revert revision. then, review change(s), make sure liking, , commit. more details here : you can commit items up-to-date respect repository. if 'update ...

java - What is the difference between JSF, Servlet and JSP? -

how jsp , servlet related each other? jsp kind of servlet? how jsp , jsf related each other? jsf kind of prebuild ui based jsp asp.net-mvc? jsp (javaserver pages) jsp java view technology running on server machine allows write template text in client side languages (like html, css, javascript, ect.). jsp supports taglibs , backed pieces of java code let control page flow or output dynamically. well-known taglib jstl . jsp supports expression language , can used access backend data (via attributes available in page, request, session , application scopes), in combination taglibs. when jsp requested first time or when web app starts up, servlet container compile class extending httpservlet , use during web app's lifetime. can find generated source code in server's work directory. in example tomcat , it's /work directory. on jsp request, servlet container execute compiled jsp class , send generated output (usually html/css/js) through web server on network c...

c# - Model for Maintaining Collection Over Multiple Threads -

i have shared instance of list gets updated randomly various threads (objects added via threads). have timer executes on set interval removes records list based on set of criteria--specifically, if records older x minutes. finding system scales out , threads become more numerous, method cleans list randomly throw exceptions iterates it. presume due contention between list updates , removal of records. best way prevent exceptions put lock on shared instance iteration done? if so, negatives of doing so. if not, other options there? i'm sure pretty basic question i'm new threading issues. i don't think stated strong enough: have lock it. beware list not great collection object this, removing old items costs o(n^2). consider creating new list old 1 or using linkedlist.

c - How do I use pointers in combination with getc? -

i have function getnum(), gets number file , returns it. when go getnum() have lost pointer , starts @ begging of file again. i'm wondering how location of getc , go place. couldn't find how in manual or in forums. thank you. #include <stdio.h> #include <stdlib.h> int getnum(); int getline(); int getmatrix(); main() { int num; int two; num = getnum(); printf("%d\n", num); 2 = getnum(); printf("%d\n", two); } int getnum() { file *infile; infile = fopen("matrix.txt","r"); int c; double value = 0; while ((c=getc(infile)) != '\n') { if(c==32){ if(value != 0){ return(value); } //otherwise keep getting characters } else if ((c<=47)||(c>=58)){ printf("incorrect number input %d\n", c); exit(1); } else { value = (10*value) + c - '0'; } } return(value); } the reason reopen file each time execute getnu...

Haskell - Concat a list of strings -

im trying create list of strings using recursion. basically want take part of string point. create list , process rest of string through recursion. type docname = filepath type line = (int,string) type document = [line] splitlines :: string -> document splitlines [] = [] splitlines str | length str == 0 = [] | otherwise = zip [0..(length liststr)] liststr liststr = [getline] ++ splitlines getrest getline = (takewhile (/='\n') str) getrest = (dropwhile (=='\n') (dropwhile (/='\n') str)) thats got. concats strings since list of characters themselves. want create list of strings. ["test","123"] if input "test\n123\n" thanks if try compile code, you'll error message telling in line liststr = [getline] ++ splitlines getre...