Posts

Showing posts from May, 2014

mysql - PHP search form -

i new php please forgive if question or problem seem confusing trying create search form has 2 dropdown option: st. peter or jhs. user types in name of professor , choose school professor teach at. form has below <form name=form action="form.php" method="get"> <input type="text" name="find" /> <select name="school[]" > <option value="">school</option> <option value="1">st.peter</option> <option value="2">jhs</option> </select> <input type="submit" name="submit" value="search" /> </form> the form.php script using is <?php $q=$_get["find"]; $s=$_get["school"]; $con = mysql_connect('localhost', 'peter', 'abc123'); if($q && ($s==st.peter)) echo "that professor belongs st.peter h.s"; else{echo "that professor not belong school...

concurrency - Features for profiling concurrent program behaviour in Java -

nowadays there profilers promise profile concurrent behavior of program execution in order understand threaded execution. i collection features useful java profiler concentrating on profiling concurrency only: what i've collected far: construction of waits-for graphs detect potential deadlocks time measurement of accessing resources (data-structures, etc.) show states of every thread (alive, interrupted, dead) which thread called thread accessing shared ressources (wait, blocked, etc.) what ideas have? aiming unveil bad programming habits when dealing concurrency in java. summary statistics each thread: how time spend in each state (running, runnable, blocked etc).

CSS relative positioning -

i want .tag element placed literally on top of img tag. i've tried position: relative it's not quite working i'd to. don't want .tag push image below it. <div class="first center"> <div class='tag'></div> <img src=''/> </div> position: relative on outer div, , position: absolute on two elements div inside. see here explantion of why works: http://css-tricks.com/absolute-positioning-inside-relative-positioning/ live demo: http://jsfiddle.net/xakbp/

language agnostic - Detect if a string was double-encoded in UTF-8 -

i need process large list of short strings (mostly in russian, other language possible, including random garbage cat walking on keyboard). some of these strings encoded in utf-8 twice. i need reliably detect if given string double-encoded, , fix it. should without using external libraries, inspecting bytes. detection should fast possible. the question is: how detect given string encoded in utf-8 twice? update: original strings in utf-8. here as3 code second encoding (unfortunately don't have control on client code, can't fix this): private function toutf8(s : string) : string { var bytearray : bytearray = new bytearray(); bytearray.writeutfbytes(s); bytearray.position = 0; var res : string = ""; while(bytearray.bytesavailable){ res += string.fromcharcode(bytearray.readunsignedbyte()); } return res; } mystring = toutf8(("" + mystring).tolowercase().substr(0, 64)); note tolowerca...

iphone - NSPredicate endswith multiple files -

i trying filter array using predicate checking files ending in set of extensions. how it? would close 'self endswith in %@' work? thanks! nsarray * dircontents = [[nsfilemanager defaultmanager] contentsofdirectoryatpath:documentsdirectorypath error:nil]; nsarray * files = [dircontents filteredarrayusingpredicate: [nspredicate predicatewithformat:@"self contains %@", [nsarray arraywithobjects:@".mp4", @".mov", @".m4v", @".pdf", @".doc", @".xls", nil] ]]; you don't want contains array, want in. ideally want filter path extension. so nsarray *extensions = [nsarray arraywithobjects:@"mp4", @"mov", @"m4v", @"pdf", @"doc", @"xls", nil]; nsarray *dircontents = [[nsfilemanager defaultmanager] contentsofdirectoryatpath:documentsdirectorypath error:nil]; nsarray *files = [dircontents filteredarrayusingpredicate:[nspredicate ...

asp.net - Deploying SharePoint layout ASP .NET assembly into GAC -

i'm rewriting legacy sharepoint application , need figure out how deploy it. application sharepoint solution several features, including webparts , simple web pages code. there webpage designed deployed in layouts subfolder. in production environment, there no codebehind in layouts subdirectory, .aspx file. i understand corresponding codebehind assembly loaded gac. indeed, there. page code doesn't contain <%@ assembly %> directive ask in gac, nor specify fully-qualified name: <%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="badwolf._default" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <!-- --> </html> so how page locate code assembly in production environment? need deploy same code differen...

translation - Auto translating website using Google Translate -

i need find way translate website appropriate language locale settings on users machine. in otherwords germany visits site, locale settings german, nou site displays in german, possible using google translate or there other options available? i know when visit site in language using google chrome, says "this site appears in [drop down languages]. want google translate it?" might have api can per page. however, if site @ professional, should translate site you, google translate fails in embarrassing ways.

oracle - SQL for extract portion of a string -

i have zipcode stored in text field (string) , select last 3 digits of value in select statement. possible? there standard way of doing sql interchangeable accross databases? using in production on oracle, test on interbase (yes, yes, know, 2 totally diff dbs, thats doing) thanks can offer assuming zipcodes have same length, can use substr . if don't have same length, have similar things strlen function. interbase not have built-in substring function, have udf (user defined function) called substr in lib_udf.dll works this: select substr(clients.lastname, 1, 10) clients you declare udf this: declare external function substr cstring(80), smallint, smallint returns cstring(80) free_it entry_point 'ib_udf_substr' module_name 'ib_udf'; oracle have built-in substr function use this: select substr(clients.lastname, 1, 10) clients --jeroen

android - conversion of document text to speech -

i followed following tutroial tts http://android-developers.blogspot.com/2009/09/introduction-to-text-to-speech-in.html but how make work documents want extract text in documents , convert speech , want functionality stop,pause play functions in in media player by documents,i mean word,pdf etc.please tell how extract text these documents in android.i newbie android step #1: "extract text in documents". you, person on planet knows "documents" referring to. step #2: "convert speech" using text-to-speech engine linked above, converting results audio file (see "file rendering , playback" section). step #3: use mediaplayer create own playback activity "stop,pause play functions" see fit.

python - Developing PyPy's Rpython as a general programming language -

is there interest in developing rpython (restricted python) pypy project general purpose programming language? perhaps fork pypy project. such project exist? since programs compiled, 1 contribute modules written in rpython, , compete other python implementations including cpython , pypy. i can't speak else, extremely interested in using rpython general-purpose language. answer other people's questions: why? because cython pain figure out how use. if don't put in lot of tricky type declarations right, don't speedup. rpython, run fast or won't run @ all. using pypy offers speedup, not as rpython. rpython might way super-fast, pythonic code. here's example started. i'm not aware of large projects this, unfortunately.

security - Signed Java Applet prompting for printer access -

i have small java applet custom printing browser. i have signed applet go daddy certificate, still receiving following security warning: == security warning the applet has requested access printer do want allow action? == there checkbox says, "always allow applet run", selecting still causes warning dialog show before print dialog displayed. is there anyway grant access printer without modifying .policy file on client machines or include .policy file in .jar file? thanks! i don't think there other way. had same problem - signed applet printing, annoying dialog. my problem applet executed javascript. according note here , applet executed javascipt behaves unsigned one.

Is unhooking event handlers needed in ASP.NET to prevent memory leaks? -

coming winforms/wpf i've learned hard way not remembering unhook event handlers can lead memory leaks. does apply webapps too? seems when request ends, (non-static) should eligible garbage collection. true? i remember jumping through sorts of hoops ensure events got unhooked when object goes out of scope, multi-threading going on ensure responsive ui. of still in webapp or 1 of luxuries of working (mostly) restful model? i don't think need worry unhooking events. correct non-static gets queued garbage collection. main thing worry cleaning unmanaged code. make sure wrap implementing idisposable in using{} block (or manually call dispose() on it).

tortoisesvn - SVN folder does not have green icon in Windows7 -

i setting repository, , reason when create repository, directory not change displaying common svn checkbox. are there common well-known mistakes cause that? i using windows7 thanks, alex not sure if that's problem, there common problem tortoisesvn overlay icons not showing in windows 7: tortoisesvn icons not showing under windows 7

What's wrong with this C++ program? -

i have header file , and .cpp file passing value function gives me error main.c #include "me.h" #include <iostream> #include <sstream> #include <string.h> using namespace std; int main() { me("http"); } me.h #ifndef me_h_ #define me_h_ #include <string.h> class me { public: me(std::string u); virtual ~me(); }; #endif /* me_h_ */ me.cpp #include "me.h" #include <iostream> #include <string.h> using namespace std; me::me(std::string u) { // todo auto-generated constructor stub cout << "help"; } me::~me() { // todo auto-generated destructor stub } i getting error in file included ../src/me.cpp:8: ../src/me.h:13: error: expected ‘)’ before ‘u’ ../src/me.cpp:12: error: prototype ‘me::me(std::string)’ not match in class ‘me’ ../src/me.h:11: error: candidates are: me::me(const me&) ../src/me.h:11: error: me::me() make: *** [src/me.o] error 1 ...

iis - Null JSON in getJSON response from IIS6, not IIS7? Using MVC2, jQuery, Ajax -

new here. i've searched quite bit working solution problem, though have found posts promising titles, none of solutions have worked. i deploying mvc2 web app client's server. i did development on win2k8 server, running win2k3 sever. the app's purpose receive record id information http parameters, check in database status of given record or records, , return status information simple string such "completed" or "incomplete" in json format. this getjson code works fine in development environment. inexplicably me, on client's server, getjson request receives null response application. there no cross-domain action afaik... result same client's server or machine via vpn. in mvc model's json code, common solution people add "jsonrequestbehavior.allowget" attribute json result being returned. did long before trying deploy it, , said, has worked fine in dev environment. using firebug, have watched same request url sent bo...

ruby - Rails 3 validates inclusion of when using a find (how to proc or lambda) -

i've got project there currency , country table. there's price model requires valid currency , country code, have following validation: validates :currency_code, :presence => true, :inclusion => { :in => currency.all_codes } validates :country_code, :presence => true, :inclusion => { :in => country.all_codes } the all_codes method returns array of currency or country codes. works fine long no codes added table. how write result of currency.all_codes either proc or inside lambda? tried proc.new { currency.all_codes } -- error object doesn't respond include? note: answer true old versions of rails, rails 3.1 , above, procs accepted. it must not accept procs. can use custom validation method same thing: validate :currency_code_exists def currency_code_exists errors.add(:base, "currency code must exist") unless currency.all_codes.include?(self.currency_code) end

Python Function Argument -

i having 2 issues code - not sure how link populatearray function main function; i'm not sure argument need pass also, have been having trouble file path of file opened - path correct , file exists data in. here code: network = [] def populatearray(): file = open('theroute.txt', 'r') network = [] line in file: network.append(line) print "network = " print network file.close() def main(): if __name__ == "__main__": populatearray() any appreciated! thanks replies - code looks above, when remove def main(): following error: file "populatearray.py", line 18 if __name__ == "__main__": ^ indentationerror: unindent not match outer indentation level remove line 5 (the "network=[]") , def main() don't need. , pass network argument populatearray function , work. network = [] def populatearray(network): ...

c# - How do I create two associated entities at one time with EF4 Code-First -

so have 2 entities, post , posthistory . whenever create or edit post, want create exact copy of posthistory log changes made post. post entity has following definition: public class post { public int id { get; set; } public string text { get; set; } public virtual icollection<posthistory> posthistory{ get; set; } } the problem comes when create first post . example, if try this: post post = new post { text = "blah" }; context.posts.add(post); posthistory history = new posthistory { text = "blah"}; context.posthistory.add(history); post.posthistory.add(history); that fail because since both post , history new entities, post.posthistory null due not having been initialized yet. way can see first commit post db, commit history database, don't see why performing 2 separate inserts should necessary this. if have constructor initializes icollection list<t> works fine, forcing implementation list<t> causes othe...

UML Model and Diagram definition, where? – XMI has them, Standards not? -

so, i’ve been looking through uml 2.3 infrastructure, uml 2.3 superstructure, mof 2.0 , xmi 2.11 standards in search of specification , definition of models , diagrams. i aware models , diagrams , (diagrams show view on model), seeing them in xmi file exported visual paradigm , analysing got bit confused. throughout standards mentioned above specification mentions diagrams , models corresponding meanings, not find defined, nor, important part, how comes in uml metamodel. xmi mentioned above has following structure (heavily pruned): <xmi:xmi xmi:version="2.1" …> <uml:model /> <uml:diagram /> </xmi:xmi> so not find definitions on model , diagram, not find out how many model elements allowed/possible , content may have. same diagrams, although know can 0..* . the easiest way check model use eclipseuml2 editor. not graphical uml tree can create elements directly on xmi model. xmi 2.1 corresponding uml 2.3 , clean. xmi used rsa ib...

How to set up oscommerce Shipping to these settings? -

i need set is: $4.95 flat rate anywhere in us. $11.95 anywhere else in north america. $13.95 anywhere else in world. is possible do? take @ multi geozone multi table shipping mod. http://addons.oscommerce.com/info/2571 if prefer, clone build-in zones mod twice, , apply original us, first clone canada/mexico , second clone everywhere else.

osx - Titanium Developer Crashes on Startup (was fine) -

closed laptop when left work. when got home , opened it, had restarted. when go open titanium developer instantly crashes. so can't open now. ideas on how debug or figure out going wrong? thoughts of trying see message or detailed error report helpful. i'm pretty new mac world, i'm not sure why computer restarted - there place see events or may have triggered that. couldn't find on forums issue. i experienced same instant crash problem , found post on http://developer.appcelerator.com/question/21121/titanium-crashing-on-startup-on-mac suggests running chmod -r g+u /library/application\ support/titanium - far good.

c++ - External IP Address -

possible duplicate: stable way of retrieving external ip host behind nat well, hello again. wondering how external ip address (external since people haves router) of computer? here's 1 way of using user's suggestion ... of course works own ip determine opening command prompt , running ipconfig /all #include <windows.h> #include <wininet.h> #include <iostream> #pragma comment(lib, "wininet") int main(int argc, char* argv[]) { hinternet hinternet, hfile; dword rsize; char buffer[32]; hinternet = internetopen(null, internet_open_type_preconfig, null, null, 0); hfile = internetopenurl(hinternet, "http://automation.whatismyip.com/n09230945.asp", null, 0, internet_flag_reload, 0); internetreadfile(hfile, &buffer, sizeof(buffer), &rsize); buffer[rsize] = '\0'; internetclosehandle(hfile); internetclosehandle(hinternet); std::cout << "your ip address:...

c++ - Advanced QCompleter -

Image
well, looking on qcompleter , it's pretty cool of can see. looked on visual studio 2010 when example: messagebox(hwnd hwnd, shows rectangle (white background, black text) shows messagebox( hwnd hwnd , lpcwstr lptext, lpcwstr lpcaption, unit utype); mean it's highlights position are. here image: other using setcompletionmode 1 of 3 enum options it's quite possible can't achieve without subclassing , implementing own version. qcompleter model parser it's more akin visual studio when type . or -> , pick available method/member/etc on current object.

java socket programming problem (sending and receiving data) -

client has sendpoints() method called other class did not include. anyways, sendpoints() called , sends integers server, receives them , send clients connected server(broadcast). the problem is, clients keep sending integers while server stuck in thread created receiving integers(i think server not reading inputstream). i tried changing stream, tried putting integers in object , send objectoutputstream none of these seems work. need (pointstruct class holds integer values created) import java.net.*; import java.util.*; import java.awt.*; import java.io.*; import javax.swing.*; public class server { private arraylist dataclient; private arraylist messageclient; private serversocket dataserver; private serversocket messageserver; public static void main(string[] args) { server s1 = new server(); s1.start(); } // start running server public void start() { try { dataserver = new serversocket(4999); ...

Can we connect Emacs with Yahoo, Facebook and MSN? -

i wonder, can chatting using facebook,msn , yahoo inside emacs? google bit, , found http://alexott.net/en/writings/emacs-im/emacsyahoochat.html , there's no download available. what solution it? thanks. there's great support xmpp in emacs . facebook has xmpp support. there gateways others xmpp. i doubt anyone's put lot of effort proprietary protocols.

asp.net mvc 3 - Ninject model validator causing issues in medium trust -

using ninject 2.2 asp.net mvc 3 . i have controller , classes located in external assembly registered loading ninjectmodule said assembly. the models contain validation properties. seems ninject getting security exception when post action done on action takes model validation attributes. below exception: "attempt method 'ninject.web.mvc.validation.ninjectdataannotationsmodelvalidatorprovider.getvalidators(system web.mvc.modelmetadata, system.web.mvc.controllercontext, system.collections.generic.ienumerable`1)' access method 'system.web.mvc.dataannotationsmodelvalidator.get_attribute()' failed." the inner exception states: system.security.securityexception: request failed. however, works fine in full-trust permissions. i attempted create container in main assembly via var kernel = new standardkernel(new ninjectsettings() { usereflectionbasedinjection = true }); but issue still persists.

encryption - Best approach to encrypt username/password and then transfer them to the server in Java application -

what best approach encrypt password entered user @ client side , decrypt @ server in java application.? basically want make sure data entered client secure. regards tarun sapra use ssl. solves problems. if can't use ssl reason might need post more information system can provide more specific advice.

java - uploading of files and images -

i have upload images , pdf files client side server side, using browsing of file. m using jboss,tomcat , apolloclient. how can that?? function , library have refer??? is want? and link on question

Visual C++ 2010, rvalue reference bug? -

is bug in visual c++ 2010 or right behaviour? template<class t> t f(t const &r) { return r; } template<class t> t f(t &&r) { static_assert(false, "no way"); //< line # 10 return r; } int main() { int y = 4; f(y); //< line # 17 } i thought, function f(t &&) should never called it's called t = int &. output: main.cpp(10): error c2338: no way main.cpp(17) : see reference function template instantiation 't f(t)' being compiled [ t=int & ] update 1 know c++x0 compiler reference? i've tried comeau online test-drive not compile r-value reference. update 2 workaround (using sfinae): #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_reference.hpp> template<class t> t f(t &r) { return r; } template<class t> typename ::boost::disable_if< ::boost::is_reference<t>, t...

ios - Convert JSON feed to NSDictionary -

where json_category_data_url_string feed url, returns fine as: [ { "group":"for sale", "code":"ssss" }, { "group":"for sale", "category":"wanted", "code":"swnt" } ] i cannot seem nice nsdictionary (or nsarray ) out of following code: + (nsdictionary *)downloadjson { nsdictionary *json_string; nsstring *dataurl = [nsstring stringwithformat:@"%@", json_category_data_url_string]; nslog(@"%@",dataurl); nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:dataurl]]; nsdata *response = [nsurlconnection sendsynchronousrequest:request returningresponse:nil error:nil]; json_string = [[[nsstring alloc] initwithdata:response encoding:nsutf8stringencoding]autorelease]; nsdictionary *json_dict = (nsdictionary *)json_string; nslog(@"json_dict\n%@",json_dict); nslog(@"js...

c# 4.0 - Loading embedded resource .rtf file into richtextbox on load C# -

ok read loading embedded rtf rich text box , trying when form loads. form not main form, second form loads when control clicked. have on form when loads: private void credits_load(object sender, eventargs e) { assembly creditassm = assembly.getexecutingassembly(); using (stream creditstream = creditassm.getmanifestresourcestream("ydisplayview.credits.rtf")) { creditsrichtextbox.loadfile(creditstream, richtextboxstreamtype.richtext); } } in solution explorer rtf file shows resource , build action set embedded resource. when click button load form, shows expected, nothing happens. contents of rtf doesn't seem show :/ i can assume doing wrong :( any newbie appreciated. i figured out: creditassm.getmanifestresourcestream("ydisplayview.credits.rtf")) needed be: creditassm.getmanifestresourcestream("ydisplayview.resources.credits.rtf")) edit: reason time around can't above code work found 1 did ...

c# - Socket.Disconnect(bool reuse) -

socket.disconnect(bool reuse) according msdn enables program reuse socket. questions are: if decide reuse socket mean reuse same local end point well? preserve port socket or (i don't believe does) save objects resources? if in effect save resources allocated next connection , if send/receive buffers automaticly flush or there way flush them? socket.shutdown(shutdown.both) me on disconnect? in situation use socket.disconnect(false) ? if purpose reuse socket grant me? if reuse = false socket disposed automatically after closing. settings endpoint , buffer sizes not reseted defaults, can change if desire. supose user decides change connection port. need close socket, change port , connect socket again without create new socket , set again. the socket.shutdown disables send/receive/both; not disconnect socket. occurs new incoming/outgoing data buffers flushed normaly. practice call before disconnection ensure data sent , no data being received while disconnecti...

c# - Is this the good pratice to name the namespace according to the directory name -

i have directory structure store source files. practice name naming space according directory structure? like models\model.cs data\data.cs one defined in namespace models 1 defined in namespace data yes, that's typical approach, , it's 1 that's supported tools such resharper. the difference between , java approach don't add directories way down top - default namespace project. example, suppose creating foo.bar.baz.model , foo.bar.baz.data, c# , java solutions might be: c#: foo.bar.baz foo.bar.baz.csproj defining project default namespace of foo.bar.baz model\ somemodel.cs data\ somedata.cs java: src\ foo\ bar\ baz\ model\ somemodel.java data\ somedata.java

c# - CTP5 update cascade -

i need add or update pattern ctp5. assuming model: public class user { public int userid { get; set; } public icollection<address> addresses { get; set; } } public class address { public int addressid { get; set; } public string location { get; set; } } if add new user, coresponding address table populated. if user in db, dbupdateexception. in case want data in database updated new data. how can this? data in database table address addressid location 1 johnplace 2 maryplace 3 jimmyplace the user update has in addresses collection 1 item addressid:2, location=georgeplace. id=2, in db there record location=marryplace. want georgeplace overwrite marryplace. i cannot have address not assigned user i create user like: var user=new user(); user.id=getuseridfromservice(); foreach(var address in getaddressesfromservice(user.id)){ user.addresses.add(address); } context.users.add(user); cont...

scripting - get specific file from sorted files -

meybe simple im new on unix. i have directory /home , in directory have 5 files ; /home/file1.csv /home/file2.csv /home/file3.csv /home/file4.csv /home/file5.csv i want display file , must ordered date , can display example 3.file order .. i'm not sure if want ordered newest first or oldest first. ls -t | head -3 will print newest 3 files, and ls -rt | head -3 will print oldest 3 files. and if want sort result in access time (the commands above sort them in modification time), please use following commands respectively. ls -u | head -3 ls -ru | head -3

sencha touch - Showing a carousel from a nestedList - possibly using handler? -

i have nestedlist - when final item, call handler swaps panel carousel. please see - http://test.miaduk.com/mobile/tle/ unfortunately can't seem handlers work on nested items , can not think of way. i'm still beginner in sencha, appreciated. thank you! see code: ext.setup({ icon: 'icon.png', tabletstartupscreen: 'tablet_startup.png', phonestartupscreen: 'phone_startup.png', glossonicon: true, onready: function() { /*data store *********************************************************************************/ var data = { text: 'categories', items: [{ text: 'core skills/personal development', items: [{ text: 'fishbone diagram', leaf: true },{ text: '5 whys technique', leaf: true },{ text: 'smart objectives', leaf: true },{ text: 'circle of influence', ...

uml - How would you design a database for storing mazes and games played on the same mazes? -

Image
i have assignment design database storing mazes , games played on these mazes. a maze grid, containing prizes , traps. assignment isn't more specific: asks find kind of general rules express events occur in game , rules these events. i've put down simple conceptual schema of it: do think that, based on description of assignment, solution? how can improve it? so maze grid, each node containing data. each node contains several things: 1) list of links other nodes 2) list of items available @ node everything else can expressed those. that suggests table maze, containing basic data maze id, name, description, etc. there's table node, containing data node. id, name, coordinates, , maze_id 3rd item, id, item_name, node_id, item_type, , maybe other things. to speed lookup operations, might want link table maze_node containing maze_id , node_id foreign keys both tables, , node_item table node_id , item_id fields. other columns , tables may needed hold inf...

java - Accessing Spring Session scoped Proxy Beans -

i'm developing web-app using struts 2 spring 3 backend. i'm using spring aop:proxy beans handle session beans rather struts 2 sessionaware interface. working fine until have action running under struts execandwait interceptor. because interceptor in effect runs action under seperate thread, when come try , access proxied session bean, beancreationexception/illegalstateexception. there "spring way" can hold of session beans in scenario? regards from execute , wait interceptor documentation important : because action running in seperate thread, can't use actioncontext because threadlocal. means if need access, example, session data, need implement sessionaware rather calling actioncontext.getsession(). the problem session scoped-beans depend on thread-local attributes set requestcontextlistener or requestcontextfilter . latter allows set interesting threadcontextinheritable flag... if execandwait interceptor creates new thread per every ...

.net - how to save image in database -

fileupload img = (fileupload)uploadimg; byte[] imgbyte = null; if (img.hasfile && img.postedfile!=null) { httppostedfile file = uploadimg.postedfile; imgbyte = new byte[file.contentlength]; file.inputstream.read(imgbyte, 0, file.contentlength); } **strong text** here want save image in database . want convert image byte array. wrote above code. here if condition not executed assuming have file upload control on page: <asp:fileupload id="uploadimg" runat="server" /> <asp:button id="uploadbutton" runat="server" text="upload" onclick="uploadbutton_click" /> the following should work: protected void uploadbutton_click(object sender, eventargs e) { if(uploadimg.hasfile) { byte[] imgbyte = uploadimg.filebytes; string filename = path.getfilename(uploadimg.filename); // todo: save image databa...

css - Is it possible to have a table with in a <td> but not constricted to that td's width -

i want table inside <td> , don't want resize <td> . want on flow next <td> on right not not resize parent <td> . i'm putting inside <td> move when screen resized. try css code on nested table: position: absolute; top: 0; left: 0; the parent td should have: position: relative; but again, playing tables not recommended... may need nest table in div because positionning tables , td tricky.

c++ - Static variable in a Header File -

static variable has file scope. have 2 following files: file1.h file1.cpp file2.h file2.cpp i have declared static variable static int var1 in both header files. both file1.h , file2.h included in main.cpp file. i did since static variable have file scope won't conflict each other. after compilation found showing conflict. now static variable behaving extern variable. on other hand if declare static variable in both .cpp files, compiles well. i unable understand behavior. can body explain how scope , linkage working in scenario. static variables local compilation unit. compilation unit .cpp file contents of .h file inserted in place of each #include directive. now, in compilation unit can't have 2 global variables same name. what's happening in case: main.cpp includes file1.h , file.h , , each of 2 headers defines own var1 . if logically these 2 distinct variables, give them different names (or put them in different namespaces). ...

Book recommendation - Parallel programming for C# .NET 4.0 -

Image
i'm looking book contains information following topics: thread synchronization methods parallel extension asynchronouse programming (invoke, begininvoke, backgroundworker, threads, ...) i've knowledge these topics i'll refresh these in deep , focus on c#. the book recommendations should c# / .net 4.0 (not java) , in english or german. thank guys. danny i think parallel programming wiht .net you're looking for. you can read online in msdn library available hardcopy. it has plenty of samples (that can reused easily) in c#, vb , f# . to read more f# versions, can read my blog post series

How to i change the time stamp using php mysql -

my friend using phpfox social network. intergrating phpfox own application. in phpfox site using time stamp 1297503935 (db data type : int(10) ).we wre not able find way ther using num time stamp . there way change integer normal time stamp. check documentation php date $timestamp=1297503935; date ( date_rfc822 , $timestamp );

java - Is RMS only temporary storage? -

is record management system in j2me temporary storage system? vanish after application closed? rms storage concept using in j2me. not temporary storage. permanent storage while deleting application or rms. and 3rd party databases available j2me. see list .

flash - Post photo to Tumblr with AS3 (Error #2101 decode()) -

i'm trying post photo tumblr.com flash results in error #2101 error #2101: string passed urlvariables.decode() must url-encoded query string containing name/value pairs this code i'm using: ( actionscript3 ) import com.adobe.images.pngencoder; import flash.display.bitmapdata; import flash.display.movieclip; import flash.events.event; import flash.events.securityerrorevent; import flash.events.ioerrorevent; import flash.net.urlloader; import flash.net.urlloaderdataformat; import flash.net.urlrequest; import flash.net.urlrequestmethod; import flash.utils.bytearray; // var myloader:urlloader; myloader = new urlloader(); myloader.dataformat = urlloaderdataformat.variables; // var urlvars:urlvariables = new urlvariables(); urlvars.email = "***@*****.de"; urlvars.password = "*****"; // urlvars.type = "photo"; // var b:bitmapdata = new bitmapdata(mc.width,mc.height,true); b.draw(mc); var png:bytearray = pngencoder.encode(b); // urlvars...

Android to Bada -

is possible convert android app bada os? do know converter or else or should written bada sdk again? thanks in advance currently impossible port bada applications on android , vise-versa there few exceptions. if making widgets bada os, can strait away run on samsung's android devices. (with minor packaging modifications) you can straight away port code have written in android's ndk bada... limited libs (not gui) if game developer, suggest use air play sdk, can port android bada , vise versa few clicks.

extract the first word from a string - regex -

i have following string: str1 = "cat-one,cat2,cat-3"; or str1 = "catone,cat-2,cat3"; or str1 = "catone"; or str1 = "cat-one"; the point here words may/may not have "-"s in it using regex: how extract 1st word? appreciate on this. thanks, l it's pretty easy, include allowed characters in brackets: ^([\w\-]+)

ios - Does Apple accept apps with an embedded browser using UIWebView? -

can tell me if apple accepts application opens embedded browser of functionality living on web application on internet? i have read contradicting opinions on this, , have seen several apps seem use embedded browser main functionality of app. still couldn't confirm this. this way correct problems on application functionality on server no need submit version of app, while keeping ease of release through app store , home screen shortcut. thanks! i can't exact quote guidelines, know cordova apps allowed, , updating web files dynamically without going through new native app version allowed, long as: * updated code runs safari webkit engine (true cordova) * main functionality of app not changed

jQuery $.get doesn't put out any data -

what i'm trying catch data file , insert file's (the 1 that js in) div. won't work , can't seem find failure in here. googled it, gave me no answers. suggestions? jquery: $(document).ready(function(){ $("li#twitter-widget a").click(function(event){ $('<span class="loading">lade inhalte</span>').appendto("div#news-widget"); $.get("widgets/twitter.widget", function(data){ $(data).find("div.twtr-doc").appendto("div#news-widget"); alert( data ); $('span.loading').remove(); }); }); }); the twitter.widget http://nopaste.info/1a6c866a15.html the html want data inserted to http://nopaste.info/435800b8f8.html the problem alert(data) doesn't put out anything. jquery injects scripts retrieved via ajax dom , removes them "data". since "twitter.widget" nothing more 2 scrip...

android - Remove from launcher BUT keep enabled / startable -

i tried coding it, tried solving google , stackoverflow, nothing found :=) else has better idea, im not sure if right: i have 2 applications: ad (main app) / adfree-pro (just license starts ad app without ads ;p) so the problem is, want have pro version (with pro icon) in launcher, starts normal-ad app, (the normal ad-app) not in launcher. i tried removing ad-app launcher (which due research should remove launcher) pkgmgr.setcomponentenabledsetting(new componentname(package_name, package_name + ".main"), packagemanager.component_enabled_state_disabled, packagemanager.dont_kill_app); which results to: icons in launcher correct ;) but application can't found on phone, launched, started, not launcher pro activity shortcut. seems there (shortcuts can created) crashes activity exception when try launch it. 02-18 14:38:59.237: error/androidruntime(9941): caused by: android.content.activitynotfoundexception: unable find expli...

What's the difference between XHTML and DHTML? -

reading both separatedly, looks same, html+xml+javascript. what's difference between then? there any? xhtml w3c standard, form of html strictly conforms xml. dhtml largely deprecated term (it short 'dynamic html') introduced when first static web sites started introducing client side scripting make page more 'dynamic'. nobody talks in terms of dhtml more (the term got superseded 'ajax', , 'web 2.0', , 'web app')

playframework - Play Framework: caching on templates -

i'm using play framework (v1.1.1) , have doubt #{cache} tag. i suppose question "when should use it?" think it's quite generic. so besides that, know if has checked behaviour javascript. understand cache output of other tags embedded in body, cache javascript? more specifically, if include script tags reference external resources (like cdn), file cached or tag? the purpose of cache tag cache output server sends client. javascript, images , other information contained within code sent client side not cached, unless told headers set in tag of html. by default, play (if extend main.html) not specify cache-control headers, therefore scripts cached based on browsers standard caching policy. should "no-cache" according http spec, doubtful of whether case.

java - FOP Driver Configuration same as FOPFactory -

i using fop embedded using driver follows driver driver = new driver(); driver.setrenderer(driver.render_pdf); driver.setinputsource(new inputsource(new fileinputstream(tempout))); file tempfile = file.createtempfile("w2p", ".pdf"); fileoutputstream pdfoutput = new fileoutputstream(tempfile); tempfile.deleteonexit(); driver.setoutputstream(pdfoutput); driver.run(); but have access configuration settings programatically output resolution have produce multiple resolution files 72dpi 150dpi 300dpi way can find of doing changing fopfactory follows fopfactory fopfactory = fopfactory.newinstance(); outputstream out = new bufferedoutputstream(new fileoutputstream(new file("c:/temp/myfile.pdf"))); fop fop = fopfactory.newfop(mimeconstants.mime_pdf, out); transformerfactory factory = transformerfactory.newinstance(); transformer transformer = factory.newtransformer(); // identity transformer source src = new streamsource(new file("c:...

asp.net - UserControl Raise Events -

i add onfocus event web user control (.ascx) expection raise event when gets focus doesn't. not intended work way , how can raise event? here sample below, doesn't work. <%@ control language="vb" autoeventwireup="false" codebehind="webusercontrol1.ascx.vb" inherits="raiseeventusercontrol.webusercontrol1" %> <div style="padding: 5px; background-color: #c0c0c0"> tb1: <asp:textbox id="textbox1" runat="server"></asp:textbox> <br /> <br /> tb2: <asp:textbox id="textbox2" runat="server"></asp:textbox> </div> <%@ register src="webusercontrol1.ascx" tagname="webusercontrol1" tagprefix="uc1" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml...

c# - Outlook Add-in,group emails based on color category -

i need set sub folder group property through c# outlook add-in code basically, got mails in folder different color categories.i need sort them through code initially thought of sorting: microsoft.office.interop.outlook.items oitems =m_outlook.inbox.items; oitems.sort("[categories]"); dosnt work... :( pretty lost here also trying bubble sorting : but cant assign mail item next index object objmessage = subfolder.items[counter]; object objnextmessage = subfolder.items[counter + 1]; subfolder.items[counter] = objnextmessage; subfolder.items[counter + 1] = objnextmessage; error: property or indexer 'microsoft.office.interop.outlook._items.this[object]' cannot assigned -- read sorting seemed difficult option thought of grouping . how go ? cheers! rajat sort re-order items in collection won't update view: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._items.sort.aspx you'd need set collection di...

Best practice to isolate data access layer in Ruby/Rails -

so, have ruby on rails application. blank now. , let me right beginning of experience java, might thinking not way ror devs do. :-) what need create data access layer, access users, let userdao.rb using activerecord or directly accessing database or accessing or key-value storage or else can think of. technically, don't have interfaces in ruby, can make userdao.rb "have" implementation (basically, talking composition), may need, userdaoactiverecord.rb or userdaomongo.rb or else that. userdao.rb call methods of implementation , that's it. should easy switch between implementations. while sound possible solution, looking forward hear best practices problem in ruby world. thanks! you have ruby class other activerecord (which pointed out object relational mapper, has no separate data access layer). you might want at: http://sequel.rubyforge.org/ you create class, person, contains methods use instance of sequel talk database. this, untested cod...

.net - Allowed character for SQL Server CE password? -

in web application develop generate sql server ce database files , generate passwords. passwords generated using system.web.security.membership.generatepassword(). i assumed generatepassword generated suitable password strings since uses letters, digits , symbols. on http://msdn.microsoft.com/en-us/library/aa257373(v=sql.80).aspx find vague statement sql server ce passwords "can contain letters, symbols, digits, or combination." but today password generated made impossible create database because connection string apparently had invalid characters. "&" precise. i've searched net complete list of characters make white-list cleaning function, cannot find such info. does have such list of valid characters sql server ce passwords? i ended having make own simple password generator. blogged here looks have xml issue. xml (or web.config) special characters are: quot " amp & apos ' lt < gt > also, if used...

Java - Converting from string to generic type -

in c# this public static tconvertible changetype<tconvertible>(object value) tconvertible : iconvertible { try { if (value == null) return default(tconvertible); return (tconvertible)convert.changetype(value, typeof(tconvertible)); } catch (system.formatexception) { return default(tconvertible); } } is there way similar in java? using android sharedpreferences , trying wrap management class around it. rather using getstring , getint , getlong , etc, i'd pass in value, store string, , convert on it's way out. i believe isn't possible due java's implementation of generics , whole type erasure issue wouldn't know tconvertible @ runtime.

keyboard events - Python cross-platform listening for keypresses? -

this question has answer here: python read single character user 17 answers i need listen keypresses in python terminal program without pausing execution raw_input . i've seen people use few windows specific ways of listening keystrokes , i've seen people use large modules tkinter , pygame want avoid. is there lightweight module out there cross platform (at least ubuntu, windows, mac)? or there way use event system tkinter, pygame, etc...? if not, how should approach tackling this? first thought redirect stdin process , keep checking see if contains 1 of event keys. edit thank @unutbu taking time mark question 3 years old , answered duplicate of question answers not apply question because asked non-blocking solution. i don't know of cross-platform lightweight module listens keypresses. here's suggestion in case want implement simple...

oracle - SQL Query to get most populated ZIP code for a CITY in a STATE from my existing table with data -

i have table 'people' these columns : id, fname, lname, addr, city, state, zip in oracle 9.x i want populated zip code per city per state i wrote query: select city, state, zip, count(*) people group city, state order count(*) but gives me multiple rows city state, (made up):- city -- state -- zip -- count(*) city0 -- st0 -- 32111 -- 50 city1 -- st1 -- 11223 -- 100 city1 -- st1 -- 11225 -- 90 city1 -- st1 -- 11226 -- 50 city2 -- st1 -- 11255 -- 70 city3 -- st2 -- 55443 -- 60 i tried having clause like: having count( ) = max(count( )) got error message : nested having clause deep or somethig (oracle 9.x) i want top row :- city1 -- st1 -- 11223 -- 100 city1 - st1 rows, other rows there 1 row per city per state remain same. wanted output:- city -- state -- zip -- count(*) city0 -- st0 -- 32111 -- 50 **city1 -- st1 -- 11223 -- 100** city2 -- st1 -- 11255 -- 70 city3 -- st2 -- 55443 -- 60 how can achieve this? viewing. ...

Infinite loop with string iterator in C++ -

while i'm willing parse instructions contained in strings, trying clean string it's spaces , tabs character, in order seek instructions in it. unfortunately, loop going infinite loop, , can't find why i'm refreshing iterator on each erasing of char... any please? void myclass::parseinstructions(std::string& line) { std::string::iterator it; (it = line.begin(); != line.end(); ++it) if (((*it) == ' ') || ((*it) == '\t')) = line.erase(it); } the flow of code: it = line.begin(); while (it != line.end()) { if (((*it) == ' ') || ((*it) == '\t')) = line.erase(it); ++it; } correct code: it = line.begin(); while (it != line.end()) { if (((*it) == ' ') || ((*it) == '\t')) = line.erase(it); else // <---- important ++it; } right you'll miss 2 whitespace characters in row, , when final character whitespace you'll move ...

actionscript 3 - AS3 Loader keeps reloading same swf over and over -

i have flash animation made on main timeline of swf couple of layers, functions , keyframe labels. example, have movieclip of star come across screen , triggers dispatchevent main timeline go frame label "next". here sample of actionscript used on main timeline : stars.addeventlistener("fadeintitle",_fadeintitle); function _fadeintitle(e:event):void { title.gotoandplay("fadein"); stars.removeeventlistener("fadeintitle",_fadeintitle); } stop(); that swf alone works perfectly. problem comes when try load swf one. happens loader keeps reloading swf on , over, overlapping them , actionscript that's on main timeline of loaded swf ignored, timeline plays continuously. here code use load swf : import flash.net.urlrequest; import flash.display.loader; import flash.events.event; import flash.events.progressevent; function startload(){ var mloader:loader = new loader(); var mrequest:urlrequest = new urlrequest("fly....

c# - Is it possible to have drag and drop from a ListView to a TreeView in Winforms? -

if it's not possible, can use 2 treeview controls. won't have hierarchy in second treeview control. it's gonna act sort of repository. any code sample or tutorial helpful. listview not support drag-and-drop naturally, can enable small bit of code: http://support.microsoft.com/kb/822483 here's example drag-and-drop listview treeview (it's expert sex change link, wait few seconds , scroll bottom, you'll find answers): http://www.experts-exchange.com/programming/languages/.net/visual_csharp/q_22675010.html update: code link: create listview , treeview. ( in example, listview called listview1 , treeview called tvmain ) on treeview, set allowdrop true. create itemdrag event on listview private void listview1_itemdrag(object sender, itemdrageventargs e) { listview1.dodragdrop(listview1.selecteditems, dragdropeffects.copy); } in example items listview copied 'drop' object. now, create dragenter...