Posts

Showing posts from April, 2013

image processing - skin detection in the YUV color space? -

can perform skin detection using set of rules (things x1 < y < x2 ) the short answer yes , can. however, luminance (y) irrelevant . it's chrominance (cbcr or uv) matters. one of cited papers in area this one (uncompressed ps file). i've implemented , seems work well. update: link above seems have become broken, here bibtex citation of paper: @article{767122, author={chai, d. , ngan, k.n.}, journal={circuits , systems video technology, ieee transactions on}, title={face segmentation using skin-color map in videophone applications }, year={1999}, month={jun}, volume={9}, number={4}, pages={551 -564}, keywords={h.261-compliant coder;chrominance component;complex background scene;face-segmentation algorithm;fast algorithm;foreground/background coding;head-and-shoulders view;human skin color;input image;luminance;perceptual quality;pixels;regularization processes;reliable algorithm;simulation results;spatial distribution characteristics;test im

How To Make Jquery Submenu Stay Visible After It Is Clicked? -

i have read similar posts not jquery need more specific menu. <div id="nav"><!--// start nav //--> <dl id="nav"> <dt class="nav"><b>one</b></dt> <dd> <ul> <li><a href="/a">a</a></li> <li><a href="/b">b</a></li> <li><a href="/c">c</a></li> </ul> </dd> <dt class="nav"><b>two</b></dt> <dd> <ul class="nav"> <li><a href="/d">d</a></li> <li><a href="/e">e</a></li> <li><a href="/f">f</a></li> </ul> </dd> </dl>

java - If statement not working correctly for dates -

i wrote if statement should write different output depending on data. works if int y = 2000, m = 5, d = 06; , doesn't output correct value when int y = 2889, m = 44, d = 16; . this code. please me understand wrong. public class date1 { private int year = 1; // year private int month = 1; // 1-12 private int day = 1; // 1-31 based on month //method set year public void setyear(int y) { if (y <= 0) { system.out.println("that early"); year = 1; } if (y > 2011) { system.out.println("that year hasn't happened yet!"); y = 2011; } else { year = y; } } public int setmonth(int themonth) { if ( themonth > 0 && themonth <= 12 ) { // validate month return themonth; } else { // month invalid system.out.printf("invalid month (%d) set 1.", themonth); re

search - change precedence in a query, 'AND' or 'OR', without () -

i'm doing search query in lucene searchengine. since i'm doing railo setup i'm having trouble parenthesis bug so can't query like(which need): "exact term here"^10 or "less exact term"^5 or ("loose term1" , "loose term2" , "loose term3") but like: "exact term here"^10 or "less exact term"^5 or "loose term1" , "loose term2" , "loose term3" but behave like: ("exact term here"^10 or "less exact term"^5 or "loose term1") , "loose term2" , "loose term3" is there way around without parenthesis

StackView in Android 3.0 HoneyComb -

can 1 provide example of stackview in android 3.0 honeycomb , wll gr8 me .. thnxxx.... you can find basic tutorial on stackview here: http://developer.android.com/resources/samples/stackwidget/index.html here sample demonstrating stackwidget using stackview .

directory - How to track directories but not their files with Git? -

i've started using git , having trouble 1 thing. how can track directories without tracking contents? for example site i'm working on allows uploads. want track uploads directory created when branching, etc. not files within (test files whilst in develop branch or real files in master). in .gitignore have following: uploads/*.* have tried (which ignores whole directory): uploads/ this directory may contain sub directories (uploads/thumbs/ uploads/videos/) able track these not files. is possible git? i've searched everywhere without finding answer. git doesn't track directories, tracks files, acheive need track @ least 1 file. assuming .gitignore file looks this: upload/* you can this: $ touch upload/.placeholder $ git add -f upload/.placeholder if forget -f you'll see: $ git add upload/.placeholder following paths ignored 1 of .gitignore files: upload use -f if want add them. fatal: no files added then when git status you&#

delphi - Enable scroll bars in disabled TMemo control -

is there way how enable scroll bars in disabled tmemo component ? want let users scroll content if control's enabled property set false. know possible workaround readonly , color changes in disabled state, me lot. thanks in advance :) a control can disabled or enabled, not half dis- , half enabled. (and, nit-pickers amongst us, think no hack should make :-), reason given below). using readonly easiest solution. mindful though color changes not make control disabled. confusing user regard recognizing enabled/disabled controls. better make scrollable multi-line label. done setting (background) color equal color of parent. haven't used solution suggested , linked @hallodu, looks alternative.

regex - C# regular expression (replace) -

assume have string: 10,11,12,13,14,abc,def,ghi,66 i looking run regex against return 0-9 , "," characters, stripping else out. i have looked @ regex.replace, isn't quite right it. code below: regex reg = new regex(@"[0-9,]+"); string input = reg.replace(input, delegate(match m) { return string.empty; }); how can make work? do want ^ in that? input = regex.replace(input, @"[^0-9,]+", "");

How to find a whole word in a String in java -

i have string have parse different keywords. example, have string: "i come , meet @ 123woods" and keywords '123woods' 'woods' i should report whenever have match , where. multiple occurrences should accounted for. however, one, should match on 123woods, not on woods. eliminates using string.contains() method. also, should able have list/set of keywords , check @ same time occurrence. in example, if have '123woods' , 'come', should 2 occurrences. method execution should fast on large texts. my idea use stringtokenizer unsure if perform well. suggestions? the example below based on comments. uses list of keywords, searched in given string using word boundaries. uses stringutils apache commons lang build regular expression , print matched groups. string text = "i come , meet @ woods 123woods , woods"; list<string> tokens = new arraylist<string>(); tokens.add("123woods"); tokens.add("wo

.net - '-' not working while using Regular Expressions to match special characters, c# -

pattern regex splregexp = new system.text.regularexpressions.regex(@"[\,@,+,\,?,\d,%,.,?,*,&,^,$,(,!,),#,-,_]"); all characters work except '-'. please advise. use @"[,@+\\?\d%.*&^$(!)#_-]" no need commas. if place - inside character class , means literal dash if it's @ start or end of class. otherwise denotes range a-z . damien put it, range ,-, indeed rather small (and doesn't contain - , of course).

c++ - Detecting basic_string instantiation -

i wrote following code determine if type instantiation of std::basic_string : template <typename t> struct is_string { enum { value = false }; }; template <typename chart, typename traits, typename alloc> struct is_string<std::basic_string<chart, traits, alloc> > { enum { value = true }; }; is there more succinct way achieve that? okay, found shorter way: #include <type_traits> template <typename t> struct is_string : std::false_type {}; template <typename chart, typename traits, typename alloc> struct is_string<std::basic_string<chart, traits, alloc> > : std::true_type {}; but maybe others can better? :)

Update VBScript to work with Windows 7 -

i running windows xp pro on domain computers , in process of migrating windows 7. i have schedule task runs vb script @ login assigns partition current user. here breakdown of setup, -80 gb hard drive -30 gb system partition -10 gb partition (dmw drive) -10 gb partition (dth drive) -10 gb partition (nmw drive) -10 gb partition (nth drive) the script assigns correct drive according time of login. use have storage place users have full access save data. this runs on xp not run on windows 7. here script. set wshshell = wscript.createobject("wscript.shell") ireturn = wshshell.run("diskpart.exe /s removeall.txt", 1, true) set objwmiservice = getobject("winmgmts:\\.\root\cimv2") set colitems = objwmiservice.execquery("select * win32_localtime", , 48) each objitem in colitems dayofweek = objitem.dayofweek hourofday = objitem.hour next if dayofweek = 1 or dayofweek = 3 if hourofday >= 6

servlets - How to apply a stylesheet to castor Marshaller output stream -

what best way apply xslt castor marshaller output stream? i send xhtml client in servlet. i've tried buffer data in string, , putting pipeline xalan, seems expensive , there ought way process stream once. public void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string strgpxid = request.getparameter("id"); long gpxid = long.parselong(strgpxid); // set content type html. response.setcontenttype("text/xml; charset=utf-8"); // output goes response printwriter. java.io.printwriter out = response.getwriter(); try { // private method call fetch gpxdb gpx gpx = this.getgpx(gpxid); stringwriter strwriter = new stringwriter(); marshaller marshaller = new marshaller(strwriter); marshaller.setencoding("iso-8859-1"); marshaller .setschemalocation("http://www.topografix.com/gpx/1/1/gpx.xsd");

c# - How can I delete all the comments in my code? -

i'm new c#, , want develope program delete comments after // in code. there simple code recommended purpose? first point, seems bad idea. comments useful. taking exercise, edit: simple solution fail on case @bubbafat mentions (and propbably more). still work ok on source files. read text 1 line @ time. find last occurrence of // , if using string.lastindexof() remove text after (including) '//' when found write line output ad 1: can open textreader using system.io.file.opentext() , or file.readlines() if can use fx4 also open output file using system.io.file.writetext() ad 3: int pos = line.lastindexof("//"); if (pos >= 0) { line = line.substring(0, pos); }

Deploy an iphone app from xcode to iphone -

i doing school project , required deploy iphone app phone. have noob questions ask. have tried read solutions website dont understand! these questions: iphone app minus app store , how can deploy iphone application xcode real iphone device . can here give me easier way understand please? easy: sign ios developer account . includes signing apple id, enrolling apple developer, opting dev account developer program. link walks through process. hook device machine , @ in xcode organizer (window > organizer). tell xcode want use development. i believe xcode out more used to. if doesn't, apple has step-by-step instructions. in short, need to: use keychain access generate csr (certificate signing request) submit apple via dev portal download resulting development signing certificate , install along apple's intermediate certificate in keychain double-clicking on files. you need create provisioning profile. add device id it. download , stick on device,

Can I Write Selenium Tests in JavaScript? -

selenium's written in javascript. how write tests in javascript? tried adding user extensions, how call regular selenium commands javascript? tried calling doopen, doesn't wait browser load should. how call selenium command javascript? yes can! there node.js implementation of selenium 1 @ https://github.com/learnboost/soda

memory management - What's the difference between generational and incremental garbage collection? -

i think both (generational , incremental) different approaches make garbage collection pauses faster. differences between generational , incremental? how work? , wich 1 better real time software / produces less long pauses? also, boehm gc of those? a generational gc incremental, because not collect unreachable objects during cycle. conversely, incremental gc not employ generation scheme decide unreachable objects collect or not. a generational gc divides unreachable objects different sets, according last use - age, speak. basic theory objects created, become unreachable quickly. set 'young' objects collected in stage. an incremental gc may implemented above generational scheme, different methods can employed decide group of objects should sweeped. one might @ this wikipedia page , further downward, more information on both gc methods. according boehm's website, gc incremental , generational: the collector uses mark-sweep algorithm. provides i

javascript match two arrays then display max value -

i trying match 2 values in 2 arrays var months ['jan', 'feb', 'march']; var nodays ['31', '28', '31']; then want fin months maximum number , return them such "both jan , march have total of 31 days" any suggestions please well, problem solved simple algorithm: var months = ['jan', 'feb', 'march']; var nodays = [31, 28, 31]; var maxdays = 0; var longestmonths = []; (var = 0; i<math.min(months.length, nodays.length);i++){ if(nodays[i]>maxdays){ maxdays = nodays[i]; longestmonths = [months[i]]; }else if(nodays[i]==maxdays) longestmonths.push(months[i]); } after executing code, maxdays 31 and longestmonths ['jan', 'march']

asp.net - how to force textchanged to work onblur? -

actually want tabbing in gridview rowwise have done it. problem have done using ontextchange event whenever hav tabbing have text , enter tab,then works , requirement tab should done without entering text i'm having code want forcefully onblur event. ?? you write little javascript(using jquery) when onblur event occurs txtchanged event called on client side. like $('#idhere').blur(function() { $('#idhere').change(); });

ssl - Java HttpURLConnection connect using Weak Ciphers -

i working on vulnerability scanner in java check websites allow connections using weak cipher suites. would, example, try connect using 56 bits "ssl_dhe_rsa_with_des_cbc_sha" (or other weak ciphers) , if 200 ok, website vulnerable. here far: 1- httpurlconnection works time default ciphers if try use "system.setproperty() set weak cipher, either "cipher not supported exception (for of cipher suites) or "connection rejected" exception when try connect(). know connection rejected answer websites don't accept weak ciphers, how actual http reponse header (with rejection code) instead of exception? 2- not interested in finding vulnerability on ssl level (layer 6) on http level (layer 7) , know http header may deceptive in instances, ok that. in summary, need work weak cipher suites only: url url = new url(ip); httpsurlconnection con = (httpsurlconnection) url.openconnection(); con.sethostnameverifier(new hostnameverifier()

Access - Tricky SQL statement -

i have access database contacts, phone numbers, fax, mobile. example: table: numbers name number type george 555555 phone george 656565 phone george 323232 fax michael 656565 phone john 323232 fax steve 234345 mobile i want select person has phone number 656565 and fax number 323232, namely here george , not michael or john. (name foreign key if helps) sql statement? one possibility set out below, answer will, think, depend on [name] being unique key in whatever table from: select [name] numbers type = 'phone' , [number] = '656565' , [name] in (select [name] numbers type = 'fax' , [number] = '323232') i have assumed number text field because phone numbers stored text.

visual studio - Javascript /// <field type=?> for Instanced Custom Objects -

trying accustomed visual studio's xml javascript comment syntax. have question type. have custom type such as... namespace.types.user = function(_id, _name) { /// <field name="id" type="number">id of user</field> /// <field name="name" type="string">name of user</field> this.id = _id; this.name = _name; }; if want reference type in <field> later on like... namespace.session = function() { /// <field name="currentuser" type="namespace.types.user">the current user of session</field> this.currentuser = new namespace.types.user('foo', 'bar'); }; however, when intellisense show me description of .currentuser means but not show suggestion either .id or .name . in other words acts it's plain object no other type data. how can vs intelligence pickup richer description of custom objects? try putting in xml comments pa

xml - PHP Soap Client -

hi, i have xml i'm trying make parameter soap client <?xml version="1.0" encoding="utf-8" ?> <requestgenerateinvoice xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns="xml"> <type>enadd</type> <invoice> <invoicenumber>5</invoicenumber> <invoiceidtxt>101</invoiceidtxt> <accountidtxt>1001</accountidtxt> <invoicedate>2011-02-21t15:04:42.8500736+02:00</invoicedate> <code>1</code> <details>some details</details> <quantity>1</quantity> <amount>10</amount> <amountdue>20</amountdue> <fromdate>2011-02-21t15:04:42.8490735+02:00</fromdate> <todate>2011-02-21t15:04:42.8530738+02:00</todate> <months>7</months> <ispr

javascript - JQuery UI Tabs Not Displaying Correctly - Internet Explorer -

Image
i'm trying started jquery ui tabs , i'm running issue demo have on site. runs fine me on site itself, when download source , other files run on machine, renders correctly this: when click on of other tabs, render this: clicking leftmost tab makes things correct, clicking other tabs cause lines have circled not rendered. works fine me in firefox , chrome. has else seen before? i'd grateful advice. thanks, -mark i found issue. in jqueryui css. defining .ui-tabs .ui-tabs-nav li elements this: .ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } when should be .ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em -1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } i.e. 1px should -1px margin

Perl's DBD::mysql -- installation conflict -

attempting install perl module dbd::mysql on windows 7 from windows command line executed perl -mcpan -e 'install dbd::mysql' which downloaded , uncompressed file -- then gave me error: cpan.pm: going build c/ca/capttofu/dbd-mysql-4.018.tar.gz set gcc environment - 3.4.5 (mingw-vista special r3) c:\progra~1\mysql\mysqls~1.1\bin\mysqla~1.exe: connect server @ 'localhost' failed error: 'access denied user 'odbc'@'localhost' (using password: no)' problem running c:\progra~1\mysql\mysqls~1.1\bin\mysqla~1.exe - aborting ... warning: no success on command[c:\perl\bin\perl.exe makefile.pl installdirs=site ] guessing issue mysql's root user has password, what's not clear how resolve issue. questions, feedback, requests -- comment, thanks!! ---------- update (1): re: force install dbd::mysql cpan> force install dbd::mysql running install module 'dbd::mysql' running make c/ca/capttofu/dbd-mysql-4.018.tar.gz has

javascript - AjaxToolkit's AnimationExtender has no support for event like onLoad, onClick -

animationextender's animation tag has no intellisense support events onload, onclick etc. follow link , shows. link

java - Preserving Embedded Fonts in iText -

Image
i have java application splits pdf sections using itext, stitches selection of these again. original pdf has many embedded fonts varying in type (all non-system fonts). when stitch pdf's again, of embedded fonts missing. for example, clipping original fonts list: this clipping generated pdf font list: i using pdfwriter , pdfreader copy pages new document, pdfcontent , addtemplate(). finally found answer! problem level of pdf set low: writer.setpdfversion(pdfwriter.version_1_2); i changed to: writer.setpdfversion(pdfwriter.version_1_7); and fonts embedded correctly. i forgot piece of code in there - had borrowed project had done in past. lesson learned ;) i love know why case though.

ruby on rails - Asking rspec to stub find(1), instead it's encountering find(1, {:conditions=>nil}) -

i'm telling rspec: @foo1 = factory(:foo) @foo2 = factory(:foo) foo.stub(:find).with(@foo1.id){@foo1} foo.stub(:find).with(@foo2.id){@foo2} as spec code: f = foo.find(foo_id) and error: expected: (1) got: (1, {:conditions=>nil}) i thought perhaps stub can't told parameters expect, , have use should_receive , though that's not behavior i'm testing in spec -- tried , has same error. i think you're missing something. stub returns canned response don't have retrieve data database. still need expectation on own code. #in spec... @foo = mock(foo) foo.stub!(:find).and_return(@foo) #...do stuff calls foo.find... x.should be_y of course, can use fixtures seed test database, don't have mock activerecord @ all...

clojure - Update and replace map value -

i'm sure it's right here in front of me, i'm missing it. examine following: (assoc :position entity (add (:position entity) (:velocity entity))) what want (with fake function called altermap): (altermap :position entity #((add % (:velocity entity))) what suggested method? there built-in function #2? update-in altermap function, except takes vector of keys instead of single key. so: (update-in entity [:position] #(add % (:velocity entity))) to best of knowledge there no single-key variant of update-in , having put brackets around key shouldn't cumbersome.

c# - exception when mocking a unity container -

i trying mock unity container - using moq , getting errror system.argumentexception: invalid setup on non-overridable member: c => c.resolve<ilogisticsadapter>(new [] {}) here code setup portion of test. var mockcontainer = new mock<iunitycontainer>(); mockcontainer.setup(c => c.resolve<ilogisticsadapter>()).returns(logicsticsadapter); iunitycontainer container = mockcontainer.object; what missing? no master @ mocks in general or unit testing can tell should work... just in case important using vs2010 , ms test... thanks here whole test fixture -you can see have changed use real unity container ideally don't want create real unity container - isn't testing. can see code commented out... [testmethod] public void whencontructed_adaptergetsset() { //prepare ilogisticsadapter logicsticsadapter = new mock<ilogisticsadapter>().object; var mockeventaggregator = new mock<ieventaggregator>(); mockeventaggregat

linux - Loading raw code from C program -

i'm writing program loads , executes code file. got problem: "write" syscall not work. code loads , executes, not display text on screen. program loads code: #include < stdio.h > #include < stdlib.h > int main(int argc,char* argv[]) { unsigned int f_size = 0; unsigned char* code_buf = null; void (*func_call)(void) = null; if(argc < 2) { printf("usage: %s <file>\n",argv[0]); return 1; } file* fp = fopen(argv[1],"rb"); if(!fp) { printf("error while opening file: %s\n",argv[1]); return 1; } unsigned int fsize = 0; fseek(fp,0,seek_end); fsize = ftell(fp); fseek(fp,0,seek_set); if(fsize < 4) { printf("code size must > 4 bytes\n"); return 1; } code_buf = (unsigned char*) malloc(sizeof(unsigned char)*fsize); if(fread(code_buf,fsize,1,fp)<1) { printf("error w

java - Android ImageView set to local URL not working? -

so new android, not understand why not work (and how work): imageview = (imageview) findviewbyid(r.id.image_to_display); uri uri = (uri) extras.getparcelable(intent.extra_stream); i.setimageuri(uri) i did toast , have made sure uri.tostring() returns url content://... sure i valid reference, because able set local images part of .apk . so why not work, , how can work? thanks if don't have have uri instead. string fullpath = environment.getexternalstoragedirectory() + "/pathtoyourfile" // take path create bitmap , populate imageview it. imageview iv = (imageview) v.findviewbyid(r.id.thumbnail); bitmap bm = bitmapfactory.decodefile(fullpath); iv.setimagebitmap(bm);

UIScrollView bad contentSize height when in Landscape (ipad) -

i've problem using uiscrollview subviews , vertical scrolling. when in portrait mode scrolls fine, when in landscape, if set arbitrary value (let's 1400px), doesn't scroll along size, removing around 400 pixels , stops before content visible. any ideas? did try set yourscrollview.autoresizingmask = uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight; it should resize scrollview height.

.htaccess - Mod_rewrite question -

it possible rewrite url using mod_rewrite , htaccess user enter: http://www.mainsite.com/12345 which server translate as: http://www.mainsite.com/index.php?id=12345 by trying remove file extension pages, (remove .php) conflicts , causes never ending redirect: <ifmodule mod_rewrite.c> options +followsymlinks rewriteengine on rewritebase / rewriterule ^(.*)\.php$ $1 [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([0-9a-za-z]+)$ index.html?id=$1 [qsa,nc,l,r] </ifmodule> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([0-9]+)$ index.php?id=$1

astronomy - Using the Ruby Date class for Astronomical data -

~ approximate solar noon lw = 88.743 # longitude jdate = date.ordinal_to_jd(time.now.year, time.now.yday) n = (jdate - 2451545 - 0.0009 - lw / 360).round # lw users longitude west of 0. j_noon = 2451545 + 0.0009 + lw / 360 + n puts j_noon => 2455616.24740833 as update, part of confusion solar noon calculations started since january 1, 4713 bc greenwich noon. the correct use of date.ordinal_to_jd has not compensated fact. adding or subtracting 12 hours this: jdn = date.ordinal_to_jd(time.now.year, time.now.yday) - 0.5 we should less errors. use though since our calculations start yesterdays noon? the code derived 2 equations page sunrise_equation . the first answer got user here don't understand use of 0.0009 , lw / 360. lw / 360 appear fractional day of arc prime meridian. 0.0009, must small amount of variance in seconds since january 1, 4713 bc greenwich noon. see iau standards more info i calculate 0.007776 seconds accordi

iphone - How to send a picture via POST with correct orientation -

i want send image saas via http post request. image taken iphone camera or choosen iphone library. problem iphone seems encode orientation of image in exif data, when try send image via post service elaborate wrong orientation (it isn't smart check exif tag first). can post snippet check exif (if any) , make new image correct orientation? thank help. at risk of encouraging copy-paste programming, i'll use code found here same thing. it'll take uiimage, check exif data, , return new uiimage has been adjusted match service won't need worry it. just keep in mind may need tweak match specific needs. it's starting point though.

python - How to handle array of strings (char **) in ctypes in a 64-bit environment? -

i'm using ctypes work libgphoto2 in python. following code succeeds on 32-bit machine, fails segmentation fault on 64-bit machine (linux, ubuntu): import ctypes gp = ctypes.cdll('libgphoto2.so') = gp.gp_library_version(0) x = ctypes.c_char_p.from_address(a) x.value libphoto2, ctypes , python repositories, assume problem in code; need consider pointers in more general way or that. gp_library_version() returns const char ** , array of string constants. other gp_* functions work fine. the problem that, default, ctypes assumes functions return int , 32 bits. but, on 64-bit system, pointer 64 bits, you're dropping upper 32 bits pointer return value, segfault when try dereference invalid pointer. you can change expected return type of function assigning type restype attribute so: gp = ctypes.cdll('libgphoto2.so') gp.gp_library_version.restype = ctypes.pointer(ctypes.c_char_p) = gp.gp_library_version(0) print a[0].value

Codeigniter + Doctrine and too many mysql connections -

i running large scale website codeigniter , doctrine using rds master/slave dbs, reason keep running doctrine error of too many mysql hosts issue. error tells me flush mysql hosts , fix issue, , does, question is, else experiencing issue? if so, how getting around doesn't continually happen? you in post title many mysql connections, in question many mysql hosts? if down many connections, changing following codeigniter default in database config file might help: $db['default']['pconnect'] = false; it defaults true, meaning codeigniter uses persistent connections - can problem depending on how many simultaneous visitors have , webhost's mysql configuration.

Basic PHP problems -

when use function variables created included scripts retained within scope of function. function reqscript($script) { $include_dir = 'inc/'; $page_ext = '.php'; include($include_dir.$script.$page_ext); } is there way of me not having use following method? include(buildfilename('...')); if want define variables in included file, have use $globals . e.g: $foobar = 42; should $globals['foobar'] = 42; so $foobar available in global scope (outside of functions). but prefer buildfilename() method.

Jquery event on wrapped input radio override 'checked' event -

i want check , uncheck (toggle) radio when "td" click preserving default input event <table> <tr> <td> <input type='radio'> </td> </tr> </table> my code attempts: try 1: http://jsfiddle.net/ujxru/ try 2: http://jsfiddle.net/ujxru/1/ try 3: http://jsfiddle.net/ujxru/2/ preview: $("td").click(function(e) { if (!$(e.target).is("input")) { var bool = !$(this).children("input").is(':checked'); $(this).children("input").attr("checked", bool) } else{ var bool2 = !$(e.target).is(':checked'); $(e.target).attr('checked',bool2); } }); try out.. $("td").click(function(e) { if (e.target.type !== 'radio') { $(this).find(":radio").trigger('click'); } }); example on jsfiddle . if want make td , radio button tog

C# Linq-to-SQL Create a Generic Repository -

i have few repositories this public class departmentsrepository { private personnelactionformdatacontext db = new personnelactionformdatacontext(); /// <summary> /// returns departments /// </summary> /// <returns>an iquerable of departments</returns> public iqueryable<department> getall() { return db.departments; } /// <summary> /// department id /// </summary> /// <param name="id">id of department</param> /// <returns>a null department if nothing found</returns> public department get(int id) { return db.departments.singleordefault(d => d.id == id); } /// <summary> /// department department name /// </summary> /// <param name="department">name of department</param> /// <returns>a null department if nothing found</returns> public department get(string

flex - Cannot figure out why List won't display data from ArrayCollection -

i'm working on flash cards application , using arraycollection of objects store each cards individual data. when user click 'save' button, text 2 textareas , 'title' textinput stored in ac 1 object .title, .side1 , .side2 properties contain text flash card. i have made list in separate class want have display title of each card user has created, after days of researching , looking around, still cannot display list titles. if point me in right direction appreciated. part of newcard.mxml: <?xml version="1.0" encoding="utf-8"?> <fx:script> <![cdata[ import flash.events.eventdispatcher; import mx.collections.arraycollection; import spark.effects.slideviewtransition; import views.mycards; protected function button1_clickhandler(event:mouseevent):void // button { { navigator.pushview(views.myflashcardshome, event.relatedobject);

subclipse - Is it safe to set SVN to ignore . in a directory that should be version controlled? -

yesterday, asked a question why directories can appear subclipse contain uncommitted changes when don't. answer setting svn:ignore status on pseudo-directory . counted modification, subclipse didn't show because doesn't deal . . knowing cause nice, issue isn't resolved. safe commit addition of ignore status . pseudo-directory? not want actual directory ignored svn; want make uncommitted change decorator go away. (no, haven't tried doing it. wouldn't know how cleanly revert change if turned out problematic.) edit: pointed out in tim's answer, blaming modification of . misleading. . marked modified because 1 of subdirectories set svn:ignore ; that's real change , root cause. based on output of svn diff received, setting svn:ignore resource target . property information saved on parent versioned resource (in case project root . ) can committed repository independent of local ignore settings. given this, safe commit property chan

command line - CommandLine Arguments in java Help -

i'm suppose use command-line arguments take user input , use enhanced loop sum. this error: exception in thread "main" java.lang.error: unresolved compilation problem: type mismatch: cannot convert double int public class enhanceforloop { public static void main(string[] args) { // todo auto-generated method stub if(args.length !=5) system.out.println(" please enter no more 4 numbers"); else { double sum; double arraylength = double.parsedouble(args[0]); double [] myarray = new double [ arraylength ]; double value = double.parsedouble((args[1])); double counter = double.parsedouble((args[2])); for(double num: myarray) sum += num; system.out.printf("the sum %f ", sum); } } } here how far: public class enhanceforloop { public static void main(string[] args) { // todo auto-generated method stub if(args.length !=5) system.out.println(" plea

C# Mono aot with protobuf-net getting ExecutionEngineException -

first big marc gravell author of protobuf-net http://code.google.com/p/protobuf-net/ . it's great resource. anyhow hoping marc or else can me resolve exception. i trying implement protobuf-net on mobile devices (ios , android) using unity3d game engine. unity 3.2 uses mono 2.6, modified version of mono. it works fine in editor, on ios device @ runtime fails @ first member tries serialize. note --aot-only flag in exception. think unity builds arm assembly through mono's aot feature though don't understand it's doing under hood. executionengineexception: attempting jit compile method 'protobuf.property.property`2<gamemanagersavestate , bool>:.ctor ()' while running --aot-only. @ protobuf.property.propertyboolean`1[gamemanagersavestate]..ctor () [0x00000] in <filename unknown>:0 @ protobuf.property.propertyfactory.createproperty[gamemanagersavestate] (system.type type, protobuf.dataformat& format, memberserializationoptions options) [0

c# - How to loop through all MailItems of certain Outlook subfolders -

i'm working on outlook 2007 add-in. found code loop through folders have not been able figure out how loop inside given folder examine mailitem objects (ultimately, want save emails elsewhere , modify .subject property). here have far: private void btnfolderwalk_click(object sender, eventargs e) { // retrieve name of top-level folder (inbox) , // purposes of demonstration. outlook.folder inbox = application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderinbox) outlook.folder; // cast mapi folder returned outlook folder // retrieve reference top-level folder. if (inbox != null) { outlook.folder parent = inbox.parent outlook.folder; // mailbox if (parent != null) { recursethroughfolders(parent, 0); } } } private void recursethroughfolders(outlook.folder therootfolder, int depth) { if (therootfolder.def

c# - Can I run NUnit tests from within Visual Studio 2010? -

is there addon of kind let me run , view results inside visual studio? remember there sort of icon red rocket ship on it. suggestions? can't remember name. i don't want use nunit gui if can it. sounds you're looking testdriven.net . there other alternative test runners nunit gui too, such resharper , gallio .

javascript - Does it make sense to initialize models from the DOM in backbone.js? -

backbone.js relies on restful applications initialize models, progressive enhancement? data in dom (or of it), should models still make calls the restful interface though html elements exist? there library design might better suited case? you should not use dom element initialize model backend data. have nice infrastructure backbone not this. when rely on dom need change javascript whenever dom structure change due design exemple. also not rely on backbone view create model. must go other way around, model dictate views on page. just add script element , create js objects directly in there. can initialize collections, single models, etc. you can same templates or dom ui building blocks: <script type="text/js-template"> <!-- template realy elements or using js templating engine _.template--> </script> load page , have app play locally.

html - question regarding the use of alert -

i came upon code while studying settimeout. settimeout executes alert 5 seconds after button clicked. <input type="button" name="clickme" value="click me , wait!" onclick="settimeout('alert(\'surprise!\')', 1000)"> however, saw alert string inside has format ive never seen before. \ occurs before ' surprise! \'. use? this indented command: alert('surprise!') . contains 2 quotes. in case command passed as string settimeout . string delimited quotes: 'string' . 'alert('surprise!')' , invalid syntax, because it's parsed this: 'alert(' // string surprise! // nonsense ')' // string so quotes inside string escaped signify "this not end of string". this worst possible way though. better way alternate 2 available quote types: 'alert("surprise!")' this mess in case though because confuse html parse

why does visual studio 2008 runtime require admin privileges, while 2005 and 2010 don't? -

is there way copy libraries computer has them 1 doesn't without using automated installer ? for admin part no idea, automated installer part, guess if copy dlls in same folder app exe work fine. not sure way approved ms though. you'll find dlls in c:\windows\system32 folders (for vs2008 i guess msvcr90.dll , msvcp90.dll enough). be careful, if on x64 machine x64 dlls, 32 bits 1 in syswow64). you not allowed distribute debug dlls (the 1 ending 'd' before extension).

swing - Java EventQueue. When should I consider using it? -

i'm looking @ eventqueue class on oracle website: http://download.oracle.com/javase/1.4.2/docs/api/java/awt/eventqueue.html i'm not sure when should use it? should use if class has listeners 2 or more events? normally don't have submit events eventqueue, happens "automatically" when user actions (like mouse clicks , such), or when system thinks window needs repainted. the 2 methods i'm using regularly eventqueue.invokelater , eventqueue.invokeandwait() (less often). use 1 of them if doing action outside of edt (event dispatch thread) , want changes gui (like adding or removing component to/from container), such actions should occur on edt.

security - Difference between CRC and hash method (MD5, SHA1) -

both crc , hash methods can used verify integrity of original data. why systems uses hash method nowadays? crc designed prevent transmission errors, not malicious action. therefore, isn't collision resistant. in particular, linear properties of crc codes allow attacker modify message in such way leave check value unchanged

xml - Does PHP simplexml_import_dom convert the full DOM? -

i have xml document importing php dom , validating xsd (relaxng not option). want turn dom simplexml processing. function simplexml_import_dom seems thing use, documentation says "this function takes node of dom document , makes simplexml node." implies 1 node converted, not full dom tree. correct? i xml simplexml re-reading file, wasteful. if simplexml_import_dom not full dom tree, how convert dom simplexml? i've looked example code recursive dom traversal have not found examples. suggestions? simplexml objects/elements/nodes include children. simplexml_import_dom function handles recursion you.

events - Removing two children and its parent with Javascript -

been struggling 1 have following dom structure: <ol id="add_images"> <li> <input type="file" /><input type="button" name="removebutton" /> </li> <li> <input type="file" /><input type="button" name="removebutton" /> </li> <li> <input type="file" /><input type="button" name="removebutton" /> </li> basically i'm trying remove children , containing parent (the li tag) when clicking remove button. i have tried every manner of parentnode , removechild combinations. below javascript, can children not parent. function addfile(addfilebutton) { var form = document.getelementbyid('add_images'); var li = form.appendchild(document.createelement("li")); //add additional input fields should user want upload additional image

mongodb - Is there any method to guarantee transaction from the user end -

since mongodb not support transactions, there way guarantee transaction? i think ti's 1 of things choose forego when choose nosql solution. if transactions required, perhaps nosql not you. time go acid relational databases.

html - javascript : simple delayed image show -

i'm trying write simple javascript snippet delays image loading number of millisecs below. <html> <head> <script type="text/javascript"> function settimer() { var timer = setinterval("showimage()",3000); } function showimage() { document.getelementbyid('showimage').style.visibility = 'visible'; } </script> </head> <body onload="settimer()" style="visibility:hidden"> <div id=showimage> <a href="home.php"><img src="gwyneth_paltrow_2.jpg"></a> </div> </body> </html> am approaching incorrectly? thanks in advance this ok approach. there bugs, namely: document.getelementbyid('showimage')style.visibility = 'hidden'; getelementbyid should getelementbyid needs dot after ('showimage') you setting visibility 'hidden' in order show it. instead, should start out hidden,

c++ - what's the type of 'struct random_data* buf'? -

i'd have instance variable of "struct random_data*" used in int random_r(struct random_data *buf, int32_t *result); i've tried declaring as "struct random_data* instancebuf;" "random_data* instancebuf;" but compiler doesn't of it. how should declare variable? -edit ah,, api linux, , i'm on mac(bsd) :( oh wait, linux only? http://www.gnu.org/s/libc/manual/html_node/bsd-random.html probably: struct random_data buff; int x = random_r (&buff, ...); is easiest solution. you'll have make sure that structure has been defined. and, if buffer required long lived (like seed), make sure it's defined somewhere large scope (global or class-level, example).