Posts

Showing posts from May, 2011

java - How to run Applets on Android? -

kgs app seems run applets, need figure out how. android not support applets , missing large number of classes needed applets.

configuration - Saving Eclipse Desktop View Arrangement -

i have been using eclipse on/off years find views not stick. example see debug , log screen below. place them there , don't stay. switch debugger or close , open , find eclipse has no memory of view arrangement established. question this, once desktop arranged way want it, how save view configuration in reliable way can go it. seems basic never clear me how can done or if can done. find myself rebuilding bottom row of views way want it. how can save view configuration? in particular, see debugger window in java perspective walk thru. don't want other debugger stuff example. thanks

php - Images not saved when saving a web page ! -

i building web site using php. i'm using zend framework on apache server. www folder structure following: +www | |_+css | | | |_images | |_js | |_images now problem whenever save page images inside 2 image folders(1 inside www , other inside css) aren't saved. when explore saved page using firebug find css of div referring image inside folder named images (which isn't created). link image ...so can tell me what's wrong ? coz have manually copy 2 images folders saved file every time. assuming mean 'save page firefox's save page option': option broken, , doesn't save everything. there plugin firefox fix this: https://addons.mozilla.org/en-us/firefox/addon/save-complete-4723/

date - Django question: Having a problem with saving -

hello have edit item form. view, @ item.current_item_status_date . def edit_item(request, client_id = 0, item_id = 0): client = none item = none status = none contact = none status_id = request.post.get('status_id', none) contact_id = request.post.get('contact_id', none) save_item = request.post.get('save_item', none) save_status = request.post.get('save_status', none) try: client = models.client.objects.get(pk = client_id) item = models.storageitem.objects.get(pk = item_id) except: return httpresponsenotfound() try: status = models.status.objects.get(pk = status_id) contact = models.contact.objects.get(pk = contact_id) except: pass if request.method == 'post': form = forms.itemform(request.post, instance = item) if form.is_valid() , save_item not none: item.current_item_status_date = date.today() ite...

c# - Which library to use to extract text from images? -

i writing program when given image of low level math problem (e.g. 98*13) should able output answer. numbers black, , background white. not captcha, image of math problem. the math problems have 2 numbers , 1 operator, , operator +, -, *, or /. obviously, know how calculating ;) i'm not sure how go getting text image. a free library ideal... although if have write code myself manage. try post regarding using c++ google tessaract ocr lib in c# ocr tesseract interface

Android Gallery async image load -

is possible use async image loader project http://open-pim.com/tmp/lazylist.zip gallery widget? tried: public view getview(int position, view convertview, viewgroup parent) { imageview imageview=new imageview(activity.getbasecontext()); imageloader.displayimage(urllist.get(position), activity, imageview); imageview.setscaletype(imageview.scaletype.fit_center); imageview.setlayoutparams(new gallery.layoutparams(150, 150)); return imageview; } but had no effect. you must tag image views appropriately asynchronous task can update them once images retrieved cache or network: imageloader.displayimage(urllist.get(position), activity, imageview); imageview.settag(urllist.get(position));

jquery - Use Ajax or Attributes for Images -

what better dynamically loading images- using ajax function or changing image's src attribute desired link? please supply snippet of code answer. thanks depends on definition of "better," since javascript doesn't deal binary streams, i'd recommend "changing image's src attribute" option. var mysource = '/path/to/image.jpg'; var img = new image(); img.src = mysource; // or $('#someimageid').attr('src', mysource);

javascript - Handle submit of a form that inside of a included jsp with jQuery? -

i use: ... $('#form').submit(function(e) { ... <div id="list"> <jsp:include page="list.jsp" /> //form here </div> ... to handle form's submit , works. can handle form's submit. however moved form list.jsp think can't recognize inside of jsp file can't handle form's submit. want ability within list.jsp too. what should do? based on code provided, looks trying attach event form before it's rendered. wrap event binding in onready function. $(function(){ $("#form").submit(function() { ... }); }); if doing, make sure form rendered jsp include has id="form" .

iphone - setting ivar by super -

my interface file: @interface secondviewcontroller : uiviewcontroller <uitableviewdelegate, uitableviewdatasource> { id delegate; iboutlet uitextfield *textfield; nsarray *list; nsstring *label1; nsstring *label2; uitableview *tableview; } and implementation of file inherit secondviewcontroller - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [super setlabel1:@"something"]; [self.navigationcontroller popviewcontrolleranimated:yes]; } but can see in debugger label1 still nil. knows, why? edit so didn't enough enunciate. yes, when set ivar in inherit class, nslog shows correctly set, when return superclass ivar in nslog shows nil it means have not allocated label , set frame it. edit sorry missed that, have created test app, it's working fine. can download code here ignore file names. in hurry.:)

php - mysql_real_escape_string shortcut -

i have array around 10 key values. best way add mysql_real_escape_string of them ? $escaped_array=array_map('mysql_real_escape_string',$array); look @ array_map

gallery file upload problem php -

i have script: if(($_post['number2'] && !$_post['button_add']) || ($_post['number2'] && !$_post['button_add_gal'])) { $num=$_post['number2']; for($p=0; $p<$num; $p++) { if ($_post['page']=='news') { $dir = '../images/news/'; // Директорията в която ще се записват файловете } if ($_post['page']=='gallery') { $dir = '../images/gallery/'; // Директорията в която ще се записват файловете } $name[$p]='gal_'.$_files['file']['name'][$p]; move_uploaded_file($_files['file']['tmp_name'][$p], $dir.$name[$p]); $filename[$p] = $name[$p]; if ($_post['page']=='news') { createthumb(...

c# - Enum to Drop Down Box to method -

basically, best way of doing this? i have enum has possible resolutions , want them displayed on drop down combobox. so far, found bind enum combobox like: combobox2.datasource = enum.getnames(typeof(resolution)); however, in method, have: public void testmethod(resolution res){} and can't think of way convert back. thinking of changing method use string, have case or if s in method convert enum. in addition, ideally want of names have spaces. have read [description("description spaces")] think gets applied on tostring. even if sort of loop , add each item box via tostring, still return string. i not sure how proceed other dump enum , go different approach. i wondering in similar situation, do? i use lookupedit instead, , tie enum value key , enum.getnames(typeof(resolutions)); displayed value on edit. when user selects item actual value instead of name.

Ruby: Alternative to openssl for HTTPS and SSL communications -

i'm connecting government web services on rails application, using savon library. however, web services hosted on looks poorly configured machine, , openssl library refuses work them. since java , .net clients working fine, started alternatives. i've changed ruby runtime ruby enterprise edition jruby, not use openssl libraries (it 'forwards' ssl implementation java itself), , worked great. so i'm looking alternative writing ruby web service client using https not openssl. there pure-ruby implementation of tls/ssl? or other library can bind to? i've heard nss, looks it's deprecated. does machine have libcurl installed? following libraries use libcurl (which uses openssl internally) , it's possible libcurl 'well' configured guess. need libcurl header files compile , install these gems though... curb patron typhoeus i've never heard non-openssl ssl/tls implementation ruby.

php - Newline characters not showing up -

i have form escaped input in php in pretty standard way using function: mysql_real_escape_string( string ) but when pull contents out of database, reason, spaces no longer showing, , text gets displayed 1 big block. page has example of in hike description area: http://www.comehike.com/hikes/scheduled_hike.php?hike_id=131 does know why happening , how prevent this? bug or normal behavior? you have learn html basics. linebreaks intended not rendered in html. make visible, have replace them html tag.

uitableview - What's the proper behavior for deleting an iPhone table row with an asynchronous server call? -

i'm working on adding functionality delete row in uitableview on iphone. it's pretty clear how delete row within application, both model , ui. however, deletion requires call made server, can't guaranteed succeed given funkiness can happen mobile connectivity. i'm implementing both swipe-to-delete single rows , switching entire table editing mode. what kind of behavior can used within uitableview/uitableviewcell indicate server call in progress? think can tricky limited real estate. should user permitted delete other rows while delete call in progress? what behavior recommended errors? displaying uialertview? change accessory view of cell uiprogressview show activity taken place , set networkactivityindicatorvisible . since ui interaction happens on main thread allow user delete multiple rows @ same time. send request in background , dont allow user swipe , delete row until operation complete. for quick , dirty solution uialertview work. more ele...

dynamic Memory allocation and free in C -

lets have created string dynamically in program char* s = malloc(sizeof(char) * 128); before start using s, how check whether memory allocated or not? free(s); and before using free() , want check there other pointers pointing s . malloc() returns pointer newly allocated memory or null. so check null char *s = malloc(128); /* sizeof (char), definition, 1 */ if (s == null) { /* no memory allocated */ } else { /* use memory */ free(s); } there other pointers pointing s points if (the programmer) created them.

embedded font won't work in Flex mobile ActionBar -

Image
i've got few fonts embedded , using them in mobile application, , working, except ones try use "actionbar". work everywhere else, , substituting "comic sans ms" "titlecgf" changes comic sans. why won't work custom fontfamily? <fx:style> @namespace s "library://ns.adobe.com/flex/spark"; @font-face { src: url("assets/comic_book.ttf"); fontfamily: comic; embedascff: false; } /****************************** @font-face{ src: url("assets/cgf_locust_resistance.ttf"); fontfamily: titlecgf; embedascff: false; } @font-face{ src: url("assets/cgf_locust_resistance.ttf"); fontfamily: titlecgf; embedascff: true; } **********************************/ .titlestyle{ fontfamily: titlecgf; color: #ffffff; } ...

Ruby !sub returning strange null -

i don't understand result of first line. it's supposed return file name without extension if file has one. can explain me why , tell me more proper here? irb(main):003:0> 'fafeafeafewafeawfeaw'.sub!(/\.[^\.]*$/, '') => nil irb(main):004:0> '.fafeafeafewafeawfeaw'.sub!(/\.[^\.]*$/, '') => "" irb(main):005:0> 'fafeafeafewafea.wfeaw'.sub!(/\.[^\.]*$/, '') => "fafeafeafewafea" it documented sub! (like many of ! string operations) return nil if no change made. from docs performs substitutions of string#sub in place, returning str, or nil if no substitutions performed. instead use regular sub. in case bang (!) unnecessary. 'fafeafeafewafeawfeaw'.sub(/\.[^\.]*$/, '') bang methods the difference between sub , sub! subtle. in ruby in general, non bang (!) version of method safer. since convention bang means method has more side affects. in cas...

javascript - Insert Facebook Like-box into a jQuery modal dialog -

i'm trying use code insert facebook like-box page: <script src="http://connect.facebook.net/en_us/all.js#xfbml=1"></script><fb:like-box href="http://www.facebook.com/pages/xxxxx/xxxxx" width="285" show_faces="true" stream="false" header="false"></fb:like-box> and i'm trying add jquery modal dialog, i'm doing this: <script type="text/javascript"> $(document).ready(function() { $( "#facebook" ).dialog({ autoopen: true, height: 350, width: 350, modal: true }); }); </script> <div id="facebook" title="like us"> <script src="http://connect.facebook.net/en_us/all.js#xfbml=1"></script><fb:like-box href="http://www.facebook.com/pages/xxxxx/xxxxx" width="285" show_faces="true" stream="false" header="false...

Pull value from PHP Cookie Array -

i doing modifications site built in asp. however, mods in php site being moved on language. when user signs in, assigned cookies lkie so: ("mycook")("id")=23 ("mycook")("pref")="html" ("mycook")("job")="janitor" now in asp, these can referenced as: request.cookies("mycook")("pref") which respond "html" is there similar syntax php aware of? this doesn't seem work: echo $_cookie['mycook']['pref']; echo $_cookie["mycook"]["pref"]; i saw solution uses each -> , , can see how work. seems bit of overkill (to loop through values print 1 looking for) , wondering if had ideas? thanks in advance help. in example, cookies stored following string in "mycook" cookie: ["mycook"]=>string(27) "pref=html&job=janitor&id=23" so access need echo $_cookie['mycook'] tra...

c++ - Why is it necessary to do a rebuild after adding a new member variable to a class? -

this morning, in visual studio 2005, tried adding new private member variable class , found giving me sorts of weird segmentation faults , like. when went debug mode, found debugger didn't see new member variable, , giving me strange behavior. it required "rebuild all" in order program working again (and debugger see new member variables had made). why necessary rebuild all? why doing regular build insufficient? i solved problem, feel understanding build process better me in future. let me know if there's more information need. thanks in advance! when add or remove members of class change memory layout of object. if don't recompile breaking odr rule, , segmentation faults effect of that. as why happens, old code might acquiring memory old size, , passing object (without new member) new code access beyond end of allocated memory access new variable. note access specifier not affect @ all, if private class member functions ones accessing ...

c# - how to set a webservice as a scheduled task in windows -

i writing console application in c#. how can set console application run scheduled task in windows? here's how schedule task in windows 7. point task @ .exe of console application.

javascript - Get html element in which a mouse click occurred? -

in javascript i'd able determine element in html page in mouse click occurs. note elements not have event listener attached. basically: cursor somewhere in page, user clicks mouse, capture mouse click event, element in click occurred. possible? one approach thought of x,y coords of click event, iterate through dom getting positions each element, , finding inner-most element contains click event. sounds bit long-winded though - wondering if there way. http://www.quirksmode.org nice website explains lot events. especially question: event properties - html element target of event? . in internet explorer, can element event object event.srcelement [docs] , in other browsers event.target [docs] . also see "safari bug" workaround in example linked (although don't know whether still exist and/or in version of safari).

tsql - Tips on how to optimize and SQL Query -

hi wounder if has tips on how should optimize query? declare @rowstoprocess int declare @currentrow int declare @selectcol1 int declare @datenow datetime declare @macadress varchar(100); declare @port varchar(100); declare @switchname varchar(100); declare @vlan varchar(100); declare @changedmacadress varchar(100); declare @changedvlan varchar(100); declare @table1 table (rowid int not null primary key identity(1,1), col1 int, [macadress] [varchar](255) null, [portname] [varchar](255) null, [switchname] [varchar](255) null, [vlan] [varchar](255) null) insert @table1 select id,macadress,portname,switchname,vlan forwarddatabase set @rowstoprocess=@@rowcount select @datenow = getdate() set @currentrow=0 while @currentrow<@rowstoprocess begin set @currentrow=@currentrow+1 set @macadress = null; set @port = null; set @switchname = null; set @vlan = null; set @changedmacadress = null; set @changedvlan = null; select @selectcol1=c...

linux - How to monitor c++ daemon process? -

i develop 1 daemon tcp server boost asio, want know there daemon manager lib monitor process, if server process dead, manager can restart it you try use powerfull daemontools manage everything. these tools allow in grained monitoring, restarting etc. if don't need power following shell-script enough: while true; $process sleep $sleep_time done this takes care of restarting system when crashes, there not , if need additions out of luck.

python - Graphically represent lists -

is there quick way (without overhead of using gui or graphics module) visually render 2d , 3d lists. for example if have 2d array of zeros , ones, draw black , white grid according array. i looking module allows me these thing in simple ways. similar easiness of matplotlib allows drawing graphs. the command matshow in matplotlib displays matrix: import pylab p p.matshow(p.array([[0,1],[1,1]]),cmap="greys") ; p.show() this work 2d lists. 3d lists, i'm not sure understand how you're planning on visualising them.

Compile another java file from java file -

just out of curiosity. can compile & run java file java program? if so, can send reference knowledge source? take @ java compiler api , this little example.

c++ - Using Boost.Phoenix's operator ->* -

i'm playing around phoenix v3 trying figure out whether should standardize on instead of current mix of bind , lambda. documentation got impression should possible simplify expressions. currently i'm stuck on usage of ->* operator in combination stl algos. following compile (visual studio 2008 sp1) not give expected output: #include <algorithm> #include <iostream> #include <vector> #include <boost/mem_fn.hpp> #include <boost/phoenix.hpp> using namespace std; using namespace boost; using namespace boost::phoenix; using namespace boost::phoenix::arg_names; struct { void f() const { cout << "a"; }; }; struct b { a() { return a(); }; }; int main() { vector<a> va(1); for_each(va.begin(), va.end(), bind(mem_fn(&a::f), arg1)); for_each(va.begin(), va.end(), arg1->*&a::f); vector<b> vb(1); for_each(vb.begin(), vb.end(), bind(mem_fn(&a::f), bind(mem_fn(&b::a), arg1))); return 0; } ...

oop - Is this a good practice to use the "default" Java access to hide classes and methods from client -

in case of classes: if use factory method we'll have return created implementation type of implemented interface. public class factory { public product getproduct() { return new producta(); } } public interface product { } class producta implements product { } to avoid client's ability cast returned product concrete implementation of product{a, b, c... etc.} have to: package client's , factory's code separately (let's com.example.client , com.example.factory ) declare concrete implemantations default ("package") access (visible factory, not visible client) package com.example.client; ... public class client { public static void main(string[] args) { product = new factory().getproduct(); producta = (producta) i; // type of producta isn't visible. } } in case of methods: for example need use same factory hidden method public class factory { public product getpro...

moq - Mocking repository with Entity Framework -

i'm using mog mocking repository linq sql this: public static iproductsrepository mockproductsrepository(params product[] prods){ // generate implementer of iproductsrepository @ runtime using moq var mockproductsrepos = new mock<iproductsrepository>(); mockproductsrepos.setup(x => x.products).returns(prods.asqueryable()); return mockproductsrepos.object; } public interface iproductsrepository{ iqueryable<product> products { get; } void saveproduct(product product); void deleteproduct(product product); } how can change function entity framework if using this: public interface iproductsrepository : ientities{ entitystate getentrystate(object entry); void setentrystate(object entry, entitystate state); void commit(); } public interface ientities{ dbset<product> products { get; set; } } now using dbset . well, since iproductsrepository implements ientities should have public dbset<product...

jQuery .change() with ajax requires refresh for comboboxes -

so code have seems correct; however, comboboxes change after refresh page; not anticipated $.change(). prior current code had 2 separate ajax calls. 1 clear checkboxes, , other set them. worked without page refresh; however, check incorrect boxes (or not check correct ones). i've checked returns php through firebug , results anticipated. the code jquery v1.5.1 because i'm using jquery ui. thanks in advance! php <?php require 'config.php'; if(!empty($_get['usr'])) { //retrieve committee banks list $db->query('select * clas_gov_app_meeting_access_list usr="committeebank"'); $committeebank = $db->get(); //retrieve selected users permissions $db->query('select * clas_gov_app_meeting_access_list usr="'. $_get['usr'].'"'); $accesslist = $db->get(); //echo user permissions echo $accesslist[0]['isadmin']; //combine committebank's , use...

view - How to get total price from estimate to show up in index.ctp using CakePHP -

i have estimates hasmany estimatedetails hasmany items. i'm trying total on estimates index view. the debug of $estimates on index.ctp: array ( [0] => array ( [estimate] => array ( [id] => 1 [name] => city base cinema 10 [employee_id] => 1 [created] => 2011-07-12 18:08:37 [modified] => 2011-07-12 18:08:37 ) [employee] => array ( [id] => 1 [first_name] => edward [last_name] => ramon [phone] => 2106959672 [hourly_pay] => 0.00 [position_id] => 2 [created] => 2011-07-12 17:56:42 [modified] => 2011-07-12 17:56:42 [fullname] => edward ramon [position] => array ( [id] => 2 ...

wcf - DNS Lookup for localhsot failed. No such host is known -

i did break point on method never goes there , if paste url in web browser , hit enter , in firebug: readresponse() failed: server did not return response request. edit: indeed typo, after correcting , still have no response, in ff see response get getcustomer?method=jsonp1299253547713 http://localhost:2344/service1.svc/getcustomer?method=jsonp1299253547713 aborted localhost:2344 ? what may wrong ? end edit i have created wcf services using json padding (http://msdn.microsoft.com/en-us/library/cc716898(v=vs.90).aspx) i have code below using call service, , code in html page withint th same project have created wcf service. $("#btn").click(function (event) { $.getjson('http://localhsot:2344/service1.svc/getcurrentuser?method=?', { }, function (data) { debugger alert(data); }); //return false; }); getting error: dns lookup localhsot failed. no such hos...

Strange Javascript Behavior IE8 with Jquery and Animations -

i working on project right uses accordion style menu, think more of general question reguarding ie8 , jquery .animate(). reason, though animations seem completed (tested callback functions) showing on screen incomplete. seems it's completing because whenever use browser zoom in , out, try highlighting region, or other similar things cause change in appearence corrects (ie end result of animation shown). have tested in latest version of chrome , animation looks perfect, ie issue. i animating property "margin-top" next element distance when element clicked using .animate(), reveiling submenu underneath. when element "opened" in manner , clicked, function called check elements being opened , closes 1 using .animate() also. i've typed description of code because feel issue browser performance (possibly on machine?). has heard of happening in ie8 or below in regaurds animations or jquery/javascript , ie8 in general? in ie8 have manually cau...

url - Multiple mappings in .htaccess files don't work -

i have mapping in .htaccess file rewriterule outdoors/trees/(.*)/(.*) outdoors/trees/tree.php?tree_id=$1 rewriterule outdoors/parks/(.*)/(.*) outdoors/parks/park.php?tree_id=$1 for reason mapping trees works, 1 parks not. trying have url this: http://www.comehike.com/outdoors/parks/park.php?park_id=1 to redirect 1 looks this: http://www.comehike.com/outdoors/parks/3/parkname any idea why isn't working redirects showed above? thanks, alex the last flag may work. rewriterule outdoors/trees/(.*)/(.*) outdoors/trees/tree.php?tree_id=$1 [l] rewriterule outdoors/parks/(.*)/(.*) outdoors/parks/park.php?tree_id=$1 [l] edit: typo in park_id rewriterule outdoors/trees/(.*)/(.*) outdoors/trees/tree.php?tree_id=$1 [l] rewriterule outdoors/parks/(.*)/(.*) outdoors/parks/park.php?park_id=$1 [l]

How to show/hide div from imagemap inside jquery window? -

i have created rollover imagemap show cuts of beef. when user clicks on section of beef, div becomes visible list recipes, via js/popupbox.js script. all basic scripts working here (click on "chuck" section) but first imagemap of cow opens in jquery modal window (i'm new jquery, may referring wrong!). problem: my show/hide div ceases work inside of jquery window . i have considered using tooltip script instead, it's essential user able open/close div clicking, because there recipes , other content inside each div need able click on. any appreciated! you need attach event handler dialog using open event. $('#opener').click(function() { $('#dialog').dialog({ modal: true, height: 550, width: 800, hide: "explode", open: function() { $(this).click(function() { $('#popupbox').show(); }); } }); }); working example: ht...

c# - "Impersonating" session in a web service call -

i trying write web service returns session variables. application calls web service has access the session id of current session. i tried doing creating "aspnet_sessionid" cookie , attaching setting cookie container of proxy class web service not work. did so, protected void callservice(string sessionid) { localhost.authservice auths = new localhost.authservice(); //service proxy class system.net.cookiecontainer cookiejar = new system.net.cookiecontainer(); system.net.cookie newcookie = new system.net.cookie("aspnet_sessionid", sessionid); newcookie.domain = "http://localhost"; cookiejar.add(newcookie); auths.cookiecontainer = cookiejar; string sessiondata = auths.getsessiondata(); the getsessiondata web method returns session data so: [webmethod(enablesession=true)] public string getsessiondata(string sessionid) {return ((string)session["user"]);} should approach work...

c# wpf richtextbox run mouseup -

hey, have richtextbox. add content this paragraph p = new paragraph(); run r; r = new run("[" + user + "]: "); b = system.windows.media.brushes.black; if (user.equals(program.lclient.strusername)) b = brushes.blue; r.foreground = b; r.tooltip = datetime.now.tolongtimestring() + " " + datetime.now.tolongdatestring() + "\nclick whisper"; r.cursor = cursors.hand; r.background = brushes.white; r.mouseenter += delegate(object sender, mouseeventargs e) { r.background = new radialgradientbrush(colors.darkgray, colors.whitesmoke); }; r.mouseleave += delegate(object sender, mouseeventargs e) { r.background = brushes.white; }; r.previewmouseup += delegate(object sender, mousebuttoneventargs e) { tbmess.text = "/w " + user + " "; tbmess.focus(); }; p.inlines.add(new bold(r)); rtbchat.document.blocks.add(p); everything works except can register mouseup/down events. mouse enter , leave work fine, reason can...

.htaccess - htaccess Redirection - domain.com/folder to website.com/folder -

i have thought simple question suppose i'm missing something. i have website 2 domain names associated it. i'd modify .htaccess file trying access particular folder redirected correct domain name. for example: someone accessing www.domain.com/folder/ should redirected www.website.com/folder/ , folder. what have include in .htaccess file this? any appreciated! rewritecond trick. note: didn't test verbatim, it's psuedocodish. rewritecond ${http_host} domain.com [or] rewritecond ${http_host} www.domain.com rewriterule ^folder/(.*)$ http://www.website.com/folder/$1 [qsa,r=301,l] make sure check docs @ http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html flags [qsa] means append query string. note r=301 flag, tell visitor permanent redirect. there many other flags can use...

javascript - Deselect a text box in jQuery after page reload if content is active -

i have google instant style jquery search script queries php file parses results html div. when no query active text box automatically selected when query active want not automatically selected. know possible using .blur(); function, how can make use .blur(); function when query active , page has been reloaded? hope can understand question. my jquery code is: $(document).ready(function () { $('[id^=type_]').click(function () { type = this.id.replace('type_', ''); $('[id^=type_]').removeclass('selected'); $('#type_' + type).addclass('selected'); return false; }); $('#query').focus(); if (window.location.hash != "") { var full = window.location.hash.replace('#', ''); var querytype = full.substring(0, full.indexof("/")); $('#type_' + querytype).click(); } else { $('#type_search').cl...

c# - Fastest way to remove white spaces in string -

i'm trying fetch multiple email addresses seperated "," within string database table, it's returning me whitespaces, , want remove whitespace quickly. the following code remove whitespace, becomes slow whenever try fetch large number email addresses in string 30000, , try remove whitespace between them. takes more 4 5 minutes remove spaces. regex spaces = new regex(@"\s+", regexoptions.compiled); txtemailid.text = multiplespaces.replace(emailaddress),""); could please tell me how can remove whitespace within second large number of email address? i build custom extension method using stringbuilder , like: public static string exceptchars(this string str, ienumerable<char> toexclude) { stringbuilder sb = new stringbuilder(str.length); (int = 0; < str.length; i++) { char c = str[i]; if (!toexclude.contains(c)) sb.append(c); } return sb.tostring(); } usage: var s...

sql - Help! MySQL Query -

i need single line query. must dumb or over-thinking mysql query. please solving following query. lets there 2 simple tables: class , books class id--name-----students 1------kg-----------20 2------grade(3)---25 3------grade(5)---30 books id--classid--title-------------cost 1-----1--------------drawing------------------5 2-----3--------------history--------------------25 3-----1--------------a-to-z--------------------10 4-----2--------------alphabets---------------20 5-----3--------------maths--------------------15 6-----2--------------english-------------------30 lets say: know -----> id of class have find ---> book cost of class. (books each students in class) can have single line of query? try this: in single line: select sum(class.students * books.cost) bookcost books inner join class on books.classid = class.classid books.classid = <class-id-value> group books.classid with formatting: select sum(class.students * boo...

html - Set class with jquery? -

i have javascript function looks this: function updatefilterview(){ if(_extrafilterexists){ if($('#f_showf').val() == 1){ $('#extrafilterdropdownbutton').attr('class', "showhideextra_up"); $('#extrafilterdropdownbutton').css("display", "block"); if($('#divcategoryfilter').css("display") == 'none'){ $('#divcategoryfilter').show('slow'); } return; } else{ if($('#divcategoryfilter').css("display") == 'block'){ $('#divcategoryfilter').hide('slow'); } $('#extrafilterdropdownbutton').css("display", "block"); $('#extrafilterdropdownbutton').attr('class', "showhideextra_down"); return; } } ...

Which functional programming language should I choose to learn? -

having programmed in c++ several years , having read hn several months, learn functional programming language expand/change way think writing programs. functional programming language should choose learn? python, ruby, haskell, others? nice have decent library support can write web based product using , host somewhere :). please advice. it depends on eventual goal is. if you're interested in functional programming own sake, or want grasp of essentials, suggest haskell best bet. environment free download, has near-fanatical community of supporters, , 1 of "purest" functional programming languages, force adjust mindset functional way of programming. functional programming may sound little procedural programming, in reality quite different. i'd recommend picking copy of "programming in haskell" graham hutton, excellent introductory text, downloading environment , having bash. there excellent lectures (based on book) available dr. meijer, hask...

associations - The better way to pass the foreign_key value to the Rails controller -

it's been week since i've began dig deeper in forms , associations , hashes , symbols... seems cannot solve puzzle without . i working on project displaying different galleries content . basic idea when user sees names of galleries (names links ) able click on chosen one. images ,that belong gallery , displayed . on bottom there should link "add image in gallery" . my models : class gallery < activerecord::base attr_accessible :name has_many :pictures end class picture < activerecord::base attr_accessible :image belongs_to :gallery end i have created index on gallery_id 'pictures' table . my big problem appears here , how pass gallery_id controller's action 'new' . i've seen in "agile web development rails" : <%= link_to 'add picture here...',new_picture_path(:gallery_id=>@gallery.id) %> as seems in case foreign_key :gallery_id exposed in url bar of browser . second problem :galler...

android - What does defStyleAttr and defStyleRes in context.obtainStyledAttributes() used for? -

when check quickcontactbadge in framelayout , found following code: public quickcontactbadge(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); typedarray = context.obtainstyledattributes(attrs, com.android.internal.r.styleable.quickcontactbadge, defstyle, 0); mmode = a.getint(com.android.internal.r.styleable.quickcontactbadge_quickcontactwindowsize, quickcontact.mode_medium); a.recycle(); init(); mbadgebackground = getbackground(); } i don't catch meaning of defstyle , 0 parameter in obtainstyledattributes() . have looked reference, still don't know used for. the documentation explains pretty clearly, did see part: defstyleattr attribute in current theme contains reference style resource supplies defaults values styledattributes. can 0 not defaults. defstyleres resource identifier of style resource supplies default values styledattributes, ...

resolving this simple php math -

i trying multiple number of 2 , 3 pls help. thanks for($i = 0; $i <30; $i++) if($i % 2) echo 'number '. $i . ' multiple of 2 <br/>'; elseif($i %3) echo 'number '. $i . 'is multiple of 3 <br/>'; else echo 'number '. $i . 'is multiple of other number <br/>'; try this: if($i % 2 === 0) ... elseif($i %3 === 0) ... basically if modulo 0 means number evenly divisible. however, problem logic number may divisible both 2 , 3 . can fix extracting these out separate if statements: if($i %2 === 0) { ... } if($i %3 === 0) { ... } but sort of breaks last else since cannot fall though anymore. solve setting variable false @ top of loop. if of if statements triggered, set variable true . finally, print "not divisible" message @ end of each iteration if variable still false .

android making a mysql connection and getting some data back -

i need make mysql connection , data back. can in java using code try{ string username; string password; username = tf.gettext(); password = tf2.gettext(); class.forname("com.mysql.jdbc.driver").newinstance(); connection con = drivermanager.getconnection("jdbc:mysql://188.181.248.30:3306/test","simon","123"); int counter = 0; try{ statement st = con.createstatement(); resultset res = st.executequery("select * kunder"); // system.out.println("navn: " + "\t" + "kredit: "); while (res.next() && counter ==0) { string = res.getstring("navn"); string s = res.getstring("kredit"...

How can I export some Blog posts from our Sql Server, to a file? -

we have simple website contains (take pick, example) blog posts / q & questions / whatever. people upload text (single sentences paragraphs .. including white listed/approved html). i need export data .. file / .. can give data else. eg. sample schema id int title varchar(100) uniqueurl varchar(100) content varchar(max) modifiedon datetime publishedon datetime createdbyuserid integer is there way can export data format simple give person import? have no idea import .. guessing csv or excel format might sufficient. said, 1 of fields contains varchar(max) can have paragraphs of text. anyone have suggestions? ##update i've tried tasks -> export data : give me error during final step. error message give's -nothing- happened. total fail :( run sql script -> save results -> .txt or .csv : file created, can't read content .. since 1 of fields varchar(max) user generated content everywhere :( maybe export xml ? what have tried? ...

c# - A bit of confusion regarding ComboBoxes, ValueMember and DisplayMember -

Image
this on windows forms, .net 4.0. public class person { public int id { get; set; } public string name { get; set; } public string lastname { get; set; } public override string tostring() { return string.format("{0} {1}", name, lastname); } } i read on msdn page , if no .displaymember set combobox control, uses default tostring of object, that's reason why i'm overriding tostring method. the result expected: here's how i'm loading data: private void button2_click(object sender, eventargs e) { var people = loadsamplepeople(); combobox1.datasource = people; } private ienumerable<person> loadsamplepeople() { return new list<person>() { new person(){ id = 1, name = "sergio", lastname = "tapia" }, new person(){ id = 2, name = "daniel", lastname = "tapia" } }; } the problem arises, when set .valuemember of control, seems display...

windows phone 7 - how to scroll textblok horizontally in wp7 -

i'm trying scroll large textblock horizontally. tried couple of following way. none of works me. can tell me how it? try 1:- <canvas x:name="mycanvas" height="590" horizontalalignment="left" margin="10,10,0,0" verticalalignment="top" width="700"> <scrollviewer x:name="sv" canvas.left="1" canvas.top="520" horizontalscrollbarvisibility="auto"> <textblock canvas.left="2" canvas.top="522" height="62" name="textblock1" text="textblocktextblocktextblocktextblocktextblocktextblock111111222222" width="590" /> </scrollviewer> </canvas> try 2:- <canvas x:name="mycanvas" height="590" horizontalalignment="left" margin="10,10,0,0" verticalalignment="top" width="700...