Posts

regex - java replaceAll and '+' match -

regex - java replaceAll and '+' match - i have code setup remove spaces in between words of title string formattedstring = unformattedstring.replaceall(" +"," "); my understanding of type of regex match many spaces possible before stopping. however, strings coming out not changing in way. possible it's matching 1 space @ time, , replacing space? there replaceall method, since it's doing multiple matches, alter way type of match work here? a improve approach might utilize "\\s+" match runs of possible whitespace characters. edit another approach might extract matches "\\b([a-za-z0-9]+)\\b" , bring together them using space allow remove except valid words , numbers. if need preserve punctuation, utilize "(\\s+)" capture runs of non-whitespace characters. java regex

c# - ASP, Listview conditional Alert -

c# - ASP, Listview conditional Alert - i'm working listview in want htmltablecell possess onclick property driven codebehind rather javascript.. i'm guessing that's pretty much dream getting obey c# code... anyways want run: protected void show_anm(object sender, eventargs e) { label hiddenc = (label)listview1.findcontrol("hidden"); alert.show(hiddenc.text); } and here's alert class public static class alert { public static void show(string message) { string cleanmessage = message.replace("'", "\\'"); string script = "<script type=\"text/javascript\">alert('" + cleanmessage + "');</script>"; page page = httpcontext.current.currenthandler page; if (page != null && !page.clientscript.isclientscriptblockregistered("alert")) { page.clientscript.registerclientscriptblo...

arrays - What is this pointer in C? -

arrays - What is this pointer in C? - i have seen lot of these types, have no thought means unsigned char somevar[maxlen]; int *ptr = (int *) somevar; can explain? it's somevar interpreted sequence of int 's (or one) through ptr pointer. incrementing ptr 1 time moves pointer sizeof(int) bytes ahead. be aware of endianness when doing conversions these. bytes somevar may need reordering interpreted ints. also create sure somevar of length that's multiple of sizeof(int) , otherwise undefined behaviour when trying access lastly int since partially available. c arrays pointers char

Ruby on Rails Tutorial Chapter 8 Signup Success -

Ruby on Rails Tutorial Chapter 8 Signup Success - i have written users controller , spec tests correctly "successful creation" in user controller next 2 errors: 1) userscontroller post 'create' success should create user failure/error: lambda count should have been changed 1, changed 0 # ./spec/controllers/users_controller_spec.rb:95:in `block (4 levels) in <top (required)>' 2) userscontroller post 'create' success should redirect user show page failure/error: response.should redirect_to(user_path(assigns(:user))) actioncontroller::routingerror: no route matches {:action=>"show", :controller=>"users", :id=>#<user id: nil, name: "new user", email: "user@example.com", created_at: nil, updated_at: nil, encrypted_password: nil, salt: nil>} # ./spec/controllers/users_controller_spec.rb:102:in `block (4 levels) in <top (required)>' the test specs ...

java - Tapestry 5 - communication between two components -

java - Tapestry 5 - communication between two components - i have page in java + tapestry 5 application, contains 2 components - form , grid. form field utilize filter results displayed in grid. form textfield sets value of object on mapped. grid created object a. need send right instance grid component form component. best way this? plain old java way setting object in upper page, there should cleaner way. thinking environment annotation, isn't heavy? public class i1 { @component private wfrformfilter wfrformfilter; @component (parameters={ "wfrdataholder=property:wfrformfilter.wfrdataholder" }) private wfrresulttable wfrresulttable; } public class wfrformfilter { @inject private wfrservice wfrservice; @propperty @persist private wfrdataholder wfrdataholder; @pageattached void pageattached() { if (wfrdataholder == null) { wfrdataholder = new wfrdataholder(); } } @onevent(event...

c++ - What is the difference between -1 and ~0 -

c++ - What is the difference between -1 and ~0 - the title says all: difference between minus 1 , tilda (ones-complement) zero? the question came during give-and-take of best way specify bit mask in bits set. of next better? int func(int value, int mask = -1) { homecoming (value & mask); } or int func(int value, int mask = ~0) { homecoming (value & mask); } are there other uses other way around? update: there has been similar give-and-take on topic on @ stackoverflow.com/q/809227/34509 missed during prior research. johannes schaub pointing out. the first variant relies on 2's complement representation of negative numbers, isn't used. 1's complement can used too... or other encoding. vote sec approach c++ bitmask ones-complement

php - Getting remote file contents after login with cURL -

php - Getting remote file contents after login with cURL - as title suggest, i'm trying content of (several) pages on site requires login. legitimate login , have access content - nil shady's going on. i've searched , found several posters attempting same thing - nil i've found has helped specific issue. i've tried several variations - adding various options followlocation (set true, tried set false); increasing timeout; setting both cookiejar , cookiefile; calling curl_close after login, new curl_init after (before loading target file); using traditional php methods grab file (file_get_contents, etc); explicitly creating cookie file , setting writable; tried , without referer; tried changing referer; tried both http , https protocols; tried calling curl_close 1 time first forcefulness cookie written, running script block 1 time again afterward; etc... no luck. below snapshot of code beingness used (just trying 1 file now). any suggestions appr...