Posts

Showing posts from August, 2010

Can you grab a file with PHP through a form with $_SERVER['PHP_SELF']; action? -

i have email attachment form working fine when <form action="processingtheformfile.php"> sent php file process. however, when try implement same idea form <form action="<?php echo $_server['php_self']; ?>"> , use if(isset($_post['submit'])) { $tmp_name = $_files['filename']['tmp_name']; $type = $_files['filename']['type']; $name = $_files['filename']['name']; $size = $_files['filename']['size']; before html of file, attachment ends being noname.txt everytime, regardless of file type. is because $_files cannot work on <?php echo $_server['php_self']; ?> action, or should elsewhere dilemna? pray makes sense.... forms used uploading files need have enctype="multipart/form-data" make work. here's example: <form method="post" enctype="multipart/form-data" action=""> although r...

javascript - jquery tooltip throwing error: function not defined -

i trying custom tooltip on image. during run time says "method or property tooltip not defined" here code <script src="/full/jquery.tools.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("#content img[title]").tooltip(); }); </script> <style type="text/css" > .tooltip { display:none; background:transparent url(images/blackarrow.png); font-size:12px; height:70px; width:160px; padding:25px; color:#eee; }</style> </asp:content> <div id="content"> <img alt="" src="images/help1.png" title="your comes here" /></div> try include plugin directly developer, test. if works, there problem code. i've removed [title] <img> , if need it, p...

Jasper report line chart with two date type axis -

Image
hello ! i need create report attachment shows jasper reports. i've tried line chart. result : line chart expects 2 number type field axises. i've tried time series. result : time series expect 1 number , 1 date type field axises. i have use dates, need chart type can handle dates. any suggestion how can solve ? i've tried google @ least 10 hour. i'm desperated. thanks ! i think i've solved problem. i've written customizer class : package com.test; import java.text.dateformat; import java.text.simpledateformat; import net.sf.jasperreports.engine.jrchart; import net.sf.jasperreports.engine.jrchartcustomizer; import org.jfree.chart.jfreechart; import org.jfree.chart.axis.dateaxis; import org.jfree.chart.axis.datetickunit; import org.jfree.chart.plot.xyplot; public class trendcustomizer implements jrchartcustomizer { public void customize(jfreechart chart, jrchart jasperchart) { dateaxis xaxis = new dateaxis(); dateaxis yaxi...

twitter bootstrap - Less CSS - access part of class name and use in mixin -

in less, possible access part of class name , use within mixin? this best explained example: i have grid have declared follows: .columns (@columns) { //code here generate column widths } //this problem is: .column-1 { .col (1) } .column-2 { .col (2) } .column-3 { .col (3) } // etc etc obviously there lot of repetitive code going on here. ideally able not have declare column-1 column-2 etc , have way, regex perhaps, of parsing class name, , using value after dash automatically calculate column width. twitter bootstrap doing similar cant understand it: .spanx (@index) when (@index > 0) { (~".span@{index}") { .span(@index); } .spanx(@index - 1); } .spanx (0) {} i think you'll understand : .columnx (@index) when (@index > 0) { // guarded mixin: use mixin when condition true (like if statement) (~".column-@{index}") { // outputs .column-0 class name .col(@ind...

python - Obscure curses error message when creating a sub window -

i have simple python curses code creates subwindow. however, in process of running function window.subwin() fails message: here test case: import curses if __name__ == '__main__': curses.initscr() window = curses.newwin(15, 40, 7, 20) window.box() window.refresh() subwindow = window.subwin(5, 10, 2, 2) subwindow.box() subwindow.refresh() subwindow.getkey() curses.endwin() produces following output: traceback (most recent call last): file "c.py", line 12, in <module> subwindow = window.subwin(5, 10, 2, 2) _curses.error: curses function returned null is there way more descriptive message? the error happens when not possible create sub-window (illegal operation). can happen because asking paint sub-window outside of window. the method subwin receives absolute coordinates (with respect screen, not parent window). fail if subwin coordinates outside of window . reason fail: width or height overfl...

c++ - Linking to older version of gcc -

i have centos 6.2 (64bit gcc 4.4.6 default). unfortunately, code compiles gcc 3.4.6, installed gcc separately (from source) under /home/rajat/local. on linking simple "hello world" program, following. >ldd a.out linux-vdso.so.1 => (0x00007fff215ff000) libstdc++.so.6 => /home/rajat/local/lib64/libstdc++.so.6 (0x00007f11853e7000) libm.so.6 => /lib64/libm.so.6 (0x00000033be400000) libgcc_s.so.1 => /home/rajat/local/lib64/libgcc_s.so.1 (0x00007f11851ce000) libc.so.6 => /lib64/libc.so.6 (0x00000033bd000000) /lib64/ld-linux-x86-64.so.2 (0x00000033bcc00000) while stdc++ , gcc link 3.4.6 libraries, libm , libc still link default libraries. ok?? 3.4.6 installation did not produce libm or libc libraries? yes, that's ok. the libc/libm part of glibc, not gcc compiler. libstdc++ on other hand ls part of gcc.

git - Unmerged Commits going off the track with no future -

Image
i new git , trying grasp ins , outs of it. have 1 efficiency related question. in picture below please see red arrow. my question can scenario named mean line associated red arrow has no future. different color lines technicaly termed as. understanding concept of wanted google problem due limited git vocabulary wasnt able search meaning ful. after tellinng me names of these two. my next , important question should these red arrow lines considered problem ?. if yes, why , how reolve those. this isn't native git; you're using sort of gui tool. won't try guess, , practical point of view doesn't matter long it's sensible. the colored lines branches. dots on each line represent commits. whether or not colors mean specific, other way differentiate branches, gui. the top-most dot of each line branch head. red arrow pointing merge commit never merged rest of ongoing development--or vice-versa, depending on point of view. it's informational, , not ...

java - how to clear this error iTextPdf Document error? -

i getting the document has no pages. runtime error in program... public class windows { public static void main(string[] args) throws filenotfoundexception, documentexception { java.io.file f = new java.io.file("c:/temp/text.pdf"); java.io.fileoutputstream fo = new java.io.fileoutputstream(f); com.itextpdf.text.document d = new com.itextpdf.text.document(pagesize.a5, 50, 50, 50, 50); pdfwriter pw = pdfwriter.getinstance(d, fo); d.open(); boolean b0 = d.newpage(); boolean b1 = d.addauthor("tamil selvan"); d.addcreator("tamil selvan"); d.addheader("tamil selvan header name", "header content"); d.addkeywords("these keywords document"); d.addsubject("these subjects document"); d.addtitle("the title of document"); d.close(); system.out.println("is documnet opened "+b0); system....

c# - Toolbar Overlay over WindowsFormsHost -

i have swf object embedded in windowsformshost control inside wpf window. i'd add toolbar on swf movie. the problem snippet of code have below, when new child added host control (or movie loaded, haven't figured out yet), toolbar invisible. seems z-index of swf reason set top. here looks like: xaml: <grid name="player"> <windowsformshost name="host" panel.zindex="0" /> <grid name="toolbar" panel.zindex="1" height="50" verticalalignment="bottom"> [play, pause, seek columns go here] </grid> </grid> c#: private void window_loaded(object sender, routedeventargs e) { flash = new axshockwaveflashobjects.axshockwaveflash(); host.child = flash; flash.loadmovie(0, [movie]); // movie plays, no toolbar :( } any insight on issue appreciated. update: since no suitable answer posted, i've placed own solution below. realize more of...

c++ - Why should Next() operation of a singly linked list be protected with a critical section? -

i'm reading book multithreading applications in win32 the book says return node->next compiled separate machine instructions not executed atomic operation, next() should protected critical section. my question is, instructions translated into, cause race condition? typedef struct _node { struct node *next; int data; } node; typedef struct _list { node *head; critical section critical_sec; } list; list *createlist() { list *plist = malloc(sizeof(list)); plist->head = null; initializecriticalsection(&plist->critical_sec); return plist; } void deletelist(list *plist) { deletecriticalsection(&plist->critical_sec); free(plist); } void addhead(list *plist, node *node) { entercriticalsection(&plist->critical_sec); node->next = plist->head; plist->head = node; leavecriticalsection(&plist->critical_sec); } void insert(list *plist, node *afternode, node *newnode) { entercri...

passing wstring, string and reference to enum variable from C# to C++(unmanaged DLL) -

i have c++ dll in following functions exported. double getdouble(std::wstring filename, std::string id, status &stcode); int getint(std::wstring filename, std::string id, status &stcode); float getfloat(std::wstring filename, std::string id, status &stcode); string getstring(std::wstring filename, std::string id, status &stcode); int* getintarray(std::wstring filename, std::string id, status &stcode); float* getfloatarray(std::wstring filename, std::string id, status &stcode); string* getstringarray(std::wstring filename, std::string id, status &stcode); where status of enum type... now want use dll in c#.net app... can tell me how delclare respected methods in c# , can make call methods.... in advance... [dllimport("external.dll", setlasterror = true, callingconvention = callingconvention.cdecl)] public static extern mbstatus queue_accept( int reader, [marshalas(unmanagedtype.lpstr)] string status);...

java - select a word from a section of string? -

i'm trying find out if there methods in java me achieve following. i want pass method parameter below "(hi|hello) name (bob|robert). today (good|great|wonderful) day." i want method select 1 of words inside parenthesis separated '|' , return full string 1 of words randomly selected. java have methods or have code myself using character character checks in loops? you can parse regexes. the regex \(\w+(\|\w+)*\) ; in replacement split argument on '|' , return random word. something like import java.util.regex.*; public final class replacer { //atext: "(hi|hello) name (bob|robert). today (good|great|wonderful) day." //returns: "hello name bob. today wonderful day." public static string geteditedtext(string atext){ stringbuffer result = new stringbuffer(); matcher matcher = finitial_a.matcher(atext); while ( matcher.find() ) { matcher.appendreplacement(result, getreplacement(matcher)); ...

hash - C++ Unordered_Map: Receiving "error: expected unqualified-id before ‘[’ token" at Compile -

i have unordered_map (in c++) pairs int object of class item. initialize unordered map @ beginning of file such: #include <iostream> #include <unordered_map> using namespace std; typedef std::unordered_map<int, item> mylist; from on, whenever try use mylist, such in: item item1; mylist[12] = item1; i receive error @ said line: "error: expected unqualified-id before ‘[’ token" when compile in terminal. ideas wrong? below other example of how use , receive same or similar error. void itemmanager::removeitem(int x) { mylist.erase(x); } yields: "error: expected primary-expression before ‘.’ token" please , help. mylist type: typedef std::unordered_map<int, item> mylist; but using object: mylist[12] = item1; perhaps putting typedef in there mistake.

objective c - Core-data database updated in new app version -

Image
i have application in xcode using sqlite/coredata database , has been submitted app store. now have changed database managed object changed , want submit updated new version of app. want people have downloaded previous version of app won't loose data in old database.how can achieved? appreciated. this documentation official word on subject. though, simple walkthrough like: add new model version: modify new model version tastes, make sure it's set current model in inspector of root file. make mapping model knows how migrate data new model: choose corresponding models (source/destination) , edit generated mapping model tastes (often requires no changes @ if changes aren't complex). that's simplified/stripped down walkthrough it's start. read on it!

eclipse plugin - Failed to instantiate com.android.menubar.internal.MenuBarEnhancerCocoa -

i new android development , when create new project using eclipse juno on mac osx got error @ runtime failed instantiate com.android.menubar.internal.menubarenhancercocoa and yes on layout file says- the project target(android 4.1) not loaded . anyone please me how out of this. in advance.. and yes setup sdk , all, because whole setup running on 1 of other system. i had same problem managed resolve it. com.android.menubar.internal.menubarenhancercocoa - not in sdk linked eclipse install (i have multiple various reasons - e.g. appengine not supported in latest eclipse). there number of steps had resolve (so 1 of them may actual fix or combination may resolve problem). here's checklist : if have installed eclipse - click android sdk manager icon. ensure pointing latest android sdk (r20 of writing) as it's new eclipse+sdk - add build targets selecting list of targets appear in sdk manager. add android support tools restart eclipse. when asked workspace - c...

how .htaccess authentication works with my website via LDAP. How the cookies and sessions are set? -

i using .htaccess authentication website. once authentication happen ad vi ldap, how authenticated user's session , cookies got created in browser , redirection happening website. please in or please share links explains process. take @ wiki pages basic authentication , digest authentication , both authentication mechanism on protocol (http). basically, browser sees (heavily paraphrasing here): attempt request uri, webserver replies 401 response , www-authenticate header this header contains realm, kind of group of pages belong same authentication realm browser pops modal dialog box asking username , password. depending on basic or digest, password sent webserver along original request resulted in 401. if credentials incorrect, 403 returned , browser shows appropriate error message. otherwise, webserver returns requested page. the browser knows url belongs realm, every time url requested, authorization automatically sent along request. if browser requests e...

apache2 - How to get the group in which the user is authenticated? -

i know can manually parse htaccess group file remote_user group name. there way cgi group name apache2 ? apache not make full list of groups user, or groups caused authorization succeed, available cgi or other modules.

ios - Saving data objects between sessions -

i'm putting last bit of functionality in application. 1 of things want s have user able save notes. each note has title , body user specifies. when user hits save, want title , body saved in object, , have object added array (which later used populate tableview). best way save array of data objects between sessions? you should use core data this. create "note" object fields want. read on core data programming because whole subject, in essence end underlying sqlite data store interact using nsmanagedobjects

java - Checking if an EasyMock mock is on replay mode/state -

is possible determine if easymock mock on replay mode? something like: if (easymock.isreplayed(mock)) // in order check state of mock need unproxy mock , check state set mock, , 1 state replaystate . easymock works java proxies, quite easy: easymock.replay(mock); // setting replay state mock object // stripping proxy , getting invocation handler invocationhandler invocationhandler = proxy.getinvocationhandler(mock); // easymock, invocation handler holds state of mock objectmethodsfilter objectmethodsfilter = (objectmethodsfilter) invocationhandler; // not not elegant part: // this: objectmethodsfilter.getdelegate().getcontrol().getstate() // retrieves state instance can checked if // instance of replaystate.class boolean inreplaystate = objectmethodsfilter.getdelegate() .getcontrol().getstate() instanceof replaystate; and thats it! print true because set replay maybe version 3.1 use: classextensionhelper.getcontrol(mock).getstate() instance...

objective c - Objecive-C Draw a Circle with a Ring shape -

i wrote class draws animated progress circle (it draws circular sector based on float progress) @implementation mxmprogressview @synthesize progress; - (id)initwithdefaultsize { int circleoffset = 45.0f; self = [super initwithframe:cgrectmake(0.0f, 0.0f, 135.0f + circleoffset, 135.0f + circleoffset)]; self.backgroundcolor = [uicolor clearcolor]; return self; } - (void)drawrect:(cgrect)rect { cgrect allrect = self.bounds; cgrect circlerect = cgrectmake(allrect.origin.x + 2, allrect.origin.y + 2, allrect.size.width - 4, allrect.size.height - 4); cgcontextref context = uigraphicsgetcurrentcontext(); // background image //uiimage *image = [uiimage imagenamed:@"loader_disc_hover.png"]; //[image drawinrect:circlerect]; // orange: e27006 cgcontextsetrgbfillcolo...

javascript - getElementsByTagName("*") always updated? -

i have made code: var foo=document.createelement("div"); var childs=foo.getelementsbytagname("*"); console.log(childs.length);//0 ok var a=document.createelement("a"); foo.appendchild(a); console.log(childs.length);//1 wtf? a fiddle: http://jsfiddle.net/rl54z/3/ i don't have write childs=foo.getelementsbytagname("*"); between fifth , sixth line childs.length updated. how can be? most lists of nodes in dom (e.g. returned getelementsby* , queryselectorall , , node.childnodes ) not simple arrays rather nodelist objects. nodelist objects "live", in changes document automatically propagated nodelist object. (an exception result queryselectorall , not live!) so can see in example, if retrieve nodelist of a elements, add a element document, a appear in nodelist object. this why unsafe iterate through nodelist while making changes document @ same time. e.g., code behave in surprising ways: var nodel...

php - How to get geo location (coordinates) from image file? -

i've searched everywhere couldn't find solution, decided write own class in php. succeed in iphone image file , instagram image not sure if works other cameras android supported phones , cameras gps. can me out this? below code , implementation. <?php class filer { /** * variables */ private $_gpslatitude; private $_gpslongitude; private $_gpslatituderef; private $_gpslongituderef; /** * constructor method */ public function __construct(){ /** * gps meta (in reference iphone's image file) * may android folow same thing (haven't checked) */ $this->_gpslatitude = 'gpslatitude'; $this->_gpslongitude = 'gpslongitude'; $this->_gpslongituderef = 'gpslatituderef'; $this->_gpslongituderef = 'gpslongituderef'; } ...

jqtouch - Troubleshooting Paypal -

Image
i have paypal button within jqtouch site follows <div id="paypal"> <div class="toolbar"> <h5>pay online</h5> <a href="#" class="back">back</a> </div> <div class="s-scrollwrapper" > <div> <form action="https://www.paypal.com/cgi-bin/webscr"method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="----@-----------"> <input type="hidden" name="item_name" value="test item"> <input type="hidden" name="amount" value="1.00"> <input type="hidden" name="currency_code" value="nzd"> <input type="hidde...

ios - Change statusbar tint colour -

is there way set status bar tint colour? have navigationbar tint set brown , when it's on screen changes statusbar brown, on views hide navigationbar statusbar returns original colour. how can change statusbar tint colour persist trough application? there no way in ios 5. can change bar style. but if take @ new wwdc 2012 sessions, may find interesting) session number 216 - advanced appearance customization on ios

javascript - Jquery: div Hyperlink -

knewb here, have made textless, blocked, div clickable jquery , css. upon click load new url browser taking visitor away website stackoverflow.com. can jquery? if how? #star{ width:130px; height:40px; outline:1px solid orange; display:block; cursor:pointer; } <div id="star">star</div> <script> $("#star").click(function(evt){ $(this).html("http://www.stackoverflow.com"); }); </script> second question have have div transparent or empty menu background shows, (no slicing.). can or , should transparent gif? btw: how modify code local url? thank you! the first part relatively easy: $("#star").click(function(evt){ window.location = 'http://stackoverflow.com'; }); as transparency, add following css: #star { /* other stuff */ background-color: transparent; } or, if don't need full cross-browser compatibility: #star { /* other ...

c# - Generating sample data from regex to verify input strings by focussing on boundary cases defined in regex -

there several tools how generate sample data given regex. include: rex fare however, while may sufficient seed dataset, doesn't testing code depends on regex itself, such validation. assume have code generator generates model property. user specifies regex validate property. assume code generator attempting generate tests ensure validation succeeds , fails appropriately. seems reasonable tool focus on boundary cases within regex avoid generating unnecessary data. for example, consider regex ^([a-z]{3,6})$ boundary cases include: any string consisting of [a-z] length equal 2 (failure) any string consisting of [a-z] length equal 3 (success) any string consisting of [a-z] length equal 4 (success) any string consisting of [a-z] length equal 5 (success) any string consisting of [a-z] length equal 6 (success) any string consisting of [a-z] length equal 7 (failure) any string not consisting of [a-z] (failure) any string not starting [a-z] ends [a-z] (failure) ...

.net - Is there any way to implicitly construct a type in C#? -

i read of useful trick how can avoid using wrong domain data in code creating data type each domain type you're using. doing compiler prevent accidentally mixing types. for example, defining these: public struct meter { public int value; public meter(int value) { this.value = value; } } public struct second { public int value; public second(int value) { this.value = value; } } allows me not mix meters , seconds because they're separate data types. great , can see how useful can be. i'm aware you'd still need define operator overloads handle kind of arithmetic these types, i'm leaving out simplicity. the problem i'm having approach in order use these types need use full constructor every time, this: meter distance = new meter(5); is there way in c# can use same mode of construction system.int32 uses, this: meter distance = 5; i tried creating implicit conversion seems need part of int32 type,...

actionscript 2 - parse json in as2 -

i need load , parse json in flash, as2. problem parsin. seems cant out want object. 1 level object , below can see how looks filled dummy text. my json object looks this: [ { data }, { data } ] now, how parse in as2? , possible? have done in as3 before. think need sort of code how acually load , parse in as2 you try (just tested as2, , seems work): http://inner.geek.nz/archives/2007/01/18/loading-json-in-actionscript-2/ http://web.archive.org/web/20111014093347/http://inner.geek.nz/uploads/json.as usage: try { var o:object = json.parse(jsonstr); var s:string = json.stringify(obj); } catch(ex) { trace(ex.name + ":" + ex.message + ":" + ex.at + ":" + ex.text); }

iphone - bad quality image in iOS in GLKit -

Image
i added sprite scene tutorials : http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1 but have bad quality of images files. how fix problems ?? this caused xcode 'compression' of png files, transforms them use premultiplied alpha . you try replace line : glblendfunc(gl_src_alpha, gl_one_minus_src_alpha); which suppose have, mentioned following tutorial, following : glblendfunc(gl_one, gl_one_minus_src_alpha); which allow composite premultiplied alpha image on background image. for more information premultiplied alpha concept, here . if want xcode stop messing png files, can ask stop : how can skip compressing 1 png?

mapreduce - Calculating pagerank in mongodb -

i'm trying run pagerank using mapreduce in mongodb. my documents in format: { "_id" : "u: 10000", "value" : [ [ "u: 10000", "s: 985272", 1 ], [ "s: 985272", "u: 10000", 1 ], [ "u: 10000", "s: 303770", 1 ], [ "s: 303770", "u: 10000", 1 ] ] } now think first step collect links key. have several outbound links per document. (these happen bidirectional). here map , reduce functions: m = function () { (var = 0; < this.value.le...

c - Redirecting one file to another using dup2 and strtok -

i have write program, in need use strtok , dup2 redirect 1 file another, need have user put command cat < file1 > file2, not shell, instead using program. that's why need strtok. , reason program doesn't work because of that, because don't understand how strtok works. found similar program on internet, take ls command , redirect file. that's it. program more complicated. mean, would've been easier in shell cat < file1 > file2, reason want way. so, anyways, here have far (here combined have found on internet had before. had similar user go ls or ls -l. simple stuff. harder, me, @ least.) #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <errno.h> #include <sys/wait.h> #include <string.h> int main() { pid_t pid; char line[256]; char *args[129]; int i; int fd; int status; char *temp; while (1) { printf(">"); if (...

javascript - Make copy of XML page using PHP -

Image
i'm trying use javascript access data http://www.bart.gov/dev/eta/bart_eta.xml , however, found out cannot unless have copy of page on server. how can make proxy page on server exact copy of http://www.bart.gov/dev/eta/bart_eta.xml ? have tried simplexml_load_file , file_get_contents, both functions not give me xml format, give me object(simplexmlelement)#1 (2) { ["channel"]=> object(simplexmlelement)#2 (6) { ["title"]=> string(23) "bart real time eta feed" ["link"]=> string(50) "http://www.bart.gov/schedules/developers/etas.aspx" ["description"]=> string(127) "real time estimated arrivals bay area rapid transit. use subject terms @ http://www.bart.gov/dev/schedules/license.htm" ["copyright"]=> string(86) "copyright (c) 2012 san francisco bay area rapid transit district. rights reserved." ["date"]=> string(10) "07/01/2012" ["time"]=> str...

cakephp - Creating drop down tree in php -

i have table structure following |id| parent_id |name| parent_id referring same table recursively tried create drop-down tree unsuccessful. please tell how create in core php or cake php. this work did far..but give error 'fatal error: allowed memory size of 134217728 bytes exhausted (tried allocate 67025477 bytes) in /viren/webroot/upms/app/controllers/tests_controller.php on line 390'; function admin_takecat(){ $this->layout=false; $this->render(false); configure::write('debug',2); $firstlevel=$this->cats->find('list',array('fields'=>array('category.id','category.cat_name'),'conditions'=>array('category.parent_id'=>0,'department_id'=>9))); $dropbox='<select>'; foreach($firstlevel $id=>$val){ $dropbox.='<option value='.$id.'>'.$val.'</option>'; $count=$this->cats->find('count',array('conditions...

javascript - Validating an e-mail address using regex -

i trying validate e-mail addresses on website , have been trying code demo of how e-mail validation work javascript. trying pass in value of e-mail address entered user validateemail function , print out 'valid' or 'invalid' in div id 'result'. because relatively new javascript, not sure how accomplish , wondering if show me example of how this? <head> <title>practice</title> <script type="text/javascript"> function validateemail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/; return re.test(email); } </script> </head> <body> <form action="post" method="practice.php"> e-mail: <input id="email" type="text" onblur="validateemail(execute(document.getelementbyid('email')...

java - Capture a screenshot and share it with social media -

here excerpt of code. can compile it, program crashes on phone/emulator. bitmap bitmap; view v1 = myview.getrootview(); v1.setdrawingcacheenabled(true); bitmap = bitmap.createbitmap(v1.getdrawingcache()); v1.setdrawingcacheenabled(false); string path = images.media.insertimage(getcontentresolver(), bitmap, "title", null); uri screenshoturi = uri.parse(path); final intent socialintent = new intent(intent.action_send); socialintent.addflags(intent.flag_grant_read_uri_permission); socialintent.putextra(intent.extra_stream, screenshoturi); socialintent.settype("image/png"); anyone know how it? want capture screenshot , let user share if he/she likes to. else work, it's screenshot cannot get. the way screenshot can obtained having direct access frame-buffer @ kernel level, in turn requires rooted access accomplish , pull in data there make graphics screen itself. this requires either modded...

c# - List<string[]> displaying list values -

i have code generates list<string[]> variable can't quite figure out how display in text box properly. list<string[]> test = parsecsv(); (int = 0; < test.count; i++) { console.writeline("i = {0}",i); console.writeline("test[i] = {0}", test[i]); namelist.text = test[i].tostring() + "\n" + namelist.text; } when output test[i] console displays string information correctly, when output test[i] text box get: system.string[] system.string[] system.string[] system.string[] system.string[] system.string[] can tell me i'm doing wrong? this common misconception tostring shows in variety of situations . not magical formatting wizard, if primitive types appear work "as expect". tostring provides reasonable representation of data @ hand. in case of array data, obnoxious , incorrect .net output entire array every tostring call (which debugger makes heavy usage of). imagine 3d array of strings 60x60x10. h...

Extract path in MYSQL -

how retrieve this: 123 this: 123?arg=value#ancor , in mysql; in other words, removing queries , removing anchors url path. example scenario: table1: +----+------+ | id | path | +----+------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+------+ table2: +----+----------------+ | id | path | +----+----------------+ | 1 | 100#anchor | | 2 | 200?arg=value | | 3 | other/300 | +----+----------------+ select * table1 inner join table2 on table1.path = revised_path(table2.path) result: +----+------+----+---------------+ | id | path | id | path | +----+------+----+---------------+ | 1 | 100 | 1 | 100#anchor | | 2 | 200 | 2 | 200?arg=value | +----+------+----+---------------+ update: path numeric, can length. update 2: revised_path() temporary replacement solution i'm looking for. so looks path part of url. php function parse_url trick. $sql = "select * table1 inner join table2 on table1.path = revised_path(table2.pat...

transferring a javascript value to a php variable -

what best way transfer following outputted value php variable? $(document).geturlparam("id"); through ajax post. $.ajax({ type: 'post', url: url, data: data, success: success, datatype: datatype });

scala - how to use applyDynamic on Any objects -

i'm considering using new type dynamic, find obvious use case not implemented. i'm trying create convenience wrappers object-oriented database. suffers casting , usablity issues, because serializes , deserializes objects (it's methods return object). first question: method of database deserializes object of type a. althought has method a() , may know @ given moment, have a, can't call a(), since java sees object. dynamic mechanism try me if "underlying" object has method, or have deal in applydynamic myself? tried out in repl, doesn't seem me. if have check myself, easiest way (using scala's new reflection or not), check if object has method "methodname" , if yes invoke it. scared off https://stackoverflow.com/a/11056410/703862 fall java's reflection, method invocation part quite easily. i come this: scala> import java.lang.reflect.method import java.lang.reflect.method scala> class dyntest3 extends dynamic { | def...

ajax - Stable Spring version release -

right trying research on how stable spring release right now. i'm having problems determining whether current spring release (3.1.1) best choice base architecture. there differences between 3.0 , 3.1? if there impact in terms of coding structure migrating spring 2.0 3.0. have base architecture spring 2.0 , thinking of migrating 3.x integrated ajax support , integrated rest support well. there other perks in migrating 3.x? idea migrate spring 3.0? if yes there drawbacks in migrating version best migrate to? taking time in reading this, have nice day. are there differences between 3.0 , 3.1? http://static.springsource.org/spring/docs/3.1.x/changelog.txt edit: ok, that's technical, try this: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/new-in-3.1.html edit 2: no, not have to use annotations. that's convenience feature mostly. edit 3: in implementing controllers annotation based configurations have xml-schema base...

Custom styling for Bootstrap select -

i find select twitter bootstrap's dropdown ugly, how can deactivate bootstrap select widget? or possible customize way select dropdown looks? you can overwrite css styling adding own example: select { background: #333333; } this basic example example of how can customize own liking.

python - to perform addition operation on forloop.counter in django template -

i want perform reduce value of forloop.counter in django template given condition, possible in django. below demonstrated example {% in item %} {% if forloop.counter0|divisibleby:4 %} start {% endif %} {% if %} item{{ forloop.counter }} {% else %} ######### here want reduce value of forloop.counter 1 ########### {% endif %} {% if forloop.counter|divisibleby:4 %} end {% endif %} {% endfor %} in above code 8 perfect item output be start item1 item2 item3 item4 end start item5 item6 item7 item8 end but suppose item2 none, output start item1 item3 item4 end start item5 item6 item7 item8 end i want print in form of proper ascending order (incremented 1 @ each step) reducing value of forloop each time if condition not satisfied. please don't suggest custom template tag, know , consider last option. i doubt django let mess forloop.counter easily, , wouldn't mess anyway. obvio...

html - white-space: nowrap not working in IE 9 -

Image
i have table white-space set nowrap , columns widths restricted using table-layout fixed. correctly hides long lines in firefox, in ie9 lines wrapping. test case: <table border="1" width=200 style="white-space: nowrap; table-layout: fixed;"> <tr> <td style="overflow: hidden;" width=150>word spaces isnt working in ie</td> <td width=50>100/50</td> </tr> <tr> <td style="overflow: hidden;" width=150>loooooooooooooooooooooooooooooooooooongword</td> <td width=50>550/50</td> </tr> <tr> <td style="overflow: hidden;" width=150>anotherloooooooooooonnnnnnnnnnnnnnnngword</td> <td width=50>660/50</td> </tr> </table> firefox: ie 9: using strict doctype works in ie9, have same result in firefox. i've tested code <!doctype html p...

sqlalchemy - How to instead of 'query.add_column' add field to entity? -

i have sqlalchemy query: >>> items = ( company.query .add_column(address.city) .join(company.address) .filter(and_( ...some filters... )) .all() ) >>> items [(company(6239), berlin), (company(5388), moscow), ...] how can modify query, put address.city entity company? want as: ... >>> items [company(6239), company(5388), ...] >>> items[0].city berlin thank you. i not think can directly in query without modifying model. can achive in code: >>> items [(company(6239), berlin), (company(5388), moscow), ...] >>> # set company >>> (_company, _city) in items: _company.city = _city >>> # remove city attribute >>>> items = [_company (_company, _city) in items] >>> items [company(6239), company(5388), ...] >>> items[0].city berlin

Retrieve XMl Data Using Java -

i new java , xml parsing. requirement take xml file , store xml file's data in database in table , columns format using java. tried in google right solution it. helpless. till did is, can xml data dynamically , store either tag names or values. req take tag names once column names , data related particular column in row format can please correct code. <?xml version="1.0"?> <company> <staff> <firstname>yong</firstname> <lastname>mook kim</lastname> <nickname>mkyong</nickname> <salary>100000</salary> </staff> <staff> <firstname>low</firstname> <lastname>yin fong</lastname> <nickname>fong fong</nickname> <salary>200000</salary> </staff> </company> java code import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.x...

javascript - updating property method by variables -

i wanna change object's property via method called code: map = map || { level: 0 updateproperty(property, value){ if (this.hasownproperty(property){ this.property = value } } } but when fire code create new property named 'property' in object. wanna treat 'property' variable, not new property! you want (square brackets this[property] = value; ) var map = map || {}; map = { level: 0, updateproperty(property, value) { if (this.hasownproperty(property)) { this[property] = value; } } };

tcp - Connect socket using secondary IP address -

not long ago, able connect given destination address either primary or secondary ip address on given interface following steps. add secondary ip address given interface using ip addr add ... , bind socket primary or secondary address, desired, connect destination ip address using primary or secondary address, bound in #2. i upgraded machine linux 3.3.6 , no longer works, don't remember last version tried on working. know how same kind of thing in newer kernels? verified same code on 2.6.23 on different machine. update 2 seems related nic driver. 3.3.6 , 8139too , fine. same machine, using different nic , via-rhine , problem shows up. here's happens when run code (source @ end) on 3.3.6 (packet capture output tshark running in background): $ ./bind_connect 10.0.1.124 10.0.1.120 bound socket: 10.0.1.120 [10.0.1.120->10.0.1.124] # wrong source ip (should use 10.0.1.120 bind) # | # v $ 121.051052 ...

problems with jquery $.get -

Image
it not first time use $.get function, time dont know why not working function test(tid) { alert("1"); var ttt; alert("2"); var ddd; alert("3"); $.get("demo_ajax_load.txt", function(result){ alert("4"); }); } demo_ajax_load.txt text file content is: welcome i getting alert 1,2,3 not showing 4th alert message. looks normal here, wrong simple function? thanks it have nothing wrong long not testing locally. if you're using google chrome (i'm using version 20) , open console (press f12 ) , see error: origin null not allowed access-control-allow-origin. in mozilla firefox , [object xmldocument] but if remotely (in host), working normally... you can see live demo , open console see output if like. my simple jquery: $.when( $.get("a.txt") ) .done(function(data) { console.log("all done: " + data); $(".txt-from-f...

c# - Merging lists of dictionaries -

suppose have lists of dictionaries ld1 , ld2. both have dictionary objects in common. suppose dictionary object "a" in both lists. want merge list of dictionaries such same object in both lists should come once in merged list. linq's .union should work nicely: onelist.union(twolist) if need list , call tolist() on result.

osx - Error loading texture from file in Java -

i wrote code load textures files. works nicely on windows machines, once sent home work on osx, keeps crashing. simple bit of code: string path = system.getproperty("user.dir") + file.separator + "textures" + file.separator; file file = new file(path + "steel.jpg"); try { shiptexture = textureio.newtexture(file , true); } catch {glexception e) { } catch {ioexception e) { } i following exception: exception in thread "main" java.lang.noclassdeffounderror: com/sun/gluegen/runtime/dynamiclookuphelper at texture init stage, caused by: java.lang.classnotfoundexception: com.sun.gluegen.runtime.dynamiclookuphelper @ at java.net.urlclassloader$1.run why not working? a classnotfoundexception doesn't have code, means class isn't in classpath can because editor doesn't find - http://www.wikihow.com/add-jars-to-project-build-paths-in-eclipse-%28java%29 or because directory structure different in windows...