Posts

Showing posts from March, 2010

c# - Regex to validate length of alphanumeric string -

i have following regular expression: ^[a-za-z0-9]+( [a-za-z0-9]+)*$ i'm trying validate string between 0-10 characters, string cannot contain more 2 spaces in row or cannot empty. string cannot contain special characters , can case insensitive , can include hyphens. how can limit input between 0-10 characters? i tried ^[a-za-z0-9]+( [a-za-z0-9]+{0,10})*$ but not work. i this: ^(?!.* )(?=.*[\w-])[\w -]{1,10}$ this uses negative look-ahead (?!.* ) assert there not 2 consecutive spaces, , positive look-ahead (?=.*[\w-]) assert has @ least 1 non-space character (i assume "empty" means "only spaces"). note if can't "empty", can't 0 length, length range must 1-10, not 0-10. of tiny note fact don't need escape dash in character class if it's first or last character.

forms - Staying logged in with Selenium in Python -

i trying log website , once logged in navigate different page on website remaining logged in, using selenium. however, when try navigate different page, found have become logged off. i believe because not understand how webdriver.firefox().get() function works exactly. my code: from selenium import webdriver code.other import xmlparser #initialise driver , go webpage driver = webdriver.firefox() url = 'http://www.website.com' driver.get(url) #login username = xmlparser.xmlparse('./config.xml','username') password = xmlparser.xmlparse('./config.xml','password') element = driver.find_elements_by_id('username') element[0].send_keys(username) element = driver.find_elements_by_id('password') element[0].send_keys(password) element = driver.find_elements_by_id('submit') element[0].click() #go new page url = 'http://www.website.com/page1' driver.get(url) unfortunately navigated new page no longer logged in.

handlebars.js - Handlebars block helper "if" doesn't work -

i'm making movie search based on data i'm getting rotten tomatoes api. i'm using handlebars.js. far i've got template , works fine. <div class="info"> <h3>{{title}}</h3> <span> year: {{year}} </span> <span> studio:{{studio}} </span> <span> synopsis:{{synopsis}} <span> </div> however, of of movies don't have studio provided i'd make in case no "studio:" printed. code so: {{#if studio}} <span> studio:{{studio}} </span> {{/if}} i've copied example provided on handebars.js page. still doesn't work. explain me i'm missing? suppose there no need use handlebars.registerhelper since i'm using simple if statement. or it? see jsfiddle . should not have issue that. from documentation . you can use if helper conditionally render block. if argument returns false, undefined, null, "

javascript - AngularJS example in $resource API -

http://docs.angularjs.org/api/ngresource .$resource in above link, there example: // define creditcard class var creditcard = $resource('/user/:userid/card/:cardid', {userid:123, cardid:'@id'}, { charge: {method:'post', params:{charge:true}} }); // can retrieve collection server var cards = creditcard.query(function() { // get: /user/123/card // server returns: [ {id:456, number:'1234', name:'smith'} ]; var card = cards[0]; // each item instance of creditcard expect(card instanceof creditcard).toequal(true); card.name = "j. smith"; // non methods mapped onto instances card.$save(); // post: /user/123/card/456 {id:456, number:'1234', name:'j. smith'} // server returns: {id:456, number:'1234', name: 'j. smith'}; // our custom method mapped well. card.$charge({amount:9.99}); // post: /user/123/card/456?amount=9.99&charge=true {id:456, number:'1234', name:&

android - AdapterView.OnItemClickListener with more ListView -

i have 2 listview on single fragment , wonder if can set both same class implements adapterview.onitemclicklistener. i mean, android documentation says: public abstract void onitemclick (adapterview<?> parent, view view, int position, long id) added in api level 1 callback method invoked when item in adapterview has been clicked. implementers can call getitematposition(position) if need access data associated selected item. parameters parent adapterview click happened. view view within adapterview clicked (this view provided adapter) position position of view in adapter. id row id of item clicked. so suppose can choose different listview invoked onclick parent (adapterview click happened).. now how can identify listview? there way swicth / case? or need create different class (can anonymous know) implements onitemclicklistener , set differents listview differents adapterview.onitemclicklistener? ok resolved: private class myclass implements adapt

why br not save in text file and html file in jquery -

Image
i facing 1 problem .i getting data server , show on screen .it having br tag . name ksdhfk (having br tag) hello ndfjsdf when have in text file or html file show name ksdhfk (without having br tag) hello ndfjsdf .where br tag goes..? but save file on html or text . this.  (note: in open court at.) the court: i'm going reserve counsel whether or not go evidence @ stage. court wants little additional research regard matter. @dfatty1: thank you.  the court: ready bring jury in? did enough {iing} else, counsel. @plfatty1: no, honor. the court: okay. can keep -- !d1w=!e1w=!f1w>!g1w>!h1w>!i1w?!j1w?!k1w?!l1w?!m1w@!n1w@!o1w@!p1wa!q1wa!r1wa!s1wb!t1wb!u1wb!v1wb!w1wc!x1wc!y2wc!{1wc!|1wd!}1we!~1we!1we!1we!1wf!1wf!2wf!1wg!1wg!1wg!1wg!1wh!1wh!1wh!1wh!1wi!1wj!1wj!1wj!1wj!1wk!1wk!1wk!1wl!1wl!1wl!1wm!1wm!1wm!1wm!1wm!1wm!1wn!1wo!1wo!1wo!1wo!1wp!1wp!1wp!1wp!1wq!1wq!1wq. the court: okay. i'll reserve ruling regard matter, we're ready proceed. @plfatty1: yes, hono

node.js - How to start contributing to the Mojito repository on Github ? (javascript) -

how study code, understand, debug ? know javascript not know start. , know how use github, of course know mojito ! problem donot know how contribute mojito. interested in it. me tips on start mojito contribution. note :: not asking how design apps mojito asking how develop mojito flatform you can fork repo , work on yourself, @ issues , work on fixes , commit main repo or clone , use yourself.

Checking consecutive values at a MySQL query -

i have mysql table this: id - time - value and i'm getting every pair of id, time (grouped id) value greater threshold. basicaly, i'm getting every id has @ least 1 time value greater threshold. query looks this: select id, time mydb.mytable value>%s , time>=%s , time<=%s group id edit: time checks allow operate in time range of choice between data table; has nothing else asking. it works perfectly, want add filtering: want avoid times value greater threshold (let's call alarms) if alarm hasn't happened time before or after. mean: if alarm accurs @ single, isolated instant of time instead of 2 consecutive instants of time, i'll consider false alarm , avoid returned @ query response. of course can call each id check this, i'd in single query make faster. guess use conditionals, don't have expertise @ mysql. any help? edit2: example threshold = 10 id - time - value 1 - 2004 - 9 1 - 2005 - 11 1 - 2006 - 8 2 - 2107 - 12 2

uiview - hidding uinavigationcontroller toolbar -

how come doing [self.navigationcontroller settoolbarhidden:no]; works (shows toolbar) but setting on view directly self.navigationcontroller.toolbar.hidden = no; doesn't? this academic question. apple has chosen implement ui features not strict properties, if properties , behave such. confusing you. in particular case [self.navigationcontroller settoolbarhidden:no]; is short for [self.navigationcontroller settoolbarhidden:no animated:no]; i.e. there user interface considerations in addition changing property of 1 item in view hierarchy, method has called.

c# - jQuery UI class dissapears on button even though .button() is set in codebehind? -

im starting pull hair on this. im trying append jquery ui's button appearance on regular button, doesn't appended. doesnt class.. <asp:updatepanel id="cartupdpanel" updatemode="conditional" childrenastriggers="true" runat="server"> <button runat="server" id="checkoutcartbutton" causesvalidation="false" enableviewstate="false">checkout</button> <triggers> <asp:postbacktrigger controlid="checkoutcartbutton" /> </triggers> </asp:updatepanel> i want button have secondary icon. know how make happen. i'm running problems.. this checkout button cart (i had disabling working fine before wanted make fancy), , in code behind checks if have enough credit checkout or not, enabling/disabling button. i cant create button in in ascx file because over-write disabling of button, making enabled: scriptmanager.registerclientsc

java - Is the EclipseLink EntityManagerFactory thread safe? -

is eclipselink entitymanagerfactory thread safe? is safe entitymanagerfactory.createentitymanager() in multi-threaded environment obtain entitymanager per method call? thanks the implementation of eclipselink entitymanagerfactory : org.eclipse.persistence.internal.jpa.entitymanagerfactoryimpl uses delegate ... org.eclipse.persistence.internal.jpa.entitymanagerfactorydelegate and none of entitymanagerfactorydelegate apis thread safe. so, entitymanagerfactory api not thread safe.

Jquery Photostack plugin problems with IE -

i using photostack, https://code.google.com/p/jquery-photostack/downloads/list jquery plugin gallery on website : http://twin-focus-photography.co.uk/recentviewer.php?&albumid=d5906ce4e2 the problem having reason ie doesnt , not showing up, works fine in chrome. so im not sure if code or going on ?. <script src="js/photostack/photostack.js"></script> <script> $(document).ready(function(){ $('div.images').photostack({ 'speed':400, 'float':'left', 'overlay':'false' }); }); </script> <script type="text/javascript"> $(document).ready(function() { $("body").css("display", "none"); $("body").fadein(2000); $(".recentviewerclose").click(function(even

c++ - Where is the difference between between memory header in VS2010 and VS2012 regarding smart pointers? -

there seems different in declaration of smart pointers (shared_ptr, unique_ptr , weakptr) between vs2010 , vs2012 header file versions. as far understand it, e.g. shared_ptr (through c++11) part of std namespace. also still part of tr1 namespace compability issues? if so, how achieved? thank you in header <memory> defined tr1 namespace this: namespace tr1 { // tr1 additions using _std allocate_shared; using _std bad_weak_ptr; using _std const_pointer_cast; using _std dynamic_pointer_cast; using _std enable_shared_from_this; using _std get_deleter; using _std make_shared; using _std shared_ptr; using _std static_pointer_cast; using _std swap; using _std weak_ptr; } // namespace tr1 _std defined in yvals.h as #if defined(__cplusplus) #define _std_begin namespace std { #define _std_end } #define _std ::std::

Are there any TCP/IP stack implementations on top of Bluetooth for Java, more specificaly for Android? -

what need pair bluetooth enabled device hosts webservices , browse dns-sd services. then have pick 1 of discovered services , make http requests on https or other secure method. i did trough wifi, reasons there's need same trough bluetooth. i did research yesterday haven't found need. i'm not sure how approach this. any input on welcomed. thanks! most implementations of bluetooth implement sockets on top of rfcomm or l2cap, these not standard sockets. i've never used it, believe bluetooth network encapsulation protocol (bnep) allows use of standard tcp/ip networking on bluetooth. android not implement , don't think supported elsewhere.

converter - Asn.1 development tools, CDR convert to XML using Java -

i try decode cdr file convert xml i've installed java compiler on pc. used link http://www.asnlab.org/asndt/overview.html i tried decode cdr file, not working properly. it show first 19 records correctly, , gives me error, tried 2 different cdr files. , both of them shows 19 records. 1st file gives me error: record 20 org.asnlab.asndt.runtime.error.asnruntimeexception: can not invoke method 'valueof()' 794995 @ org.asnlab.asndt.runtime.conv.reflectionenumeratedconverter.toobject(ed:40) @ org.asnlab.asndt.runtime.type.enumeratedtype.i(mc:126) @ org.asnlab.asndt.runtime.type.implicittype.i(xc:152) @ org.asnlab.asndt.runtime.type.settype.i(gb:191) @ org.asnlab.asndt.runtime.type.settype.i(gb:158) @ org.asnlab.asndt.runtime.type.implicittype.i(xc:152) @ org.asnlab.asndt.runtime.type.choicetype.i(hc:183) @ org.asnlab.asndt.runtime.type.sequencetype.i(xb:221) @ org.asnlab.asndt.runtime.type.sequencetype.i(xb:46) @ org.asnlab.asndt.runtime.ty

embed facebook video with comments -

Image
i can embed facebook video following code in facebook app: <iframe src="https://www.facebook.com/video/embed?video_id=xxx" width="720" height="1280" frameborder="0"></iframe> it shows video player. possible show comments , other options of video, screenshot? you can embed post users can directly click see comments there no other way embed comments made on particular video on facebook.

HighCharts: Basic line chart doesn't show first label on the X-axis -

Image
below code of graph , problem doesn't show first label on x-axis. have tried options showfirstlabel , startontick set true. still not showing. var my_chart = { chart: { renderto: 'divsigningraph', margintop: 5, fontfamily: 'arial,helvetica,sans-serif', zoomtype: 'xy' }, credits: { enabled: false }, title: { style: { display: 'none' } }, legend: { enabled: false }, exporting: { enabled: false }, plotoptions: { series: { animation: { duration: 3000 } } }, series: [ { type: 'line', name: 'your progress', color: '#27aae2', data: [7, 0, 1, 19, 50, 5, 0, 0

css - OpenERP font-family: 'Free 3 of 9' for barcode is not working in report webkit -

i have problem webkit report .mako file. when use: <html> <head> <style type="text/css">${css}</style> </head> <body> % o in objects: <p style="font-family:'free 3 of 9';">${o.name}</p> % endfor </body> </html> in .mako file working if use <html> <head> <style type="text/css">${css}</style> </head> <body> % o in objects: <p class="barcode39">${o.name}</p> % endfor </body> </html> and class declared in field "css" of data.xml in report_webkit .barcode39 { font-family: 'free 3 of 9'; font-size: 36; color: red; } font-family: 'free 3 of 9' not work. if use font-family working. problem? i have placed font in /usr/share/fonts/truetype , run fc-cache -fv . in

c# - Casting type right in XAML code? -

i'm wpf newbie, problem want cast property type right in xaml code this: //i want cast effect dropshadoweffect access it's shadowdepth <trigger property="ispressed" value="true"> <setter property="effect.shadowdepth" value="0.5"/> </trigger> but shadowdepth not accessible, effect should casted dropshadoweffect first. show me solution in can casting right in xaml code. if it's impossible, typeconverter in code behind ok. thank in advance. i see 2 possibilities: recreate dropshadoweffect in setter, recreating object's effect . give dropshadoweffect name, , reference object directly using targetname : <setter targetname="dropshadow" property="shadowdepth" value="0.5" />

c# - Sender of static EventHandler event -

i have class static eventhandler event: public static event eventhandler myevent; static void raiseevent() { eventhandler p = myevent; if (p != null) { p(null, eventargs.empty); } } since don't have this object can used event sender, raise event sender = null . ok have parameter set null, according .net programming guidelines? if not, object can use sender? event design on static events, sender parameter should null. source: http://msdn.microsoft.com/en-us/library/vstudio/ms229011%28v=vs.100%29.aspx

ddl - i am migrtaing database from sql server 2008 to teradata -

i migrating database sql server 2008 teradata , facing problem: in sql server in ddl of table column defined follows: [rowguid] uniqueidentifier rowguidcol not null constraint [df_address_rowguid] default (newid()) this column uses newid() function generate , insert random varchar value in column [rowguid] if user doesnt provide input. there no similar function in teradata generate value. what can used instead of of newid() function of sql server while creating similar table ddls teradata? there no native equivalent guid/uuid in teradata. teradata offer identity column provide auto-incrementing column. identity column not come without own nuances , encourage read chapter 5 - create table in sql data definition language - detailed topics has section explaining identity columns. however, part of migration sql server teradata need understand concept of how data distributed in teradata means of table's primary index. may require review existing data model , r

ImageJ: How to display a line length on the image? -

i use english version of imagej 1.47v. after downloading image, set scale (analyse -> set scale...), draw stright line, , measure length (analyse -> measure). after want display (label) measured length label near line. how this?

sql server - Is it possible to change default OLEDB connection timeout value? Run-time error (80040e31) -

Image
i have 1 legacy app (vb) , have issue timeout error while connecting sql server (probably through oledb). using sql profiler figure out connection dropped through 30 seconds. i don't have access source codes scanned exe resources , couldn't find hardcoded connection string timeout values there. the last chance think have change default oledb timeout somewhere outside app. my question is: possible change default oledb timeout value? update i found connection string , changed timeout 300 not help... provider=sqloledb.1;persist security info=false;user id=______;password=______;initial catalog=________;data source=______;connect timeout=300 after tried replace current connection string connection strings different providers: ado.net , odbc every time timeout error after 30 seconds - checkmate. p.s. i'll happy advice connect timeout limit of time connect server, not execute command, setting not @ all

c# - Why does Process.Start(ProcessStartInfo) fail? -

Image
we've developed new wpf application, , have had difficulty launching external c# script. while calling process.start(processstartinfo) method processstartinfo object initialized both workingdirectory , filename successes, init filename property fails launch. this not case when calling other application. question - different approach start process has different logic? see code more details: public void launchapp(){ /********************************/ /* code passes */ /********************************/ var pstartinfocalc1 = new processstartinfo { filename = @"c:\windows\system32\calc.exe", }; process.start(pstartinfocalc1); /*****************************/ /* !!!this code fails !!! */ /*****************************/ var pstartinfo1 = new processstartinfo { filename = @"c:\program files\myappfolder\myapp.exe", }; process.start(pstartinfo1); /********************************/ /* code passes

android - ArrayList of Drawable or ArrayList of Bitmap? -

i getting 1 scenario have store images in arraylist ( bitmap or drawable ). when bitmaps come mind think memory issues outofmemory . arraylist of drawable make difference? or arraylist of bitmap ? should use? this interesting question ... generalizing answer don't know why need use list of drawable / bitmap . to honest wouldn't use neither of them because: bitmaps: these objects occupy lot of memory , storing these in memory can harmful sure sooner or later if you're not careful. example: maybe send list through intent different component. if , initial list not destroyed you'll case have doubled amount of memory bitmaps deserialized new objects on target component side. drawables: bitmapdrawable keeps reference bitmap, don't see provide benefit on bitmap itself. may "forget" clear list of drawables , way you've memory leaked bitmaps. don't think creating drawable time consuming or resource consuming make worth caching.

How to convert a range subset of bits in a C++ bitset to a number? -

this question has answer here: in bitset, can use “to_ulong” specific range of bits? 1 answer i have std::bitset , bitset type provides to_ulong method translate bitset number, problem translating bitset number while considering range in bitset, need implement own powerof2 function or there more standard approach ? you can drop unnecessary bits like #include <bitset> #include <iostream> // drop bits outside range [r, l) == [r, l - 1] template<std::size_t r, std::size_t l, std::size_t n> std::bitset<n> project_range(std::bitset<n> b) { static_assert(r <= l && l <= n, "invalid bitrange"); b >>= r; // drop r rightmost bits b <<= (n - l + r); // drop l-1 leftmost bits b >>= (n - l); // shift place return b; } int main() { std::bitset<8> b2

angularjs - AngularUI unable to change state with ui-sref -

i have following simple navigation: <ul class="iconsline ic2 etabs"> <li> <a ui-sref="dashboard.tree.workstation.queue"><span class="icos-user"></span></a> </li> <li> <a ui-sref="dashboard.tree.workstation.settings"><span class="icos-cog2"></span></a> </li> </ul> <div ui-view="detaildialogcontent"></div> these links not change state. however, if execute $state.transitionto("dashboard.tree.workstation.settings"); show expect when click link. i don't see i'm missing here. crazy? state definition: state('dashboard.tree.workstation.settings', { onenter: function () { console.log('dashboard.tree.workstation.settings'); }, views: { 'detaildialogcontent': {

dataset - Add Multiple Data Sets/Sources to BIRT Report -

i'm working birt , having problems trying create report multiple data sources , data sets. for example, let's have wizard. wizard allows user graphically select data sources in list. after selecting few data sources , finishing wizard, report rendered selected data sources. i have tried few thing such adding data sources/sets elementfactory object, not seem work. does know of can find documentation on sort of thing? possibly pointers? thanks.

ruby - List of instance methods of current class only -

i have instance o of class o . i'd know o capable of. o.methods give me many methods. o.methods - object.instance_methods . not concise. i want o.methods - o.class.superclass.instance_methods . is, methods defined in o itself. is there other way? you can use method module#instance_methods : o.class.instance_methods(false) warning documentation seems wrong, says that: with no argument , or with argument false , instance methods in mod returned, otherwise methods in mod , mod’s superclasses returned. but parameter default true : string.instance_methods.size # => 184 string.instance_methods(false).size # => 130

php - Navigate throught databse rows -

i run image hosting site, , ive run problem. want make 2 buttons beside pic "next image" , "prev image". im new php/mysql , haveing troubles. check out got. use id (numbers) find correct row, have image name build next link. how make below query next , prev image names + ids? $query_next = ("select imageid, image_name images image_name = '$image_main' order imageid desc limit 1"); $query_prev = ("select imageid, image_name images image_name = '$image_main' order imageid asc limit 1"); // next $next = mysql_query($query_next); // prev $prev = mysql_query($query_prev); while ($row = mysql_fetch_assoc($next)) { $next = $row['image_name']; } while ($row = mysql_fetch_assoc($prev)) { $prev = $row['image_name']; } the html = > simple stuff. <a href="http://mysite.com/view_image/<?=$next?>">next image</a> <a href="http://mysite.com/view_image/<?=$pr

visual studio 2012 - How to create installer for ASP.NET MVC 4 web application -

i have created mobile web application in asp.net mvc 4 using visual studio 2012. i have created deployment options deploy web app our own servers need create installer web application can installed on customer servers. i looking option create such installer in vs2012 don't see one. the setup , deployment project type see in vs2012 installshield , geared windows applications, not web applications. so, how web application installers supposed made in vs2012? vs2012 not have straight forward way load vs2012 installer projects (*.vdproj) try downloading vs 2015 , need install package "microsoft visual studio 2015 installer projects" https://visualstudiogallery.msdn.microsoft.com/f1cc3f3e-c300-40a7-8797-c509fb8933b9 bingo

Handling both specific and general Python exceptions? -

i catch specific exception , handle accordingly - continue , perform generic handling other exceptions have to. coming c background, have utilised gotos achieve desired effect. this i'm doing , works fine: try: output_var = some_magical_function() except integrityerror zde: integrity_error_handling() shared_exception_handling_function(zde) # error reporting except someotherexception soe: shared_exception_handling_function(soe) # same function above tldr: ie - there "pythonic" way of doing following: try: output_var = some_magical_function() except integrityerror zde: integrity_error_handling() except allexceptions ae: # exceptions including intregityerror shared_exception_handling_function(ae) # error reporting nb: aware of clause - isn't intended tidy-up (ie- closing files)· you reraise exception, , handle generic case in outer handler of nested setup: try: try: output_var = some_magical_function()