Posts

Showing posts from July, 2013

Php regex date validation -

i'm trying validate date input use of regex. if(!preg_match("/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/", $_post['variant']['sales_start'])) { echo "invalid"; } the string i'm trying input 2011-02-03, it's failing, , can't seem figure out why. can please tell me i'm doing wrong? thanks in advance you're separating date dashes , regex looking slashes? try if ( !preg_match( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_post['variant']['sales_start'] ) ) { echo "invalid"; }

convert c# to vb.net webbrowser -

am trying convert c# vb.net has webbrowser control, confused. code in usercontrol. c# private void setupevents() { webbrowser1.navigated += new webbrowsernavigatedeventhandler(webbrowser1_navigated); webbrowser1.gotfocus += new eventhandler(webbrowser1_gotfocus); } [browsable(true)] public override color backcolor { { return base.backcolor; } set { base.backcolor = value; if (readystate == readystate.complete) { setbackgroundcolor(value); } } } public htmldocument document { { return webbrowser1.document; } } the error 'public event navigated(sender object, e system.windows.forms.webbrowsernavigatedeventargs)' event, , cannot called directly. use 'raiseevent' statement raise event. please help try code: private sub setupevents() addhandler webbrowser1.n...

audio - Possible to apply effects to the sound during a phonecall (iPhone)? -

so can catch sound input, , manipulate before "sends" phonemate? apple not provide public apis interact phone call. boltclock mentioned in comment, may possible use private apis this, apple not allow program uses private apis sold on app store.

asp.net - Looking for Oauth Yahoo sample C# -

i know threre lot of libraries dotnetopenauth,oauthbase, etc. need sample of using yahoo. samples,which find did not work me.maybe have example.please share :-) find bug oauthbase work fine me :-) this one , found explained well. , one oauth official site

c# 4.0 - Best way to refresh a Web.UI.Page in response to a callback from another thread -

what best way accomplish following in web page lifecycle? protected void btntestasync_click(object sender, eventargs e) { this.mainthreadid = thread.currentthread.managedthreadid; testbll bl = new testbll(); bl.onbeginwork += onbeginwork; bl.onendwork += onendwork; bl.onprogressupdate += onwork; threadstart threaddelegate = new threadstart(bl.performbeginwork); thread newthread = new thread(threaddelegate); newthread.start(); } then on onworkevent enter: private void onwork(asyncprogress workprogress, ref bool abortprocess) { string s = string.format("main tread: {0} worker thread: {1} count :{2} complete: {3} remaining: {4}", this.mainthreadid, workprogress.threadid, workprogress.numberofoperationstotal, workprogress.numberofoperationscompleted, ...

big o - Shifting an LFSR loop in O(1) time? -

i'm wondering if there's way combine 2 concepts: lfsrs, , barrel shifters i'm looking way to, in o(1) time, shift lfsr loop given number of shifts. what i'm hoping find simple process have current state of lfsr , number of times want shift state parameters quick/easy process. at first thought looking @ taps, moving taps on 1 , looking @ them again, finding shift in bit each time , appending onto end of course isn't o(1) , gets complicated if want shift many times tap "slide off" original lfsr state. if not in o(1) time, there more efficient way multiple shifts doing each 1 individually? in general, inclined answer no. reason if such algorithm existed, compute in o(1) time given bit in sequence generated lfsr. seems unlikely doable in general. however, can precomputation speed things somewhat. note after fixed number of steps, state of each cell in lfsr linear combination of bits initial state. so, if precompute coefficients in li...

xml - Generating XBRL document programmatically: Use a template or a library? -

i working on financial application , 1 of functionality generate xbrl (extensible business reporting language) document. if familiar xbrl instance documents, might aware typically refer large number of schemas. easier generate these xbrl instances using (commecial) libraries. use case: design web form users fill in various fields.generate valid xbrl instance document using user input. our platform: c# & .net my questions: have used of (commercial) libraries? 1 recommend generating 'yearly financial statements'? altova mapforce seems dominant player. a crude workaround avoid using (commecial) libraries: select valid instance document, clear data , store xbrl (xml) file template. render template user using xslt. collect user input , fill in xbrl using standard xml libraries in .net would recommend workaround? why & why not? any input appreciated :) right now, use variation of second approach. have template, parse , populate data, standa...

objective c - Return Local iPhone IP Address When on a VPN -

i need able return ios device's local ip address when connected vpn. not worried app store compliance or using private frameworks. find sample code returned either cell network address or wifi address not vpn address. try here: http://blog.zachwaugh.com/post/309927273/programmatically-retrieving-ip-address-of-iphone

Getting records between 2 dates someone chooses php mysql -

i'm trying records between 2 dates. dates entered in form "yyyy-mm-dd" input type="text" (so example type "2011-02-15" text input) , posted next page has query: $start = $_post["start"]; $end = $_post["end"]; $sql_query = "select * actionlist date>='{$start} 00:00:00' , date<='{$end} 23:59:59' order id"; $result = mysql_query($sql_query); the records in table "actionlist" have field called "date" , entered automatically when creating record using "$date = date('y-m-d h:i:s')". anyway, can't seem records selected. need process $start , $end variables somehow? in advance. $start = mysql_real_escape_string(trim($_post["start"])); $end = mysql_real_escape_string(trim($_post["end"])); $sql_query = "select * actionlist date between '".$start." 00:00:00' , '".$end." 23:59:59' order i...

java - VisualVM OQL: find object that has (indirect) reachables/references to two object IDs? -

my question rather short , compact: if find 2 objects visualvm, kind of oql query can perform find objects have (indirect) reachables or references these 2 objects? update jb: after editing code, came following: //query script: find object (indirectly) references target objects //list objects objects search should (indirectly) refer var targetobjects = [ heap.findobject("811819664"), //eg. obj contains player's health heap.findobject("811820024") //eg. obj contains same player's name ]; //list objects here every or objects have indirect referer (eg. base class loaders) var ignorereferers = []; //eg. [heap.findobject("ignid1")]; //set array elements refer each target object var targetobjectsreferers = []; (var tarobjindex in targetobjects) { var targetobjrefelements = []; //get live path of target object var livepaths = heap.livepaths(targ...

list - Listing all nodes created for a time period, Drupal -

i'd get/create list of nodes created during time period? there easy way (w/out creating custom view , selecting time period)? is there module might expose this? have large amount of content added system every night, , want able peruse list; title, url, etc. if not views, option write custom module. need it? ask stuck.

vb.net - How to add a tooltip to the 'X' in a Windows Form? -

i programming within visual studio 2008 vb.net. have been asked add tooltip upper closing button (the 'x' in top right of form next maximize , minimize buttons). is there anyway in able this? solution: i solved using @saman answer , changing figured post in case having problem solved or @saman's exact answer. first added tooltip toolbox form. didn't have disable tooltips minimize, maximize , close , doesn't appear. used @saman function 1 minor change: protected overrides sub wndproc(byref m system.windows.forms.message) if m.msg = 160 , m.wparam = 20 tooltip1.settooltip(me, "save , close") else mybase.wndproc(m) end if end sub as can see instead of using tooltip1.show() used tooltip1.settooltip() . found show worked infrequently, yet settooltip set tooltip of ('x') close button new text ("save , close") , shows whenever mouse goes on close button. at first must disable tooltips mini...

hardware - JavaScript in microchips/embedded systems like robots/microwaves -

is there product out on market uses javascript main language? example microwave uses javascript, embedded system use javascript scripting language, robot, digital camera, etcetera. know there’s lot of server side javascript engines, there home equipment? (i’m not referring equipment desktop computer, mobile, etcetera) companies - on long run - take profitable course of action when creating products, , using javascript appliances not profitable. javascript not intrinsically have capability interact hardware on level needed control appliance. attempt use javascript require lower level language on system, , lower level language need system interpret javascript. require additional storage , computational power, not mention javascript have heavily modified. more profitable use lower level language directly (not mention have better performance). i sure if javascript used appliances, there jquery function called $('#rocket').takeoff() use go moon in cross-browser compat...

c++ - How to access widgets created within functions in later function calls in Qt -

so have code, in c++, creates few qlabels, qlineedit, , qcheckbox when selection made qcombobox. however, able access widgets have created in later function destroy them if new selection made combo box. able access objects created using designer doing ui-> object not able objects created using own code. can how, because know how work that. in short, able dynamically create/destroy qwidgets based on selections made user. there reference should know of this, or documentation? or going wrong way? here code presently have creating objects: if (eventtype == qstring::fromstdstring("birthday")) { qlabel *label1 = new qlabel ("celebrant: "); qlabel *label2 = new qlabel ("surprise: "); qlineedit *lineedit = new qlineedit; qcheckbox *box = new qcheckbox; ui->gridlayout->addwidget(label1,3,0,1,1, 0); ui->gridlayout->addwidget(label2,4,0,1,1,0); ui->gridlayout->addwidget(lineedit,3,1,1,1,0); ui->gridlayo...

xpath - How do I replace sequences of whitespaces by one space but don't trim in XSLT? -

the function normalize-space removes leading , trailing whitespace , replaces sequences of whitespace characters single space. how can only replaces sequences of whitespace characters single space in xslt 1.0? instance "..x.y...\n\t..z." (spaces replaced dot readability) should become ".x.y.z." . without becker's method, use discouraged character mark: translate(normalize-space(concat('&#x7f;',.,'&#x7f;')),'&#x7f;','') note : 3 function calls... or character repeating expression: substring( normalize-space(concat('.',.,'.')), 2, string-length(normalize-space(concat('.',.,'.'))) - 2 ) in xslt can declare variable: <xsl:variable name="vnormalize" select="normalize-space(concat('.',.,'.'))"/> <xsl:value-of select="susbtring($vnormalize,2,string-length($vnormalize)-2)"/>

GWT + Hibernate + saving bandiwidth -

i writing gwt app using hibernate save on server. i have similar concept customer -> orders. if create class customer , class orders, in database, order table has foreign key customer table. say wanted retrieve orders server, , not care customer. if write bring down orders, automatically bring down customer if use eager loading. if not want that, can leave lazy loading , orders, , assume myorder.getcustomer() == null. now if wanted create order on client, there way set customerid on order , pass save without having pass customer object it. i.e. order myorder = new order(); . . . myorder.setcustomerid("1234"); rpcsave(myorder); or option have customer me = new customer() order myorder = new order() . . . myorder.setcustomer(me); rpcsave(myorder); thanks, nadin one options use transient field in customer linked order: public class order { @transient private string customerid; ... // setter/getter methods } here how value...

How do I load a variable number of scripts with jQuery.getScript() before running javascript code? -

i need load variable number of javascript source files before running javascript code depends on them. 1 script needs loaded, other times 2. getscript() method allows 1 script loaded - how use load x number of scripts before running inner code? $.getscript("test.js", function(){ // code run after script loaded }); what need: $.getscript(new array("1.js","2.js"), function(){ // code run after scripts loaded }); thanks i suggest labjs that purpose is.

android - Use Xuggle in Java to trancode and streaming video/audio -

i create http streaming server, clients can not play video formats, question is, if there way, using xuggle in server transcode video in specific format , streaming directly, on fly. i mean, not have wait finish transcoding , start http streaming. mean have loop example , everytime number of transcoded bytes , writes them socket. yes, but... i'd not recommend taking approach. encoding videos cpu intensive. accepted aproach solving problem transcode video file off-line , store on streaming server. yes, means couple of different media files same video, scales muuuuuuuuch better. (all?) successful streaming servers way.

Django - Image post processing on save -

if want able "post process" image after uploaded, crop down size , apply compression. stands, doing using post_save signal, when model saved, accessing file, applying post production , saving on original. i doing when created argument of post save signal set true avoid unnecessary image processing every time model updated. the problem when image field of existing instance updated, post processing of image being skipped because created flag false. how can setup model apply post processing image when imagefield has changed, if model created? this app may not used django admin , overwriting imagefield_save method isn't going work. hope can help! this question long time ago, not actual anymore? did have at: pre_save.connect(before_mymodel_save, sender=mymodel) have @ the signal documentation of django you create function before_mymodel_save , can try in there. if you're using save inside post or pre save functions: make sure disconnect signa...

c# - Connecting to a database -

i'm trying connect database nothing try works. sqlconnection conn = new sqlconnection(@"data source=c:\users\gerard foley\desktop\northwind.sdf"); conn.open(); no matter try error: a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified) i stole connection string database explorer -> properties -> connection string. missing? can tables show in datagridview fine (by dragging data sources), want use own ui , queries. can't seem figure ado thing out. using c# express 2010 , sql server express 2008. for proper connection string use connect sql server have at: http://connectionstrings.com the connection string using strange, should contain server name , database name, see link above examples...

haskell - Recursively sort non-contiguous list to list of contiguous lists -

i've been trying learn bit of functional programming (with haskell & erlang) lately , i'm amazed @ succinct solutions people can come when can think recursively , know tools. i want function convert list of sorted, unique, non-contiguous integers list of contiguous lists, i.e: [1,2,3,6,7,8,10,11] to: [[1,2,3], [6,7,8], [10,11] this best come in haskell (two functions):: make_ranges :: [[int]] -> [int] -> [[int]] make_ranges ranges [] = ranges make_ranges [] (x:xs) | null xs = [[x]] | otherwise = make_ranges [[x]] xs make_ranges ranges (x:xs) | (last (last ranges)) + 1 == x = make_ranges ((init ranges) ++ [(last ranges ++ [x])]) xs | otherwise = make_ranges (ranges ++ [[x]]) xs rangify :: [int] -> [[int]] rangify lst = make_ranges [] lst it might bit subjective i'd interested see better, more elegant, solution in either erlang or haskell (other functional languages might not understand it.) otherwise, points fixing...

string - Automatically format a measurement into engineering units in Java -

i'm trying find way automatically format measurement , unit string in engineering notation . special case of scientific notation, in exponent multiple of three, denoted using kilo, mega, milli, micro prefixes. this similar this post except should handle whole range of si units , prefixes. for example, i'm after library format quantities such that: 12345.6789 hz formatted 12 khz or 12.346 khz or 12.3456789 khz 1234567.89 j formatted 1 mj or 1.23 mj or 1.2345 mj , on. jsr-275 / jscience handle unit measurement ok, i'm yet find work out appropriate scaling prefix automatically based on magnitude of measurement. cheers, sam. import java.util.*; class measurement { public static final map<integer,string> prefixes; static { map<integer,string> tempprefixes = new hashmap<integer,string>(); tempprefixes.put(0,""); tempprefixes.put(3,"k"); tempprefixes.put(6,"m"); ...

forms - Browsers changing <input> value! -

so, have simple form: <form action="ajaxemail.php" id='email_form' method="post" target="_blank" enctype="application/x-www-form-urlencoded"> <p> <label for="email_from">from:</label> <input type="text" id="email_from" name="from" size="42" value= "user name<user@example.com>" /><br /> <label for="email_body">message body</label><br /> <textarea id="email_body" name="body" rows="10" style="width: 100%"></textarea> <input type="button" value="submit" onclick="$('email_form').submit(); bringforth(email_div,false);"/> </form> it supposed do, submits body of text e-mailed me. problem comes from. "user name" entire "<user@example.com>" being stripped off. therefore, unab...

java - How to create security anotation like spring security -

i wonder how create security annotation spring security (@preauthorized or @secured) check session decide how application threat authority log on user. is resource can read or recommendation? best regards ps: reason, cannot use spring security the technique behind these annotations called aspect oriented programming (aop) . spring security relies on spring aop, allows intercept particular method calls on spring-managed object, can apply security checks them. see aspect oriented programming spring . alternatively, if want without spring, see standalone aop implementations such aspectj .

How do I switch on emacs keys in Eclipse? -

if go window -> preferences -> general -> keys, change scheme "emacs", , click apply, nothing happens. i'm using eclipse 3.6.1 on fedora 14. there i'm missing or broken? there workaround doesn't involve manually entering of shortcuts? while don't know built in emacs keys, enjoy using emacs+ eclipse: http://www.mulgasoft.com/emacsplus .

scheme - Simple Recursion? -

i'm new programming , have had hard time understanding recursion. there's problem i've been working on can't figure out. don't understand how solvable. "define procedure plus takes 2 non-negative integers , returns sum. procedures (other recursive calls plus) may use are: zero?, sub1, , add1. i know built in functions in scheme, know they're possible solve, don't understand how. recursion tricky! any appreciated! =] thanks i'm working in petite chez scheme (with swl editor) recursion important concept in software development. don't know (petit chez) scheme approach general angle. the concept of recursive function repeat same task on , on again until reach limiting boundary. taking first question, have 2 numbers , need add them together. however, have ability add 1 number or subtract 1 number. have literal value zero. so. consider numbers 2 buckets. each have 10 stones in them. want "add" 2 buckets togeth...

Batch file - loop ping - output to file hosts that are up -

i make .bat file loop below: @echo off /l %%g in (1, 1, 69) ( ping -n 1 192.168.%%g.3 ping -n 1 192.168.%%g.4 ) then through output , send ips replied ping txt file. possible cmd batch file? @echo off set output=%userprofile%\output.txt if exist "%output%" del "%output%" /l %%g in (1, 1, 69) ( call :ping 192.168.%%g.3 call :ping 192.168.%%g.4 ) goto :eof :ping ping -n 1 %1 >nul && echo %1>>"%output%" basically, use && add command executed if previous command (the 1 before && ) completed (technically speaking, returned exit code of 0 ). there's similar approach opposite case. if want perform actions on unsuccessful result of command, put || after , command implementing action. edit one note ping . notification router host not accessible. in case ping still exits 0 code ('successful'), because reply, if it's router , not actual host. if can case hosts , don...

java - Primefaces sources jsf -

i've downloaded primefaces sources see if can learn them. jar contains bunch of java classes use writers handle rendering etc. expecting find .xhtml files with <ui:composition> ... </ui:composition> , <cc:interface> etc etc anyway got me thinking, there way write facelets , composite components or wrote in xhtml files compiled them java classes? sorry if question absurd new jsf. template files , composite components enduser's convenience because it's easy write , use them. basic jsf implementation (the f: , h: components) , component libraries primefaces use fullworthy ui components. classes extend jsf uicomponent class. development of uicomponent classes relatively complex , clumsy. you've got take lot of things account when developing them, such writing tag files (you've define every attribute in xml file), configuration files (link component , renderer each other), etc, end more modular , reuseable model , better efficien...

html - What is the difference in doc types -

okay, i've been meaning figure out while. what different doc types , mean? anytime i've done own limited research on this, keep getting confused references dtd , quirks mode , such, don't understand either. thank you! doctypes telling browser (x)html standard document using. way, browser knows how interpret data , how render on screen. examples here: http://www.w3.org/qa/2002/04/valid-dtd-list.html

enums - Typed constant declaration list -

i wish create "enum-like" list of constants following properties: the values of each identifier sequential, few gaps. (i believe iota , blank identifier in regard). the identifiers private module. the constants can compared other constants of same type. the enumeration based on enum fuse_opcode fuse . here's code i'm trying accomplish (and wrong): const opcode ( _ = iota // skip 0 lookupop forgetop getattrop setattrop readlinkop symlinkop // 6 _ // skip 7 mknodop // 8 // et cetera ad nauseam ) here's go code fuse opcodes. created enum fuse_opcode . typically write script that; used text editor. since constant values match c enum values, explicit values used. package fuse type opcode int32 const ( oplookup = 1 opforget = 2 opgetattr = 3 opsetattr = 4 opreadlink = 5 opsymlink = 6 opmknod = 8 opmkdir = 9 opunlink = 10 o...

python - xor each byte with 0x71 -

i needed read byte file, xor 0x71 , write file. however, when use following, reads byte string, xoring creates problems. f = open('a.out', 'r') f.read(1) so ended doing same in c. #include <stdio.h> int main() { char buffer[1] = {0}; file *fp = fopen("blah", "rb"); file *gp = fopen("a.out", "wb"); if(fp==null) printf("error opening file\n"); int rc; while((rc = fgetc(fp))!=eof) { printf("%x", rc ^ 0x71); fputc(rc ^ 0x71, gp); } return 0; } could tell me how convert string on using f.read() on hex value xor 0x71 , subsequently write on file? if want treat array of bytes, want bytearray behaves mutable array of bytes: b = bytearray(open('a.out', 'rb').read()) in range(len(b)): b[i] ^= 0x71 open('b.out', 'wb').write(b) indexing byte array returns integer between 0x00 , 0xff, , modifying in place avoid need create list , jo...

qt creator to give control from one window to another -

how give control 1 window pushbutton click both windows must part of same application. connect qpushbutton clicked signal slot on other window in activatewindow() called.

c# - Any suggestions for optimizing this code? -

i have written code answer given here my sample code follows void process(int i) { input = (bitmap)bitmap.fromfile(@"filepath.bmp"); bitmap temp = new bitmap(input.width, input.height, pixelformat.format24bpprgb); graphics g = graphics.fromimage(temp); g.clear(color.red); g.drawimage(input, point.empty); temp.save(stream, imageformat.bmp); //i need stream thats further processing } void timer_ex() { int = 11; (; ; ) { if (i == 335) break; else { st.start(); process(i); st.stop(); console.writeline(st.elapsedmilliseconds.tostring()); //this time more time in thread sleeps st.reset(); thread.sleep(70); i++; } } } so trying convert image rgb32 rgb24. takes more time on processing time in thread sleeps. sample code. me question "how can optimize...

windows phone 7 - Accessibility in WP7 (Silverlight) -

does have resources on how make silverlight wp7 apps more accessible visually impaired? i have apps in sl4 ported on wp7 intentionally designed include accessibility components, seems simplest thing windows.systemcolors don't work in wp7 (every system color shows black, regardless of theme). would appreciate you've got - links, official word big m, personal experience, looking glass future... the last bit of information saw on accessibility on wp7 in answers forums (http://answers.microsoft.com) in on of support engineers mentioned accessibility work wp7 still underway.

java - uploading of pdf file -

i want upload pdf file using code given below.it give browsing facility dont upload file. when click sendfile button display uploadfile.html code page. how can that??? error in given code??? filename-upload.html <%@ page language="java" %> <html> <head><title>display file upload form user</title></head> <% // uploading file used encrypt type of multipart/ form-data , input of file type browse , submit file %> <body> <form enctype="multipart/form-data" action= "uploadfile.html" method=post> <br><br><br> <center><table border="2" > <tr><center><td colspan="2"><p align= "center"><b>program uploading file</b><center></td></tr> <tr><td><b>choose file upload:</b> </td> <td>...

streaming - android VideoView increase buffering -

i have writen video player plays videos website. videoplayer actualy videoview gadget android. the videos playing ok when on wifi network, things not same if switch 3g expected :d. want increase streaming buffer, seems videoview streaming video 8% of clip size. when press play button, streaming still coming keeps percentage distance... , if press pause, streaming stopping.. can increase streaming length , make video streaming while in pause? thank you! you possibly read stream local file , point videoview that. i'm not sure how you're allowed store. also, videoview react fixed size of file pointed to. possibly create file in correct size, have make sure video not read beyond point have cached.

.net - ASP.NET Component with custom property form -

i'm developing custom datagridview control internal use , i'd add custom property option launches winform adding custom properties. think of columns property designer of datagridview click button text "..." on , opens winform can add different boundcolumns. don't know how or start. how can 1 accomplish this? this need know (the base): http://msdn.microsoft.com/en-us/library/zt27tfhy.aspx this helpfull example (inside first link): http://msdn.microsoft.com/en-us/library/az5kdaz0.aspx if want build custom datagrid, need build control inerith datagrid control, after read linked documents on top, can able add properties required attributes use in control. (sorry bad english, i'm italian!).

java - The expression of type x is boxed into X? -

i'm little confused warning eclipse ide writing next every expression types autoboxed or autounboxed: the expression of type x boxed x expression of type x unboxed x is warning should react on? thought autoboxing java language feature - seem warnings everytime feature used. i don't think eclipse default (mine not), can turn on or off using preferences > java > compiler > errors/warnings > potential programming problems > boxing , unboxing conversions. it should "ignore" unless want know this.

c# 4.0 - How to fire a code behind function when ASP.NET page is completely displayed? -

i need trigger c# code behind function right after asp.net page displayed. there event program? if not, how it? what might want try page methods /webmethods. take @ tutorial on singingeels.com , boils down to: respond sys.application.load event trigger call server page method create page method contains logic wish execute in response call respond result sent page method, appropriate in onsucceeded / onfailed event.

android - Image not appearing in my Html script -

i have section on android app called 'more information' few pages of html scripts display using webview following code - inputstream fin = getassets().open(htmlfl + ".html"); byte[] buffer = new byte[fin.available()]; fin.read(buffer); fin.close(); webview.loaddata(new string(buffer), "text/html", "utf-8"); it works fine except images not appearing on of pages. declare them using html following - <p><img src="http://www.ourweb.co.uk/images/icon.jpg">& nbsp;<span style="font-family: arial, helvetica, sans-serif; font-size: large;"> <b>opening times during exhibition</b></span></p> am doing wrong using webview , if not there way around this? you forgot add internet permission in manifest: <uses-permission android:name="android.permission.internet" /> the webview javadoc ...

java - Where to put the properties file in web app folder in Struts 1.3? -

i making simple web app using struts 1.3 . it contains simple registration page uses <bean:message > tag. i have set path of properties file in struts-config.xml file as: <message-resources parameter="resources.application" /> the file named : application.properties , stored shown below: web-inf---classes----resources---application.properties the page giving me error : org.apache.jasper.jasperexception: javax.servlet.servletexception: javax.servlet.jsp.jspexception: cannot find message resources under key org.apache.struts.action.message what problem ? i think struts file in web-inf/classes/resources.application.properties

objective c - Best way to know if application is inactive in cocoa mac OSX? -

so, building program stand on exhibition public usage, , got task make inactive state it. display random videos folder on screen, screensaver in application. so best , proper way of checking if user inactive? what thinking kind of global timer gets reset on every user input , if reaches lets 1 minute goes inactive mode. there better ways? have @ this article covering use of iokit read users idle time iohid.

javascript - manipulating dynamically created form elements without losing their values with jQuery -

i want search , replace on complex bit of dynamically created form. it's simple finding instances of 1 string , replacing them another, made more complicated fact there 11 instances per bit of form , make parts of various attributes. examples of kind of thing i'm working (it's '001' bit i'm searching , replacing): <div id="step_title:001|title"> <label for="step_title:001|title|field"> <input id="step_title:001|title|field" name="step_title:001|title|field"/> i had thought trick: $(this).html($(this).html().replace('old string', 'new string')); however because bit of form dynamically added form data lost every time perform action. tried using .clone() function seems preserve data, doesn't allow manipulate object. tried performing search , replace directly onto containing object, guess .replace() works on strings. can update attributes instead? $('div, label...

xml - parser error : String not started expecting ' or " in php -

hi i'm trying convert xml file associative array using following code $xmlurl = '../products.xml'; $xmlstr = file_get_contents($xmlurl); $xmlobj = simplexml_load_string($xmlstr); print_r ($xmlobj);exit; $arrxml = objectsintoarray($xmlobj); and product.xml containing <?xml version="1.0" encoding="utf-8"?> <products> <product> <sku>p750h3</sku> <category>plans: vodafone unlimited cap</category> <price>$0</price> <totalmonthlycost>$129</totalmonthlycost> <totalmincost>$3096</totalmincost> <upfront>$0</upfront> <imageurl>http://store.vodafone.com.au/images/upload/nokia-6260-slide-front_118x307.png</imageurl> <threedurl>http://store.vodafone.com.au/handset-nokia-6260-slide.aspx#3d</threedurl> <smallimageurl>http://store.vodafone.com.au/images/upload/nokia-6260-slide-front_23x60.png</smalli...

list<string> cannot pass it to an class in c++ -

i have list datas list<string> l; , if pass value class process gives me error process p; p.getnames(l); and have header file process.h class process { public: void getnames(list<string> ll); }; and have cpp file process.cpp void getnames(list<string> ll) { // can use names here } error undefined reference `process::getname(std::list<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >)' the error you're getting linker error because you've defined free function named getname rather member function getname. fix this, change .cpp file have process::getname(list<string> names) and should good. error compiler thinks you're defining random function no connection process, when compiles code , tries use process::getname linker can't find imple...

html - icefaces menupopup strange problem -

i have piece of code: <ice:panelgroup menupopup="menupopup1" onclick="firecontextmenu(this, event);"> <img src="/resources/images/external/bg-suppliers.gif"> </img> </ice:panelgroup> it renders html output (as expected): <div class="icepnlgrp" id="j_id62" onclick="firecontextmenu(this, event);"> <img src="/resources/images/external/bg-suppliers.gif"> </div> if add menupopup attribute ice:panelgroup like: <ice:panelgroup menupopup="menupopup1" onclick="firecontextmenu(this, event);"> <img src="/resources/images/external/bg-suppliers.gif"> </img> </ice:panelgroup> it closes divs before img tag: <div class="icepnlgrp" id="j_id62" onclick="firecontextmenu(this, event);"></div> <img src="/resources/images/external/bg-supplie...

objective c - Error: "-[NSCFString sizeWithTextStyle:]: unrecognized selector" in IPhone SDK -

Image
i following error while running app. '-[nscfstring sizewithtextstyle:]: unrecognized selector i have not used sizewithtextstyle in entire project. so wrong? i error on return pos; statement below code: (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section { uiview *pos = [[uiview alloc] initwithframe:cgrectmake(0.0,0.0,320.0,35.0)]; return pos; } error in console: terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[nscfstring sizewithtextstyle:]: unrecognized selector sent instance 0x7044b50' because of indentation problem while putting whole crash log here, putting screenshot of crash log i think, problem somewhere else, not in line of code. object not able retain itself. post code, using sizewithtextstyle method have -all_load flag on link settings? this issue comes lot. you need add -all_load , -objc applications link flags. * edit : * crash appears ...

django - How to use the ExtFileField snippet? -

as want restrict fileupload types of audiofiles, found django snippet http://djangosnippets.org/snippets/977/ , restricting fileupload files within extension whitelist: class extfilefield(forms.filefield): """ same forms.filefield, can specify file extension whitelist. >>> django.core.files.uploadedfile import simpleuploadedfile >>> >>> t = extfilefield(ext_whitelist=(".pdf", ".txt")) >>> >>> t.clean(simpleuploadedfile('filename.pdf', 'some file content')) >>> t.clean(simpleuploadedfile('filename.txt', 'some file content')) >>> >>> t.clean(simpleuploadedfile('filename.exe', 'some file content')) traceback (most recent call last): ... validationerror: [u'not allowed filetype!'] """ def __init__(self, *args, **kwargs): ext_whitelist = kwargs.pop("ext_whitelist") self.ext_whitelist = [i.l...

php - explode and in_Array search not working -

ok here code codepad here http://codepad.org/zqz0kn3r function processcontent($content, $min_count = 2, $exclude_list = array()) { $wordstmp = explode(' ', str_replace(array('(', ')', '[', ']', '{', '}', "'", '"', ':', ',', '.', '?'), ' ', $content)); $words = array(); $wordstmp2 = array(); $omit = array('and', 'or', 'but', 'yet', 'for', 'not', 'so', '&', '&amp;', '+', '=', '-', '*', '/', '^', '_', '\\', '|'); if(count($exclude_list)>0){ $omit = array_merge($omit, $exclude_list); } foreach ($wordstmp $wordtmp) { if (!empty($wordtmp) && !in_array($wordtmp, $omit) && strlen($wordtmp) >= $min_count) { $words[] = $wordtmp; } } return $words; } ok function sh...

java - Refactoring to test -

i have piece of code equivalent following. public class concretethread extends otherthread { private daofirst firstdao; private daosecond seconddao; private transformservice transformservice; private networkservice networkservice; public concretethread(daofirst first, daosecond second, transformservice service1, networkservice service2) { firstdao = first; seconddao = second; transformservice = service1; networkservice = service2; } public future go() { results r1 = firstdao.getresults(); mycallable c1 = new mycallable(r1); return super.getthreadpool().submit(c1); } private class mycallable implements callable { private results result; private long count; private mycallable(results r) { this.result = r; this.count = new long(0); } public long call() { singleton transactions = singleton.getinstance(); try { transactions.begin(); while(result != null) { ...

entity framework - Adding index to a table -

i have table person : id, name i have queries like: select * person name "%abc%". i have 2 questions: how implement query using code-first 5 (ctp5) how add index on name column make data retrieval faster based on name in query? like operator can performed contains function: var query = p in context.persons p.name.contains("abc") select p; index must added sql - there no special construction in ef create index. can execute sql db initialization. first must implement custom initializer: public class myinitializer : createdatabaseifnotexists<mycontext> { protected override void seed(mycontext context) { context.database.sqlcommand("create index ix_person_name on person (name)"); } } then must register new initializer: dbdatabase.setinitializer<mycontext>(new myinitializer());

python - Shuffling NumPy array along a given axis -

given following numpy array, > = array([[1, 2, 3, 4, 5], [1, 2, 3, 4, 5],[1, 2, 3, 4, 5]]) it's simple enough shuffle single row, > shuffle(a[0]) > array([[4, 2, 1, 3, 5],[1, 2, 3, 4, 5],[1, 2, 3, 4, 5]]) is possible use indexing notation shuffle each of rows independently? or have iterate on array. had in mind like, > numpy.shuffle(a[:]) > array([[4, 2, 3, 5, 1],[3, 1, 4, 5, 2],[4, 2, 1, 3, 5]]) # not real output though doesn't work. you have call numpy.random.shuffle() several times because shuffling several sequences independently. numpy.random.shuffle() works on mutable sequence , not ufunc . shortest , efficient code shuffle rows of two-dimensional array a separately is map(numpy.random.shuffle, a)

Packet Listener in Android Service -

i trying create service chat widget using xmpp, picks chat messages when sent user. i have created service, , in onstart use asynctask connect chat server, , sets packetlistener. here's code packer listener: public void setconnection(xmppconnection connection) { if (connection != null) { // add packet listener messages sent packetfilter filter = new messagetypefilter(message.type.chat); connection.addpacketlistener(new packetlistener() { public void processpacket(packet packet) { message message = (message) packet; if (message.getbody() != null) { string fromname = stringutils.parsebareaddress(message .getfrom()); log.v(tag, "got:" + message.getbody()); // messages.add(fromname + ":"); // messages.add(message.getbody()); } } }, filter); ...

first application on Ruby on Rails -

im begginer in ror. me please. use windows xp, ruby 1.9.2, sqlite 3.7.5 r steps creating new. install ruby gem install rails rails new c:\tm\test sqlite3.dll, sqlite3.exe gem install sqlite3-ruby in database.yml: development: adapter: sqlite3 dbfile: db/test.db c:\tm\test>sqlite3 -init db.sql test.db rails generate model article rails generate controller article in test\app\controllers\article_controller.rb: class articlecontroller < applicationcontroller scaffold :article end rails server in firefox http://localhost:3000/article and have trouble on page: argumenterror no database file specified. missing argument: database must seeinterface work table in cmd after see: argumenterror (no database file specified. missing argument: database): in cmd after: rails generate scaffold article article i spend this: missing type attribute 'article'. example: 'article:string' string type. me please it's database in yml, not db...

jquery - Running Javascript inside a simplemodal window -

i'm trying add scripts modal ( simplemodal ) jquery plugin won't run, functionality not available when running in modal or missing something. here's how i'm calling simplemodal: $('#modal').modal({ onclose: function (dialog) { $app.setlocation('#/'); $.modal.close(); } }); and here's html of modal, includes addthis script (i've taken out real username posting here): <div class="article clearfix"> <div class="article-post"> <h2 class="title">{{header}}</h2> <p class="date">posted in {{feed_source}}, {{date}}</p> <ul class="tags clearfix"> <li><a href="#">tag 1</a></li> <li><a href="#">tag 2</a></li> </ul> <div class="body"> {{{body}}} </div> </div> <div id="single-article-commen...

database - Sharepoint: Connect to Access DB (.accdb) in document library -

i have site database placed inside document library. need extract data database , show in webpart. is there sharepoint-specific way of doing this, or connect regular connection string , point @ filename in document library, eg: http://spsite/doclib/database.accdb ? i not need pull data often, if there's overhead "fetching" database document library , memory can overlooked. seems though sp should have built-in feature access data. i tried searching how sharepoint 2007 show data access database, no avail. (note: have no problem connection string, sql, showing data, etc. - problem how connect database can execute queries) if table of data simple, consider exporting table access sharepoint list. access supports links sharepoint lists. so, can deploy access client application each persons desktop, data (the list) remain on sharepoint. since list standard list, standard sharepoint tools , code can use list other list. i not believe can open , pull data ta...

WPF. How to set focus on an element by it's tab index? -

is possible element or set focus on (textbox, instance) it's tab index, if element part of datatemplate , tab index of element uniquely defined? you can visualtreehelper search element created through templates. therefore can check tabindex of existing element , find desired element (it tab-index unique:). can name elments in datatemplate , filter name. the following function lets find elements of given type of visual tree. void findchildframeworkelementsoftype<t>(dependencyobject parent,ilist<t> list) t: frameworkelement{ dependencyobject child; for(int i=0;i< visualtreehelper.getchildrencount(parent);i++){ child = visualtreehelper.getchild(parent, i); if (child t) { list.add((t)child); } findchildframeworkelementsoftype<t>(child,list); } } call follows: list<textbox> textboxlist=new list<textbox>(); findchildframeworkelementsoftype<t...

java - Is there a way to prevent Eclipse from opening the browser when starting a Web application? -

ahoy! i wondering if there's way configure eclipse not open browser (internal or external, doesn't matter) when user selects run > run or server in specific (or any) web project. couldn't find option... no there not. way not click on apllication , run as, click on server , launch it(and deploy application). rid of browser opening.

c# - Email messages going to spam folder -

i have created community portal, in user creates his/her account. after successfull registration confirmation mail send on registered email address. i using following code send mail - private void sendmail(string recvr, string recvrname, string vercode, int newuserid) { try { string emailid = configurationmanager.appsettings["webmastermail"]; string mailpass = configurationmanager.appsettings["pass"]; string mailer = configurationmanager.appsettings["mailer"]; mailmessage msg = new mailmessage(); mailaddress addrfrom = new mailaddress(emailid, "panbeli.in.... bari community portal"); mailaddress addrto = new mailaddress(recvr, recvrname); msg.to.add(addrto); msg.from = addrfrom; msg.subject = "you have registered sucessfully on panbeli.in."; msg.priority = mailpriority.high; msg.body = registermessagebody(recvrname, vercode,newuseri...

java - Hibernate implementation of JPA -

i'm wanting using jpa in ear project. development project must started asap have not lot of time research , investigate. please jpa api restricted functionality of hibernate or no. @ moment i'm using hibernate directly. example in future i'm planing use hibernate-search , maybe hibernare-validate , -shard. can sure in future not have problem using this. , 1 more example - can use har archive , jpa together. why jpa? project available restful service (jersey or resteassy implementation). , looked in case using jpa this. i'm newbie in it's imho. may mistakes. thanks lot. best regards artem jpa subset of hibernate, you're not limited it. if need hibernate specific feature, can use @ cost of being tied hibernate. example, we've mixed in hibernate annotations jpa ones, including validater ones, without trouble.