Posts

Showing posts from February, 2011

html - JavaScript Error for OnClick -

here html: <%@ page language="c#" autoeventwireup="true" codebehind="webform2.aspx.cs" inherits="davincisapp1.webform2" %> <!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"> <head runat="server"> <title></title> <link href="~/styles/stylesheet1.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="scripts/jquery-1.4.1.min.js"></script> <%--<script type="text/javascript" src="scripts/motion.js"></script>--%> <script type="text/javascript"> $(document).ready(function(){ /* make sure contact form hidden when page loads: */ $('div#contact-form').hide(); $('a#contact-button').toggle

Asynchronous socket callbacks do not work in Mono/Linux -

i'm exploring porting .net c# application windows linux using mono. problem i'm stuck asynchronous tcp socket calls not work. means can send data no problems i'm seem able receive first response socket (via socket.beginreceive()). next beginreceive() puts thread wait state. in possible in principle our socket code contains bug it's been working flawlessly in windows years. thank you this works fine mono-2-10 branch (soon released mono 2.10) , master. the mono 2.6.7 shipped ubuntu fails , mono 2.8. i've found problem , testing fix. . next releases in 2.6.x series have fix (also 2.8.x if there's any, since moving 2.10 in few days). btw, should report problems in mono following http://mono-project.com/bugs instead of here.

entity - Deleting entities from app engine -

i'm going deleting entries python app engine server this: try: while true: q = db.gqlquery("select __key__ sampledata") assert q.count() db.delete(q.fetch(400)) time.sleep(0.2) except exception, e: self.response.out.write(repr(e)+'\n') pass try: while true: q = db.gqlquery("select __key__ userdata") assert q.count() db.delete(q.fetch(400)) time.sleep(0.2) except exception, e: self.response.out.write(repr(e)+'\n') pass ..but seems ugly , keep suspecting it's not entirely reliable. there way better delete entries of number of types instead of making 1 of each of these while loops? update: 1 restriction have running periodically via cron job, not wish doing manually (i.e. via admin console instance). a few improvements: you don't need sleep after eac

asp.net mvc - How do you wire lists/collections on view models using IoC, DI, and MVC? -

i'm working mvc project, trying implement ioc , di. both these new me, apologies in advance if i'm going down wrong road, or if question not worded clearly. suppose have view needs display address form, 1 of elements being drop down list of states. (i realize address outside context of else not likely, simplicity of example, assume case here.) suppose view model: public class addresslist { public string address1 { get; set; } public string address2 { get; set; } public string city { get; set; } public list<string> states { get; set; } public string zip { get; set; } } whose responsibility populate states list? should controller this, having had service injected getting states? if so, same injection , population logic go in each of controllers needing populate address? or should go somewhere else? at layer view model belong? if view model specific given view in app, shouldn't remain in app, , therefore not used pass service populat

java - Clear folder - delete files in folder - J2ME -

i trying clear files in folder using j2me. how do that? since using j2me, java.io.file class not available you. so assuming using fileconnector optional package (fcop). take @ javadocs javax.microedition.io.file.fileconnection , , should able figure out details. i'm not j2me expert, think code this: fileconnection fconn = (fileconnection) connector.open("file:///somedirectory"); enumeration en = fconn.list(); while (en.hasmoreelements()) { string name = en.nextelement(); fileconnection tmp = (fileconnection) connector.open( "file:///somedirectory/" + name); tmp.delete(); tmp.close(); } exception handling, proper resource handling (using finally ) left exercise reader :-)

updating a table in a Mysql database -

lets have in table named threadloc id thread 4 1 3 2 2 3 1 4 for table i want change table value of thread can pick thread , put in on bottom (id 1) , push other threads one. so pick 2 be id thread 4 1 3 3 2 4 1 2 update threadloc set id = id + 1 thread <> @currentthread , id < @currentid; update threadloc set id = 1 thread = @currentthread edit: doesn't change higher ids

How to catch IOException Error in eclispe for Android? -

i want catch ioexception error , want show in form of toast android application development. when ever apply catch( ioexception e), after try block says throws (throws ioexception ) function name after catch error message.. please provide assistance.... may desire ' throws ' catched exception above call stack, , next, catch , process exception in 1 place (or ' layer ') of code?)

asp.net - Nhibernate uses a lot of memory -

i've got fluent nhibernate in application , i'm trying locate cause of high memory usage. (i high, it's 60mb, it's web app , it's not big) unfortunately looks lot of in unmanaged memory, started taking things out - , took out calls nhibernate, memory usage dropped 11mb!! why oh why taking memory? especially, why taking unmanaged memory? i've been 'googling' day , can find posts people saying "nhibernate eats memory..." , answers "no doesn't, there's no evidence". nhibernate people in denial it? possible reasons: nhibernate caching. check these articles: http://nhforge.org/blogs/nhibernate/archive/2009/04/24/nhibernate-2nd-level-cache.aspx http://nhforge.org/blogs/nhibernate/archive/2009/02/09/quickly-setting-up-and-using-nhibernate-s-second-level-cache.aspx keep in mind "more memory usage" shouldn't "this devil". mean caching or other factors increase overall performance if m

caching - Memcached - How to prevent an item from being removed -

i'm using beitmemcached client in application. there way of preventing cached value being removed when cache grows large? got values cached have stay in cache no matter what. possible? thanks in advance! no, memcached not work way. not data store. redis , couchbase 2 products persistent storage memcached (like) interface.

.net - How to clear a memory early in c# -

after finishing use varible, can clear memory before gc it? if there specific resources need released immediately, implement idisposable interface , call dispose() (sometimes close() on objects, such streams). if looking prevent passwords being retained in memory beyond lifespan, securestring supports this, though not simple use. otherwise, have no control on when garbage collector runs or does. if desperately need kind of control, need lower level language.

Flash and php params exchange -

hello new flash, , trying make simple video player. have problem setting source of video: in action script have this: player.source='http://localhost/getvideo.php'; where getvideo.php is: <?php echo file_get_contents('sas.mp4'); ?> this works fine when try add parameters player.source: player.source='http://localhost/getvideo.php?asd=asdas'; i error: videoerror: 1005: invalid xml: url: "http://localhost/getvideo.php?asd=asdas&flvplaybackversion=2.1" no root node found; if url flv must have .flv extension , take no parameters what want is, create player can parametrize video select. 1 knows fast solution this? thanks you can't attach parameters source url that. couldn't find in documentation, makes sense restrict url strings when considering opening video file via flvplayback not equal simple url request on loader object, rather involves opening netconnection, , starting , attaching netstream, possibly no

android - Current View Identification -

there views grid view , text views in same activity. want focus text view grid view when press button need select text view. text views put in linear layout.how possible? will help? view.getid() == r.id.your_required_view

asp.net - call a webservice with list<int> as paramter from jquery .ajax -

i have webservice webmethod looks like: [webmethod(description = "gets places category & city")] [scriptmethod(responseformat = responseformat.json)] public list<p> getcitiesps(int categoryid,list<int> cityids) { return mymanager.getps(categoryid, cityids); } the parameter cityids list of values of checked checkboxes. var cityids = new array(); $('.city-checkbox').each(function() { checked = $(this).attr('checked'); if (checked == true) { cityid = $(this).attr('value'); cityids.push(cityid); } }); now when call webservice method .ajax,but doesn't fire. var params = json.stringify({ 'categoryid': categoryid, 'cityids': cityids }); alert(params); $.ajax({ type: "post", url: "finkaynwebservice.asmx/getcitiesps", data: parameters, contenttype: "application/json

c++ - Conditions for automatic generation of default/copy/move ctor and copy/move assignment operator? -

i want refresh memory on conditions under compiler typically auto generates default constructor, copy constructor , assignment operator. i seem recollect there rules, don't remeber, , can't find reputable resource online. can help? in following, "auto-generated" means "implicitly declared defaulted, not defined deleted". there situations special member functions declared, defined deleted. the default constructor auto-generated if there no user-declared constructor (§12.1/5). the copy constructor auto-generated if there no user-declared move constructor or move assignment operator (because there no move constructors or move assignment operators in c++03, simplifies "always" in c++03) (§12.8/8). the copy assignment operator auto-generated if there no user-declared move constructor or move assignment operator (§12.8/19). the destructor auto-generated if there no user-declared destructor (§12.4/4). c++11 , later only: the mov

c++ - what is wrong here -

unsigned __int8 result[]= new unsigned __int8[sizeof(username) * 4]; intellisense: initialization '{...}' expected aggregate object the types not same; cannot initialize array pointer. new unsigned __int8[sizeof(username) * 4]; returns unsigned __int8* , not unsigned __int8[] change code unsigned __int8* result = new unsigned __int8[sizeof(username) * 4];

plugins - jQuery loading animation without gif -

i'm looking jquery plugin loading animations without using gif file. thanks. loader on canvas - here loader on svg - here

c++ - including class as member in struct -

i have add class object member within c struct. is there prohibition doing this. regards, isight you can have c++ class member in c, needs seen void* in c point of view, c can handle fine. this technique called opaque pointer .

How do I use VBA to obtain the file path to a shortcut from which the ActiveDocument was launched? -

i building document management system. in each subdirectory within main document repository, there shortcut document template. when user wants create new document, he/she navigates appropriate subdirectory document , clicks shortcut. when user clicks shortcut, ms word launched, showing new document based on template. when user clicks save , document saved current directory default location new documents specified in word options . i want current directory of new document same directory of shortcut created. user has decided document located navigating appropriate subdirectory , clicking shortcut. should not necessary user navigate same location again within save as... dialog. if can obtain path shortcut, can programmatically save document same directory or new subdirectory. also asked on msdn vba forum , on vba express . i don't think you're going able without doing awful hacking around trawling file system (i had brainwave "start in" property of

web services - Get working with WSDL.How to? -

i have implement "service bindings" in project in school. i learned wsdl w3schools.com. came know "wsdl" is. know wsdl didn't it. want go practical it. don't know how that. from start? know there other things learn , don't know they. i need in getting "practical". in mind don't know how implement it. based on question assume little bit confused. you should talk teacher (or whoever gave assignment) , find expected do . web services involve lot of knowledge, wsdl 1 part of it. as have learned w3schools, wsdl means web services description language. way document web service's interface world. a web service accessible endpoint address, http://some.server.com/context/bla/whatever this tells find web service, tells nothing how call (i.e. how messages going structured correct communication). the wsdl provides info: operations exposed, how messages composed, binding used etc. so understand bit how wsdl "fit

java - Get net_rim_os not found warning when debugging -

whenever try debug app developing blackberry 8xxx something, within eclipse, warning net_rim_os not found. have click away modal, , same. i assume because have 6.x development environment installed, phone 4.5. the program works on phone though, long stay away api not existing on phone. how can make warning never appear, or better, install missing symbols or whatever eclipse complaining about. it's eclipse provided rim using. the debugger looking .debug files support symbolic debugging. isn't problem on simulator because delivered .debug files match os. physical device faced issue os version used on hardware rarely, if ever, matches version of os .debug files available. you better off compiling sdk version less or equal version of os running on hardware. if testing coverage less complete may end delivering program hidden api incompatability. best practice compile programs each version of os supporting.

indexing - How can i check in Postgresql if specific index is loaded to memory? -

is there way check if index loaded memory? check contrib module pg_buffercache after installation can use query see if table , index in buffercache: select distinct relname pg_buffercache join pg_class using (relfilenode) relname in('your_tablename','your_index_name');

stored procedures - MySQL concat multiple rows into a single row -

i have query returns multiple rows such below in mysql: attribute_name value ---------------------------------------- username emailuser domain mydomain.com my required output follows: username domain ----------------------------- emailuser mydomain.com current sql: select pa2.attribute_name, upa2.value product p inner join product_attribute pa on p.product_id = pa.product_id , pa.attribute_name = 'alias' inner join user_product_attribute upa on pa.product_attribute_id upa.product_attribute_id inner join user_product_attribute upa2 on upa.user_product_id = upa2.user_product_id inner join product_attribute pa2 on pa2.product_attribute_id = upa2.product_attribute_id , pa2.attribute_name in ( 'username', 'domain' ) p.product_name = 'email' , upa.value = 'emailalias@domainalias' i have been looking @ group_concat, think wrong path.. suggestions? nothing wrong

scripting - Good alternative to Windows batch scripts? -

what alternatives windows batch scripts? have number of them , "clunky" work with. our group familiar java groovy option? a lot of our scripts used prep dev databases involve lot of cd mydir , hg fetch , sqlplus ... , etc.. if interested in developing scripts windows technology developed windows, powershell , sensible choice. while groovy allow achieve goal don't think there particular advantage offer. saying that, have consider familiarity factor , learning curve. developers have experience java , groovy in case running ant tasks via groovy dsl can prove easier learning powershell. regardless, consider developing scripts using tdd approach. groovy offers plenty of frameworks (try spock example) while there ways achieve for powershell .

php - Loading multiple versions of the same library -

i'm using library, zend framework in , has path zendframework-1.10.8/library/zend/ i load in index.php realpath(central_libs_path . '/zendframework-1.10.8/library'), // /zend left out and can call 1 of classes class zend_form_ now question, how can use multiple versions of same library. suppose load both of in index.php realpath(central_libs_path . '/zendframework-1.10.8/library'), realpath(central_libs_path . '/zendframework-2.0.0/library') but when call class zend_form , how explicitly tell use 1 v1.10.8 or 1 v2.0.0? remember reading somewhere if 2 libraries have same class, library above 1 called. how can switch between 2 @ will? can done in same project? zend framework 2 classes grouped within namespaces , has own autoloader looks through directories (it should 1:1 relationship between directory , namespace). you need register both autoloaders (you may need rewrite zf 1.10 use spl autoloading can register multiple autoloaders

permissions - Check if user is allowed to see the web page in asp.net -

depending on user permissions pages available him, , others not. created base page inherits system.web.ui.page, , pages inherit page. in page_load event (of our base pages class) check if user allowed view page. if not redirect page says not allowed (response.redirect). is approach or there better? note : thanks suggestions, asp.net membership not option requirements :(. sorry. check out asp.net membership, read article on msdn: introduction membership . don't want re-invent wheel. membership let control locations, files, folders etc on roles / users. it's powerfull mechanism here usefull links: understanding role management managing website users roles

ruby (on rails) gem for basic form markup -

i'd add basic markup (bbcode , on) app i'm working on. need not more basic functionality such [b], [url] , tags that. can recommend gem easy drop in? edit: got tip use rdiscount, installed , trying use. unsure how use it. first idea use in :before_save filter in model, means saving html database. means if want edit content there bunch of html-tags showing user. another idea had create helper method in app/helpers/application_helper return html views calling helper_name(post.content). best idea, , seems work (partially). ruby on rails still prevents html "used" escapes tags. do recommend other way use it? if not, how can "unescape" html? something rdiscount , perhaps? not clear requirements are, here's info project .

internet explorer - CSS reset sheet for a preexisting IE-only site that wants to improve the cross-browser experience? -

i working on internal, custom asp.net site specified customer require working in internet explorer. means no resources have been put forward make sure works , looks nice in other browsers, although there no exotic ie-only technology used or that. since going want other browsers work, wondering if there exists css reset stylesheet can make other browsers layout more ie. i looking reset stylesheet intended make firefox, chrome, etc, behave more ie (i'm sure nobody leave obnoxious comments this), won't break of existing layout (which tested on ie7). i know i'll have other issues javascript, etc, question css/layout. in short, css reset sheet exist "reset" css ie defaults? it's not designed ie use - wont make difference, need apply adapt existing styles looks same in browsers. html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins,

iphone - how to display previously selected value in UIPickerview selected bar -

i displaying numbers 0 30 in uipickerview . and call pickerview when tap on button. when ever select 1 value in pickerview , tap on ok button quit pickerview. for next time when ever tap on button open uipickerview need display previous selected value like this . for example select 13 next time when open pickerview need display 13 on selected bar show in figure. how can done. can 1 please me. thank u in advance. save user selection somewhere , before show picker view set selection programmatically selectrow:incomponent:animated: method: // create picker if needed [pickerview selectrow:13 incomponent:0 animated:no]; // show picker

tree - Smartgwt select treenode from code -

i have treegrid in have tree : tree nodestree = new tree(); treegrid navtreegrid = new treegrid(); navtreegrid.setdata(nodestree); and want everytime i'm adding node tree focus on it. more general, how can code select treenode in tree ? i know navtreegrid.getselectedrecord() method not want. thank you! you can use 1 of selectrecord methods . grid.selectrecord(record);

Android - how to find out from within running app if device it is running on is phone or tablet -

this question has answer here: tablet or phone - android 26 answers is there method identify if device app running on phone or tablet? want implement different behavior depending of device type. if want differnce because of screensize, should find screensize, not easy, there tablets small screens , phones large screens. still, ofcourse possible screen size. you try do gsm capabilities. again, there exceptions, tablets can call.. i advise against making differentiation, , define on basis need. screensize, capabilities etc. might groups consist of both "phones" , "tables", you'll have better knowledge of group like. i'm still not sure how define "tablet" , try needs definition, if take @ this link , can see might (did quick read) things consider tablets not identify in user-agent string mobile device. but: you nee

javascript - Validate 3 digit number or not -

can tell me regular expression check whether entered number 3 digit number or not... should not allow alphabets also.... regex 3 numbers ^[0-9]{3}$ or ^\d{3}$

wpf - PRISM + MEF + MVVM -- Not sure where to really start? -

what i'm using: visual studio 2010 microsoft .net framework 4 prism v4 what trying figure out how started prism + mef while maintaining mvvm pattern. when go prism quickstarts, has prism + mef, comments in project state quickstart example not implement mvvm. i'm not sure mix/match shell follows mvvm (and regions). basically, want use mef able load assemblies (modules) @ run-time. and, want setup regions in shell , have shell use mvvm (so can databind things shell). every example online either prism, prism + mvvm, prism + unity, silverlight examples, prism + mef, etc. can not find wpf prism + mef + mvvm examples or information. have no idea how setup bootstrapping , such going. once part done, i'm sure i'll figure out how load other controls using mvvm shell. great, resources deal directly situation apposed similar (i.e. prism + unity , without mef). thanks! i have never used prism+mef myself, in question mention want able load modules @ runtime

C# byte[] to List<byte[]> -

i'm trying byte[] array 'a' list 'b', it's not working. have byte array 'a'. 12344 23425 34426 34533 i 4 item (# of rows) list , isn't working. (setting intermediate byte[] adding it) byte[] = {1,2,3,4,4,2,3,4,2,5,3,4,4,2,6,3,4,5,3,3}; list<byte[]> b = new list<byte[]>(); byte[] inter_byte= new byte[5]; (int u=0; u<4; u++) { (int p=0; p<5; p++) { inter_byte[u] = file[(5*u) + p]; } b.add(inter_byte); } what i'm getting list 4 rows long, last row. what's best way this? your byte array reference type, means changing in each loop changes data stored. declaring inside of each loop should work: byte[] = {1,2,3,4,4,2,3,4,2,5,3,4,4,2,6,3,4,5,3,3}; list<byte[]> b = new list<byte[]>(); (int u=0; u<4; u++) { byte[] inter_byte= new byte[5]; (int p=0; p<5; p++) { inter_byte[p] = a[(5*u) +

asp.net mvc - Model validation using db value in Range -

i have 2 tables, campaign , advert 1 many relationship. during advert creation, user selects pre-defined campaign advert belong. campaign has rrp money field , advert has saleprice money field. i'm after way ensure submitted advert.saleprice >= chosen campaigns rrp. can done in model? along lines of in advert_validation? possible fill values of range method calls? [range(0, getcampaignrrp(), errormessage = "value must equal or greater campaign rrp")] public double saleprice { get; set; } or need check @ controller level? appreciated! thanks all, jay you can use new remote attribute. calls action , returns true or false. here's link example.

Mysql, AVG and Count question -

id, rating_id , rating_num 33100, '4028', 2, 33099, '4041', 2, 33098, '1889', 4, 33097, '1889', 5, 33096, '4050', 2, 33095, '8578', 2, 33094, '8578', 4, 33093, '8578', 5, 33093, '8578', 5, guys 3 questions 1) how can see rating_id has received more 3 counts of rating_num ? (answer: 8578) 2) how can see average rating_num of each rating_id ? 3) how can see average rating_num of each rating_id received more 3 counts of rating_num ? ( answer: 4 ) thanks replying classs attender of mysql4dumbmies 1 select rating_id yourtable group rating_id having count(*) > 3 2 select rating_id, avg(rating_num) average_rating yourtable group rating_id 3 select rating_id, avg(rating_num) average_rating yourtable group rating_id having count(*) > 3

ruby on rails - Routing error using form_tag -

i have routing issue can't seem head around. i have project resource has restfull actions working expected. now want add ability update 1 specific attribute through small popup form. in popup use: form_tag (@project) text_field_tag :attribute_i_want_to_update, '' submit_tag 'go' in controller's update action intend handle specific submit. receive routing error claiming there no route '/projects/15'. checked request using post. route exists post '/projects/15' (e.g. regular update route works fine , posts exact route). what missing? thx time, erwin i had similar problem, see here if object not new, rails (at least 3 this) put route, not post. if check sent server, using firebug example, see post made param "_method=put". rails put route update existing object, in accordance fielding's definition of rest.

c++ - histogram function in OpenCV -

i seeking way compare 2 images , matching image output. using histogram function in opencv can this? can please me? but dont know how since not familiar opencv. thank you. the histogram ensure 2 images have similar color distributions. color distributions similar in different images. as example, imagine black , white 8x8 checkboard , image left side black , ride side pure white. these images have same histogram.

exception handling - ExceptionHandler returning JSON or XML not working in spring mvc 3 -

code this: @controller public class testcontroller { @requestmapping(value = "/testerror", method = requestmethod.get) public @responsebody errorto testerror(httpservletrequest request,httpservletresponse response) { throw new abcexception("serious error!"); } @exceptionhandler(abcexception.class) public @responsebody errorto handleexception(abcexception ex, httpservletrequest request, httpservletresponse response) { response.setstatus(response.sc_bad_request); return new errorto(ex.getmessage()); } @requestmapping(value = "/test", method = requestmethod.get) public @responsebody errorto test(httpservletrequest request, httpservletresponse response) { errorto error = new errorto(); error.setcode(-12345); error.setmessage("this test error."); return err

email - XAMPP Sendmail using Gmail account -

i'm trying configure sendmail through xampp send email. in sendmail.ini have these settings: # set default values following accounts. logfile "c:\xampp\sendmail\sendmail.log account gmail tls on port 587 tls_certcheck off host smtp.gmail.com myemail@gmail.com auth on user myemail06@gmail.com password mypassword account default : gmail i've created test script this: $to = "testemail@btinternet.com"; $subject = "hi!"; $body = "hi,\n\nhow you?"; $headers = "from: myemail06@gmail.com" . "\r\n"; if (mail($to, $subject, $body, $headers)) { echo ("message sent!"); } else { echo ("message delivery failed..."); } i message email sent never arrives , in logs get: sendmail: error during delivery: must issue starttls command first. does know issue here? thanks in advance! gaz this worked me no 1 else burn oil figure out did. here sendmail.ini [sendmail] smtp_server=smtp.gm

Prevent Firefox from restoring session cookies after restart -

firefox has feature restore session cookies after restart (either after crash or if user has set "restore session" option) , that's causing lot of problems (for example: firefox session cookies ). however sites, notably gmail, somehow don't have problem. after restores session firefox won't sign in gmail, you'll have enter user/pass again. (although, not quite sure if gmail uses session cookies @ all) is there way server application "prevent" browser restoring session cookies? or there way know in restored session? ok, answer own question... according can firefox restore secure session after add-on installation? , page links http://kb.mozillazine.org/browser.sessionstore.privacy_level there's firefox setting 'browser.sessionstore.privacy_level' determines ff session restores saves (can 0, 1 or 2 - see second link). until ff4 default store/restore non-secure sessions (that's why gmail asks sign in again - using s

Why do I get the "read-only cache configured for mutable" when building NHibernate session factory? -

i have set simple model: document entity multiple images. images saved in database, , updated other legacy application, app has readonly access. setup synonim can use images table on server local table. mappings following: <class name="image" mutable="false" table="imageexternal"> <cache region="images" usage="read-only" /> <id name="id"> <generator class="assigned" /> </id> <property name="name" update="false" /> <!-- other properties --> </class> <class name="document" table="document"> <id name="id"> <generator class="guid.comb" /> </id> <!-- other properties --> <set name="images" mutable="false"> <cache region="images" usage="read-only" /> <key colu

C# deserializing a binary structure with bitfields - how to do? -

i have c struct defined in way similar this: struct teststruct { uint flag1 :2; uint flag2 :2; uint flag3 :2; uint flag4 :2; uint value1; } teststruct; i know can deserialize binary struct using structlayout attribute , marshal.ptrtostructure() . there way binary fields shown in structure 1 value 2 bits long? thanks in advance. there no direct support such structure in c#. have use integral type holding bits , extract fields afterwards. see solution similar problem @ bit fields in c#

iphone - Detecting changed user defaults -

i have iphone app , have implemented local notifications. app has page in settings allows user schedule notifications specified number of days in advance of event. make sure changes settings take effect every time user activates app, have following in app delegate: - (void)applicationdidbecomeactive:(uiapplication *)application { [[nsuserdefaults standarduserdefaults] synchronize]; [self rescheduleallnotificationswithusernotification:no]; } the problem call rescheduleallnotificationswithusernotification: takes few seconds , app feels little sluggish on start. i need call rescheduleallnotificationswithusernotification: if of settings have been changed. is there way detect if user has changed of settings between app activations can avoid rescheduling notifications ? i think might looking nsuserdefaultsdidchangenotification notification. you can register listen notification , informed whenever user's preferences change.

iPhone - is @2x valid for UIWebView? -

i have uiwebview on app shows local html file. images on web view follow @2x rule? mean, if build both, regular , @2x images webview load retina ones iphone 4? remember images being loaded html tag , not uiimage method. thanks. jonathon grynspan correct. recommend reading aral balkan's tutorial on topic. read when implemented @2x graphics recent mobile site: how make web content stunning on iphone 4’s new retina display

mysql - Sql query only functions if all records exist -

delete profile, images, schedules using profile inner join images using(profile_id) inner join schedules using(profile_id) profile.profile_id = 47 i have piece of mysql code deletes records has profile 47. let's schedules doesn't have 47, whole query doesnt delete other records other tables. basically want delete regardless of whether or not schedules has record. the other option query database check schedules table before doing delete query? use outer join access tables might not have supporting records: delete p, i, s using profile p left join images on i.profile_id = p.profile_id left join schedules s on s.profile_id = p.profile_id p.profile_id = 47 here's good primer on joins .

ruby on rails - Guard Compile contents of dir to dirname -

i'm using guard compile coffee-scripts in rails 2.3.8 app. i using bistro_car bundles, scripts organized in app/scripts/{bundle_name}/{bundle_files} what compile {bundle_files} public/javascripts/{bundle_name}.js don't have re-organize everything. any ideas on how approach this? the closest can using coffee command is coffee -o public/javascripts/{bundle_name}/ --join \ --compile app/scripts/{bundle_name}/*.coffee which result in js file app/scripts/{bundle_name}/concatenation.js . write pretty simple cakefile iterate on bundles.

apache - Need help sending custom info to php global vars -

is possible send custom information $_server[remote_addr]; or $_server[http_x_forwarded_for]; ? want make these vars output custom text. thought editing headers sent browser or sending php script/curl program. don't know how. please tell me if possible , how. you can't change $_server['remote_addr'] that's ip address of tcp connection. way change connect different real ip address. you can send whatever x-forwarded-for header want in http request. header used hint connecting ip proxying request other client. it's not relied upon important.

initialization - Why is this local variable labeled as undefined? - Ruby -

i've got function goes through array of objects, , creates new array of objects based on attributes original array. when run code error in 'nonstop': undefined local variable or method `sort_list' main:object (nameerror) i made sure sort_list array initialized outside of loop, , i've tried initializing size too, keep getting error. i'm pretty new ruby, doing incorrectly? def nonstop(flight_list) index = 0 sort_list[] = nil flight_list.each |curr| if (curr.depapt == argv[2] && curr.arrapt == argv[3]) sort_list[index] = curr index += 1 end end sort_list.sort! { |a,b| a.deptime <=> b.deptime} sort_list.each |curr| puts "#{curr.flightnum}\t#{curr.deptime}\t#{curr.arrtime}" end if (sort_list.empty?) puts "none" end end i think need initialize this: sort_list = [] this doesn't throw error i

lucene.net - Is the order of multi-valued fields in Lucene stable? -

suppose add several values document under same field name: doc.add( new field( "tag", "one" ) ); doc.add( new field( "tag", "two" ) ); doc.add( new field( "tag", "three" ) ); doc.add( new field( "tag", "four" ) ); if later retrieve these fields new instance of document (from search result), guaranteed order of field s in array remain same? field[] fields = doc.getfields( "tag" ); debug.assert( fields[0].stringvalue() == "one" ); debug.assert( fields[1].stringvalue() == "two" ); debug.assert( fields[2].stringvalue() == "three" ); debug.assert( fields[3].stringvalue() == "four" ); current code does, states no guarantees whatsoever, may change @ time. i wouldn't depend on it.

python - How do I insert an attribute using BeautifulSoup? -

how insert attribute using beautifulsoup? for example, insert border="1" tag attribute. edit: i've answered own question (for particular class of table, even): intopic = urllib2.urlopen("file:///c:/test/test.html") content = beautifulsoup(intopic) tlist = content.findall('table', "mytableclass") tbl in tlist: tbl['border'] = "1" print tbl.attrs how about: intopic = urllib2.urlopen('http://stackoverflow.com/questions/4951331/how-do-i-insert-an-attribute-using-beautifulsoup') content = beautifulsoup.beautifulsoup(intopic) tlist = content.findall('table') tbl in tlist: tbl.attrs.append(('border', 1)) do not forget try lxml.html , it's fast , parse well.

osx - Access IB instantiated NSBox in MyDocument from another class? -

i started view swapping code hillegass's book cocoa programming mac os x. code uses popup menu in mydocument.nib swap viewcontrollers using displayviewcontroller in mydocument.m partially shown below. i'm trying instead use rows of table in viewcontroller swap viewcontrollers calling displayviewcontroller in mydocument.m viewcontroller generated table: - (void)displayviewcontroller:(managingviewcontroller *)vc curbox: (nsbox *)windowbox { // end editing nswindow *w = [windowbox window]; bool ended = [w makefirstresponder:w]; if (!ended) { nsbeep(); return; } ... the problem having when call displayviewcontroller viewcontroller need send along interface builder instantiated nsbox in mydocument.nib view can swapped inside nsbox in mydocument.m. need able access interface builder instantiated nsbox in mydocument.nib viewcontroller. does know how access interface builder instantiated nsbox in mydocument.nib viewcontroller? edit: i've

javascript - Can't nest links in html5? -

in xhtml nest lists, close tag begin new before closing tag. technique makes list structure clear when rendered without css , it's convenient structure applying js to. today come against problem nesting links in html5 document: <header> <nav> <a href="#">a link</a> <a href="#">a link <ul> <li><a href="#">nested link</a></li> <li><a href="#">nested link</a></li> <li><a href="#">nested link</a></li> </ul> </a> </nav> </header> which doesn't work. nested list nested in tag. so technique used regularly in xhtml doesn't work in html5. question do in situation want create flyout menu? there technique can use in html5 make easy in xhtml? know can create flyout menu without nested links liked con

.net - help in c# and webclient class -

i need enable cookie webclient ( windowsform project ) i found solution in link using cookiecontainer webclient class but can not understand how apply ? should create new class (it not work) or need change variables make suitable project ? i need explain me how apply it, , if have solution supply me it. this it: public class cookiemonsterwebclient : webclient { public cookiecontainer cookies { get; set; } protected override webrequest getwebrequest(uri address) { httpwebrequest request = (httpwebrequest)base.getwebrequest(address); request.cookiecontainer = cookies; return request; } } also check out previous answer similar topic here .

jquery - How do I alphabetize and sub alphabetize this list? -

using jquery, how alphabetize , sub alphabetize file? http://see.weareinto.com/4ukn adding small sample of large html file. <div class="two-col" id="content_well"> <ul class="hierarchyleft3 filtererd"> <li><a href= "/health-professionals/programs/center-for-outcomes-research-and-educati/pages/default.aspx"> center outcomes research , education (core)</a></li> <li> <a href="/health-professionals/programs/camp-erin/pages/default.aspx">camp erin</a> <ul> <li><a href= "/health-professionals/programs/providence-hospice-bereavement-services/pages/default.aspx"> providence hospice bereavement services</a></li> <li><a href= "/health-professionals/progr

actionscript - targeting sprites from a method in the document class - null object reference -

i trying code flash app entirely in document class. using gestureworks touch screen. when user presses button calls method should hide specific graphic not graphic touched. essentially need way refer graphic on screen using method besides 'e.target'. i receiving error: error #1009: cannot access property or method of null object reference. //this code works private function photo1spriteflickhandler(e:gestureevent):void { var opentween:tween = new tween(e.target, "x", strong.easeout, 232, 970, 5, true); } //this code gives me null object reference private function photo1spriteflickhandler(e:gestureevent):void { var opentween:tween = new tween(photo1sprite, "x", strong.easeout, 232, 970, 5, true); } //photo1sprite has been programatically added screen so: var photo1sprite = new touchsprite();

iPhone - Using OpenGL to create apps - What is a good wrapper or low-level engine to use? -

i'm working on couple apps require use of opengles 2.0. made prototype of 1 starting simple sample project. however, wasn't happy clutter of opengl code caused. think clutter cause issues if kept extending code. so- there solution working opengl on higher level? don't need complexity , overhead of game engine. frustrated can't deal opengl this: shaderprogram shader(fragmentcode, vertexcode); renderbuffer renderbuffer(xresolution, yresolution); you'll have pardon shameless self-promotion, i've been working on just such framework due exact frustrations you've been having. grew tired of nonsense of having initialize resources , clean them up. here sample xpg framework. xpg::texture2d tex("texture.jpg"); // automatically cleaned tex.bind(); // ready use i have built similar objects things vertex buffer objects (vbo). still working on it, opengl tools benefit greatly. have yet see framework make things simple. if knows of one

Executing Error in python -

import unittest service = ('u', 'urn:schemas-upnp-org:service:switchpower:1') binary_light_type = 'urn:schemas-upnp-org:device:binarylight:1' def on_new_device(dev): """ callback triggered when new device found. """ print 'got new device:', dev.udn print "type 'list' see whole list" if not dev: return def get_switch_service(device): return device.services[service[1]] def create_control_point(): """ creates control point , binds callbacks device events. """ c = controlpoint() c.subscribe('new_device_event', on_new_device) c.subscribe('removed_device_event', on_removed_device) return c def main(): """ main loop iteration receiving input commands. """ c = create_control_point() c.start() run_async_function(_handle_cmds, (c, )) reactor.add_after_st

apache - SSI parser written in PHP? -

ok, might sound little crazy, bear me here minute. i'm working on site standard use ssi include page headers, footers, , menus. included files use ssi conditionals handle different browsers, #include nesting, , #set / #if trickery highlight current page in menu. in other words, it's more #include directives in ssi. i'm sure might argue aesthetics, works quite nicely, static html. now, problem: i'd "#include" same ssi-parsed header , footer html files php scripts, avoiding code duplication , still maintaining site's uniform look. if php running in usual mod_php environment, i'd able using php's virtual() function. unfortunately, site using fastcgi/suexec run php (so each virtualhost can run different user), , breaks virtual(). i've been using simple ssi parser wrote in php (it handles #includes, , simple #if statements), i'd more general solution. so, before go nuts , write probably-buggy, more complete ssi parser, know of

syntax - What does the @ symbol mean for Objective-C? -

i know following uses of @ (at symbol): @"mystring" - used indicate objective-c nsstring, rather standard c string @keyword - used identify objective c keywords such @implementation, @synthesize, @class , @interface what @keyname mean in context below? [sfhfkeychainutils storeusername:@keyname andpassword:[nsstring stringwithutf8string:b64data] forservicename:@"default" updateexisting:yes error:&ter_ror]; does @ have other possible meanings? it means nothing @ in context of code snippet. fail syntax error. the reason @ used in obj-c keywords , in constant strings because @ not valid character use part of token in c, , obj-c strict superset of c. means valid c code valid obj-c code, obj-c can't take keywords have possibly shown in valid c. since @ isn't valid in tokens, means obj-c use start of keywords , not worry collisions. as other possible meanings, there few keywords omitted, such @protocol , @dynamic , @private , @protect

jquery - How do I reload a shoutbox's messages whenever any one of the chatroom users posts a message? -

i'm creating shoutbox using jquery, ajax, , php. know how make message box refresh every 1 second or set time interval, without refreshing rest of page, want have message box refreshed every time of participating chatroom users posts messages. how do this? or setting refresh rate @ short interval (like 0.2 seconds) better option? (i thinking might hard on server load, text chat box i'm not sure. i'm writing application practice coding skills i'd appreciate general guidance.) since nature of shoutbox is "listener", there's no real way push update remote webpage without page checking see if update required. check every second should sufficient, wouldn't go more frequent maybe .5 seconds.

php - what is the difference between a class and a library? -

i googled, , informed library made of multiple relevant classes. in codeigniter, found there virtually 1 class in every library. sorry limited knowledge this, appreciate if enlighten me little bit on this. thank much! the difference semantic one. a class implementation of specific piece of functionality (usually encapsulating functionality. a library collection of units of functionality (or one) add functionality. notice tried stay away word class in definition. libraries can procedural, functional or oop. doesn't detract fact it's library. classes abstraction when dealing oop. a framework library imparts architecture choices on how write code. every framework therefore library. not every library framework. codeigniter can used framework or library. difference if let libraries direct architecture, you're using framework. if not use architecture bit, it's library. it's pedantic difference, significant one. gross-over-simplification,

sql - Oracle - Sorting a VARCHAR2 field like a NUMBER - I found a solution, need explanation on it -

i have varchar2 column want sort numerically. 99% (or possibly 100%) of time contain numbers. looking around , found this solution . quoting source: remember our goal sort supplier_id field in ascending order (based on numeric value). this, try using lpad function. for example, select * supplier order lpad(supplier_id, 10); this sql pads front of supplier_id field spaces 10 characters. now, results should sorted numerically in ascending order. i've played around little bit solution , seems workign (so far), how work, can explain? when sorting strings/varchar, field serted left right, sort normal words. that why have problems when sorting 1 2 3 10 11 20 which sorted as 1 10 11 2 20 3 but, if pad values left, have like 001 002 003 010 011 020 which sort correctly

textview - Android - How to draw a letter at a specific point? -

i want fill screen 100 different letters in random positions. on iphone created bunch of uilabels set x , y positions , used animations move them about. on android doesn't can add textview view , specify x , y. there way this? view gameview = findviewbyid(r.id.gameboard); tv = new textview(gameview.getcontext()); tv.settext("a"); tv.setwidth(w); tv.setheight(h); // how set x , y? edit: solution use absolutelayout: absolutelayout al = (absolutelayout)findviewbyid(r.id.gb_layout); tv = new textview(this); absolutelayout.layoutparams params = new absolutelayout.layoutparams( absolutelayout.layoutparams.wrap_content, absolutelayout.layoutparams.wrap_content,10,10); params.x = 50; params.y = 50; al.addview(tv, params); and move base on motionevent me: absolutelayout.layoutparams p = new absolutelayout.layoutparams( absolutelayout.layoutparams.wrap_content, ab