Posts

Showing posts from July, 2013

java - Selecting a class dynamically at runtime -

im trying come solution class processes "message" selected @ runtime depending on message type. know can use if msg_type = "a" msgaprocessor.execute(message); else if msg_type = "b" msgbprocessoror = execute(message); .... .... .... i dont want use above approach dont want code know message types processing. want able in future add new message processor new message type. solution thinking of @ moment follows there 3 message processors @ moment msgaprocessor msgbprocessor msgbprocessor all 3 classes have method called execute process message in own way. have created interface called msgprocessor , added execute() method in interface. now having difficulty in knowing message processor caller should call without having check message type. example, cant this msgprocessor proc = new msgaprocessor() proc.execute() the above stil required in if statement needs called after finding out message type. avoid instantiating using implementation

.net 3.5 - any way to simulate OUTPUT clause in SQl Server Compact 3.5? -

i implementing email queue system. basic idea store emails in sql ce db , read them through windows service , send them. assuming there 200 rows in db need fetch 10 records first , needed output clause run this update mailqueue set status='fetched' queueid in (select top(10) queueid mailqueue status='queued' order queueid asc) **output** deleted.* if not possible can think of removing rows permanently db , processing them , incase of failure store them in failqueue table. in case can select , delete done using sqlcetransaction class???? if there better way implement please advise. thanking all performing select , update in single sqlcetransaction trick.

Android touch events when screen is dark(ish)? -

i've got samsung galaxy tab, likes dim light on device after half minute. when touch screen, turns on light again, sends touch event whatever view located touched, end clicking on didn't mean click. is there way know screen has dimmed lights, touch events shouldn't sent through views? update: use flag keep_screen_on each activity, don't want to. auto-dimming restrains battery use, if it's possible i'd else. you should able read current brightness setting here: http://developer.android.com/reference/android/provider/settings.system.html#screen_brightness i found quite annoying well, don't know if should app's job fix it.

algorithm - Database Design : Creating database and User Interface for recurring events -

we creating web-application of bus service people search , book seat. want give ui admin s/he can specify recurring trips. for example volvo bus run city1 city2 every day 9:00 except tuesday. there can number of such criteria. how should store such different recurring trips can searched without perfomance hit? how should representd in ui easy admin work with. current database design: table : trip_master trip_id name table : timetable id trip_id city_id arrival_time departure_time seq_no your options a) store entities representing each occurrence of recurring trip (as might populate calendar table row representing each day of year), approach leverages sql or b) store rule representing recurring schedule, require more procedural code throughout application. favor option a), though requires routines populate trip-occurrences table on periodic basis.

xml - How to use XSL to create HTML attributes? -

why using xml data style html tags illegal? example: <li style="width:<xsl:value-of select="width"/>px"> why can't this? there alternative methods out there? why can't this? <li style="width:<xsl:value-of select="width"/>px"> because xsl xml itself . , anything… not xml. you mean attribute value template : <li style="width:{width}px"> or explicit form, more complex expressions: <li> <xsl:attribute name="style"> <xsl:choose> <xsl:when test="some[condition = 'is met']">thisvalue</xsl:when> <xsl:otherwise>thatvalue</xsl:otherwise> </xsl:choose> </xsl:attribute> </li> or dynamic attribute names (note attribute value template in name): <li> <xsl:attribute name="{$attrname}">somevalue</xsl:attribute> </li> additional no

iphone - ASIHTTPRequest on iPad: "The request timed out" -

my application allows user download relatively large files (~120 mb) own dedicated server. i'm using asihttprequest library downloading. it may sound weird, worked fine until yesterday. i've tried downloading files countless times both app (on ipad) , mac, , while on mac download succeeds, on ipad randomly times out. goes until 100%, reaches 30%-40% or , asihttprequest's downloadfailed: selector gets called. if print out error's localizeddescription , "the request timed out". what mean? problem of app? or problem server, or connection? realize depend on several factors, please ask me information need if necessary. thanks. i had weird network situations timeouts on ipad when using wifi started after upgrade 4.2, intermittent. going settings -> general -> reset network settings , reentering wifi settings solved me. (also check hasn't setup new nearby wifi access point on same channel network!)

objective c - create, delete folders and cut and copy files -

is there tutorials following: create , delete folders @ main bundle of application remove folders document folder specific folder list folders @ main bundle any suggestion , please read nsfilemanager class reference. you can nsfilemanager instance doing: nsfilemanager *filemanager = [nsfilemanager defaultmanager]; by example can delete file by: nserror *error; [filemanager removeitematpath:mypath error:&error]; see here class reference: class ref

Setup Eclipse for BlackBerry development -

i want start blackberry development. blackberry site found eclipse development. since have previous experience eclipse decided go it. problem not able download eclipse plugin blackberry. which version of eclipse using? recommend eclipse galileo 3.5 bb development. once installed, click > install new software > , add following website work with: http://www.blackberry.com/go/eclipseupdate/3.5/java this should give list of available jre versions bb development, select version depending on os of device want develop for, 5.0 common @ moment. click next , go through steps, asked log in eventually, use credentials bb development website , register @ " register access blackberry developer zone " page. you should go there! remember when making new project select new > other > blackberry project. remember set jre blackberry jre downloaded if it's not done automatically.

Android SQLite with Triggers tutorial debugging -

i've been keen learn triggers in android , sqlite. found great tutorial at: http://android-pro.blogspot.com/2010/10/using-sqlite-database-with-android.html however, having imported project eclipse , tried running it, error: android.database.sqliteexception: no such column employeename while compiling: select _id,employeename, age, deptname viewemps deptname=? this occurs when trying view information database after selecting items foreign key. e.g. add person dept it. go view screen, select , error occurs. the author of tutorial has tried solve issue saying increase database version doesn't seem have worked anyone. part of code causes error seems this: db.execsql("create view "+viewemps+ " select "+employeetable+"."+colid+" _id,"+ " "+employeetable+"."+colname+","+ " "+employeetable+"."+colage+","+ " "+depttable+"."+coldeptname+""+ &qu

c# - Accessing the file system from a WCF service hosted in IIS -

i have need read , write files on server file system within wcf service hosted in iis. service called via silverlight 4 application , ria services. file paths can fixed known location on server having issues getting passed security issues , continue "access denied" errors. application uses forms authentication , web server configured anonymous access. we haven't gotten passed issue in our development environment , i'm assuming in production can specify specific account in iis host site under , grant account specific rights file system. in development using vs 2010 development web server our options? our goal simple creating new files or deleting files known path on server (i.e. "c:\temp\") within method call wcf service. it's acceptable temp folder underneath virtual directory. your best option here: don't use dev server this; use iis. fighting tooling issues in unrelated trying waste of time, try mimic deployment environment cl

tsql - Can I create an index on User-defined Table variables? -

just wanted check, if able create indexes on user-defined table variables. know can create pk on udt. imply pk creates (clustered) index internally? if index possible on column on udt, indexed data stored? with table variables, can define primary key , unique constraints , unable define clustering behaviour. indexes these stored alongside actual data in table variable - in memory within tempdb, if necessary, spilled disk, if memory pressure high. you're unable define arbitrary indexes on such tables.

sql - mysql query room availability -

having looked @ of other mysql availability query questions on here has got me far, way mine works different others. basically have table of dates, , each date row. each row contains fields cost, room type, , how many days booking has to book on date. if hotel has 1 room type, have 365 rows, if has 5 room types, have 1825 rows bd_id int(10) no pri null auto_increment bd_room_type varchar(32) bd_date date no bd_price decimal(8,2) bd_h_id int(8) no /* hotel id */ bd_available tinyint(1) /* number of days must book include date */ i , dates, , fill in gap in between have dates booking. $q1 = "select bd_h_id booking_dates bd_date in ('2011-02-16','2011-02-17','2011-02-18') , bd_available <= '3' , bd_room_type = 'single' , bd_price > '0' group bd_h_id having count(*) = '3'"; so if count same duration, means dependencies have been met , can show result in search. i passing query variabl

Silverlight 4 memory leaks -

i have silverlight 4 application has leaky viewmodel class. have confirmed using windbg , !gcroot command on viewmodel type. unable pin point exact cause of memory leak have attempted resolve using following line of code in corresponding view when closed: htmlpage.window.navigate(new uri(mytopleveluri)); this forces app restart , hence rootvisual reinitialised. when use windbg can see there no more references holding onto viewmodel class after view has closed. however, when monitor memory use of app (using sysinternals) continuously increases. may drop if keep opening , closing suspect view end private byte memory set of on 1,000,000k. also, if add code force gc, never recovers memory allocated. should worried? are there inherent memory leaks sl4 , controls? don't have faith given patch released fix memory leaks datatemplates (version 4.0.60129.0 http://timheuer.com/blog/ ). it appears answer original question (are there inherent memory leaks sl4?) i

android - how i can get width and height dimension from my customview? -

i have custom view ... package nan.salsa.goal.customview; import android.r; import android.content.context; import android.graphics.canvas; import android.graphics.drawable.shapedrawable; import android.graphics.drawable.shapes.rectshape; import android.util.attributeset; import android.util.log; import android.view.view; public class dayview extends view { private static string tag="dayview"; private shapedrawable mdrawable; public dayview(context context) { super(context); } public dayview(context context, attributeset attrs) { super(context, attrs); init(); } public dayview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); init(); } public void init() { int x = 10; int y = 10; int width = 300; int height = 300; mdrawable = new shapedrawable(new rectshape()); mdrawable.getpaint().setcolor(0xff74ac23);

Delete App (.apk) in emulator? -

i know of 2 ways of deleting app under development emulator: using emulator gui: settings > applications > manage applications > uninstall using adb: adb uninstall i may have discovered third way, using 'adb shell': rm /data/app/<package>.apk it seems, however, isn't way delete apps because there may additional information associated (registration?). what information , can found? it's interesting mention this. ran quick home made test shed light onto question. generally, when install .apk file, android creates internal storage area located @ /data/data/< package name of launching activity>. used internal caching area cant accessed other apps or phone user. can read in little bit more detail in internal storage chapter of androids data storage section. area exclusively used app , can write private data there. once uninstall app theoretically, internal storage area deleted. first 2 ways outlined indeed that: .apk file in

TimePicker Minimum value Silverlight -

i wan't use timepicker setting minimum posible value, user can't choose other after value. like displaydatestart in datepicker. you can use minimum , maximum properties of timepicker control in silverlight limit times displayed in drop down menu. starttime.maximum = endtime; endtime.minimum = starttime; here starttime , endtime 2 timepickers

Extract current facebook username using iOS SDK 4 -

i using graph api facebook user information follows: [facebook requestwithgraphpath:@"me" anddelegate:self]; how can this? know server response in form of json object don't know how parse it. i have answered question here how retrieve facebook response using facebook ios sdk

Handle screen orientation in android? -

me new android developments, tell me how handle screen orientation in android. have done android:configchanges in manifeast file,also override onconfigurationchanged method. but went wrong. if any1 having demo app can learn . thnx help this series of article might prove useful.

iphone - Autoresizing of UILabels in a UITableViewCell -

i adding own uilabel s contentview of uitableviewcell because need more control on layout default uitableviewcellstyles provide. in essence want detaillabel have priority on textlabel textlabel gets truncated. i have following code in uitableviewcontroller : - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring * const kcellidentifier = @"customcell"; uitableviewcell * cell = [tableview dequeuereusablecellwithidentifier:kcellidentifier]; uilabel * titlelabel, * datelabel; if(cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:kcellidentifier] autorelease]; cell.accessorytype = uitableviewcellaccessorydisclosureindicator; titlelabel = [[[uilabel alloc] init] autorelease]; titlelabel.tag = ktitlelabeltag; titlelabel.autoresizingmask = uiviewautoresizingflexiblewidth; datelabel = [[[uilabel all

javascript - Get an alert box to popup at the jquery event $(document).ready in smarty template -

i'm juuuuuust trying pop displaying test when document ready. i've managed google maps working on page somehow lot of pain. here's code: <html> <head> [...] <script type="text/javascript" href="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> {literal} <script type="text/javascript"> $(document).ready(function () { alert ("test"); }); </script> {/literal} </head> [...] </html> what should popup message? tried copy pasting working jquery page without success. changing <script href=...> <script src=...> works charm me.

How to cancel click event of container div trigger when click elements which inside container in JQuery? -

e.g <div class="container"> <div class="inside">i not fire when click me</div> </div> $('.container').click(function(){ // container here }); but,when click div inside trigger container's click event because div inside container, , need way prevent container event trigger when click on inside div! thank much!! as more general solution, should check e.target in container 's click event handler. $('.container').click(function(e) { // if want ignore clicks inside `.container` div: if (!$(e.target).hasclass('container')) return; // or, if want `.inside` div not fire event, if ($(e.target).hasclass('inside')) return; // container here }); this way you're not preventing propagation of event, break bound live handlers.

osx - How to attach MacOSX Shark to a process as soon as it starts? -

is there way tell shark attach process (by name) sees running ? that wouldn't useful feature, since can't predict how time pass between program starting , shark being able attach it. why don't have shark launch program instead?

Java Email Templates with UI? -

my website, built in java/jsp, need send 5-10 predefined emails , adhoc emails registered. i'm looking avoid 'reinventing wheel'. i'd prefer if email templates managed wysiwyg type of gui. far i've read (velocity, freemarker, etc) ok predefined templates, don't have ui , don't adhoc emails. just curious best off writing myself or there out there can help? why need gui craft emails? best keep email content simple possible instead of embedding html tags in it. if user decides open email plain/text, see bunch of ugly tags. using template engine such velocity or freemarker way go craft email template. adhoc emails, may want keep header , footer same using email template , can swap out body content adhoc messages. in project, have email template using velocity, this:- exception-email.vm file ** please not reply message ** project administrator has been notified regarding error. remote host : $remotehost server : $servername request

Socket servers, SocketAsyncEventArgs and concurrent connections in .Net -

i've been writing socket server based around 1 on codeproject derives original microsoft example . in both cases, inbound message returned sender using same socketasynceventargs . in case, need send inbound message off further async processing prior replying client. the problem returning response may try use same socketasynceventargs @ same time further message client. when happens exception: "an asynchronous socket operation in progress using socketasynceventargs instance" so, (i believe) need separate pool of socketasynceventargs messages going out. understandable far. my problem i'm not sure how create outbound socketasynceventargs relates closely inbound one. how of inbound 1 can reuse? e.g. if point @ same acceptsocket, there trouble while messages travel in both directions simultaneously? does have example code of how derive outbound socketasynceventargs inbound one? or missing point? these socketasynceventargs objects, can use t

function - jquery toggle() on DIV by hiding other div's -

i using following code toggle div clicking on block heading. need make respective div appear on click of respective block headings. div should toggle themselves. <!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> <style type="text/css"> { color:#c30; text-decoration:none; } #banner { width: 930px; background-color:#666; height: 500px; } #banner ul { list-style:none; padding: 40px; } #banner ul li { margin: 10px 0 0 0; } #banner ul li { display:inline-block; border:5px solid #fff; background-color:#fc9; padding:10px; font: bold italic 18px verdana; } .slidercontent { border:5px solid #fff; background-color:#fc9; padding:10px; min-height: 150px; display:none; margin-top:5px; } .slidercontent { padding:0 !important; border:none !important; } .slidercontent a.closebutto

iphone - Customize the position of group in UITableView -

is possible customize position of groups in uitableviewcontroller ? example, drawing groups horizontally or customize space inside 2 groups. thanks. if targeting ios 6+, uicollectionview implements features looking for. can horizontal layout out of box , uicollectionviewlayout allows customize display , positioning of items. if targeting ios 4.3+, there third-party implementation of called pstcollectionview . the uicollectionview class manages ordered collection of data items , presents them using customizable layouts. collection views provide same general function table views except collection view able support more single-column layouts. collection views support customizable layouts can used implement multi-column grids, tiled layouts, circular layouts, , many more. can change layout of collection view dynamically if want.

git - Using GitHub behind a firewall without SSH access -

i want use github, company has locked down. now, can use tortoise svn through http protocol. can use github same way? if so, how? i think you've been able clone github repositories on http, restriction couldn't push them. however, github have introduced smart http transport, can push on https. should work fine behind firewall. there's more on smart http support in blog post: https://github.com/blog/642-smart-http-support to give short summary - if click http button on "source" tab of repository, it'll give url like: https://mhl@github.com/mhl/unicode-poster.git if clone url, it'll prompt github password whenever need communicate server (e.g. git clone , git fetch , git push , etc.) however, can clone using url like: https://mhl:notactuallymypassword@github.com/mhl/unicode-poster.git ... , won't need re-enter password. (as blog post mentions, make sure you've got https:// @ start of url, , aware means gith

.net - To check wether a specific project reference exists (C# Code, Preprocessor Directives ...) -

i'm new c# / .net hope there solution problem. i'm working 2 different image-processing libraries have own classes represent images. because don't want use classes in own (private) class library, want implement own "myimage"-class supposed wrapper around both of other classes. (i have of course add functionality of libraries if missing). my problem this: myimage-class needs reference both libraries compile, use myimage-class in projects 1 library available. find not difficult "add" or "remove" references image class project, don't want comment out code refers missing library. so question is: somehow possible determine wether reference set preprocessing directive or attributes or code directly? or there better solution problem (a clever class design maybe?) thanks help i don't think there's preprocessor directive tell if reference has been added. you split class 2 separate classes, 1 each library, suspect inten

.net - Debugging F# applications using Visual Studio -

i need use visual studio in order debug f# application. need do? i know entrypoint attribute not simple that. first of build application in viual studio, not know how tell him file must last in compilation order. furthermore, if succeeded in compiling, how start visual studio debugger? my main need using debug tools breakpoints , more in ordeer follow function of mine works. thankyou ps: vs2010 :) if put file containing entry point @ bottom of project explorer tree, becomes last in compilation order. can use shortcut key atl + down/up arrow or drag , drop. once done, set breakpoints , can start debugging.

javascript - Open fancybox from function -

i trying open fancybox function have - in short html code looks this; <a href="#modalmine" onclick="myfunction(this); return false;"> click </a> and part of function looks this; function myfunction(me) { $(me).fancybox({ 'autoscale': true, 'transitionin': 'elastic', 'transitionout': 'elastic', 'speedin': 500, 'speedout': 300, 'autodimensions': true, 'centeronscroll': true, }); } the above works in ie not in firefox or chrome - idea how can fix this? know 1 why trigger link, hope solution possible. since you're using jquery, stop binding event handlers in html, , start writing unobtrusive javascript. $(document).ready(function () { function myfunction(me) { $(me).fancybox({ 'autoscale': true, 'transitionin': 'elastic',

c# - Issues with Dynamic Search Expressions in EF -

i using data structures similar following: public class individual { //other properties omitted brevity sake public list<individualname> individualnames {get; set;} } and public class individualname { public string familyname {get; set;} public string givenname {get; set;} public string middlename {get; set;} } i attempting use dynamic search expressions pass presentation layer repository level (to apply search). however, have run issues due fact individual can have 1-m individual names, , trying use linq grab of individual's individualnames can queried. for example's sake - expression looks like: searchexpressions.add(new searchexpression("individual .individualnames .select(givenname) .firstordefault()" , comparisonoperator.contains, "test"); this determine i

python - code for counting number of sentences, words and characters in an input file -

i have written following code count number of sentences, words , characters in input file sample.txt, contains paragraph of text. works fine in giving number of sentences , words, not give precise , correct number of characters ( without whitespaces , punctuation marks) lines,blanklines,sentences,words=0,0,0,0 num_chars=0 print '-'*50 try: filename = 'sample.txt' textf = open(filename,'r')c except ioerror: print 'cannot open file %s reading' % filename import sys sys.exit(0) for line in textf: print line lines += 1 if line.startswith('\n'): blanklines += 1 else: sentences += line.count('.')+ line.count ('!')+ line.count('?') tempwords = line.split(none) print tempwords words += len(tempwords) textf.close() print '-'*50 print "lines:", lines print "blank lines:",blanklines print "sentences:",sentences print

javascript rollover image - (how) can I set css styles for onmouseover image? -

newbie here pls patient :) i have image (image#1) aligned against far left of page (all body padding , margins set 0) , have added rollover javascript new image (image#2) appears in place on mouseover. image#2 larger image#1. at moment, on mouseover image#2 appears not aligning far left against page (the default page margins seem have been re-introduced , body css rules ignored). is there anyway of applying id image#2 can control css styles it? or other way of removing margin appears on mouseover? 2 images overlap @ far left corner. help appreciated. thanks! <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> </head> $('img#id').mouseover(function(){ $(this).css("property","value"); }); it requires jquery.. ////////////////////////////////////////////////////////////////////////////////////// var elem = document.getelementbyid("id"

.net - Determine a SQL Server Database Column’s Default from C# -

i need find default value of column in sql server 2005 or 2008 database .net. my first attempt execute stored procedure: sp_help @objname where @objname table. in seventh table returned (the constraints table), going use value in constraint_keys default constraints. when run query sql server management studio behaves intended, when run c# code, column constraint_keys null (although other columns populated). my second attempt use: select name, [text] syscomments com inner join syscolumns col on com.id = col.cdefault col.id = object_id(@table) , col.cdefault > 0 which works fine in sql server management studio. when run .net, however, returns no rows. additional: example .net code (using enterprise libraries): private datatable getdefaults(string tablename string database) { var db = databaseel.create(database); string sql = @" select name, [text] syscomments com inner jo

facebook - FQL and business hours -

i'm querying information facebook page small business using fql , i'm trying parse business hours. numbers getting seem represent seconds i'm not sure when epoch is. wednesday , thursday confusing - open on thursday "57600" 16 hours in seconds make 4pm wednesday epoch, closing hours on wednesday - far past 4- in 600,000+ range. mon: 8:15am-12pm , 1pm - 5pm tue: 8am-12pm , 1pm - 5pm wed: 8am-12pm , 1pm - 9pm thur:8am-12pm , 1pm - 5pm fri:8am-12pm , 1pm - 5pm sat:8am-12pm , 1pm - 5pm <hours> <mon_1_open>404100</mon_1_open> <mon_1_close>417600</mon_1_close> <tue_1_open>489600</tue_1_open> <tue_1_close>504000</tue_1_close> <wed_1_open>576000</wed_1_open> <wed_1_close>590400</wed_1_close> <thu_1_open>57600</thu_1_open> <thu_1_close>72000</thu_1_close> <fri_1_open>144000</fri_1_open>

c# - Is it normal practice to have intermediate type(s) just for data binding purposes? (WPF) -

i have collection of types model system. want show functionality of system in gui (wpf). relationship between actual types isn't databindable is. is normal practice have intermediate type(s) data binding purposes? say like: public class effectuielement { .name <string> .type <enum> .usage <string> } where these values aren't in 1 place several, has pulled seperately. is normal practice have intermediate type(s) data binding purposes? yes. "viewmodel" in mvvm (model-view-viewmodel). mvvm pattern allows create viewmodel used expose model (your original data, can come 1 or more sources) view via data binding.

.net - How to properly dispose objects created with LINQ -

i have following method creates instances of objects disposable. public overridable sub transformxmldocumentstofilestream(byval stream system.io.stream, byval xmldocuments ienumerable(of string), byval transformcontext xsltransformcontext) dim readers ienumerable(of xmlreader) = _ (from document in xmldocuments _ select xmlreader.create(new system.io.stringreader(document))) transformcontext transformxmldocumentstofilestream(stream, readers, transformcontext) end end sub i iterate on objects in method: for each reader in readers using reader transform.transform(reader, writer) end using next the visual studio code analyzer giving warning: ca2000 : microsoft.reliability : in method 'transformhelper.transformxmldocumentstofilestream(stream, ienumerable(of string), xsltransformcontext)', object 'new stringreader(document)' not disposed along exception paths. call system.idisposable.dispose on object &#

css - aligning my image and text in two columns not working -

<img id="story_image" src="images/builder_story_side.png" alt="photo"/> <div id="story_right"> <h2 class="story_header">fdgdfgdfgdfgdfgfdgdfgfdgdfgdfgdfgdfgdfgdfgdfgdfgdfgfdgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfg</h2> <p class="small_story">fdgdfgdfgdfgdfgfdgdfgfdgdfgdfgdfgdfgdfgdfgdfgdfgdfgfdgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfgdfg</p> </div> img#story_image{float:left;} div#story_right{float:left;} i've done 2 columns before, reason time it's not working. want image in column 1 , text in column two. story_right ends below image if story_image block. to float elements, need set width on elements want float. set pixel , dynamic percentage widths can both used. reason giving problems because default width of div 100%, image can't float next it.

how to save settings in vb.net -

how save settings app uses ? should use sql, xml , access or other flexible & easy way. please provide sample code same here go: http://www.xtremevbtalk.com/showthread.php?t=131671

c# Deserialize JSON list of object error -

when deserialize list of object work when deserialize object list type errors out. idea how make work? page name: testjson.aspx using system; using system.collections.generic; using system.web.script.serialization; namespace web.json { public partial class testjson : system.web.ui.page { protected void page_load(object sender, eventargs e) { string json = "[{\"sequencenumber\":1,\"firstname\":\"fn1\",\"lastname\":\"ln1\"},{\"sequencenumber\":2,\"firstname\":\"fn2\",\"lastname\":\"ln2\"}]"; //this work ilist<person> persons = new javascriptserializer().deserialize<ilist<person>>(json); //this error //people persons = new javascriptserializer().deserialize<people>(json); response.write(persons.count()); } } class person {

c# - IQueryable<T> cast to IList<SpecificInterface> -

setup public interface itable { } public class company : itable { public int id { get; set; } public string name { get; set; } } public class paginationgridmodel { public paginationgridmodel(ilist<itable> rows) { //cool stuff goes here } } public gridmodel generatemodel<t>(iqueryable<t> table) t : itable { return new gridmodel((ilist<itable>)table); } //actual call return generatemodel<company>(this.datacontext.companies); exception generated unable cast object of type 'system.collections.generic.list`1[company]' type 'system.collections.generic.ilist`1[itable]'. question since company implements itable should able convert list<company> ilist<itable> doesn't want work because it's t . t constrained in function definition itable . doing wrong here? when i'm not using generics setup works fine. wanted generic setup because i've been writing same code on , on - bad

python - Trouble Querying Against int Field using MYSQL -

hey, i'm trying run following query: self.cursor.execute('select courses.courseid, days, starttime, bldg, roomnum, ' 'area, title, descrip, prereqs, endtime ' 'classes, courses, crosslistings, coursesprofs, profs ' 'classes.courseid = courses.courseid , ' 'courses.courseid = crosslistings.courseid , ' 'courses.courseid = coursesprofs.courseid , ' 'coursesprofs.profid = profs.profid , ' 'classes.classid %s' ';', (self.classid)) classid int(11) field in db. when set self.classid = %, returns results, set say, '3454' or other amount returns nothing when there class classid. querying incorrectly against int fields? even simpler query select * classes classes.classid = '3454'; not work try: sel

browser - How can I embed windows media player without the visualizations -

i enjoyed late 90s as last guy, i'd able play audio file on web page without having @ cheesy geometric visualizations wmp shows. there way of doing this? here's code: <object classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6"> <param name="url" value="file.wav" /> <param name="autostart" value="true" /> <embed type="application/x-mplayer2" src="file.wav" name="mediaplayer"> </embed> </object> one temporary solution i've found set height parameter 45, ends showing controls @ bottom. microsoft decides change layout though, won't right. argh!

html - Set value of select element based on GET parameters, without JavaScript? -

here's basic html question you: <form method="get" action="#"> <select id="u" name="u"> <option value="nothing" title=""></option> <option value="adamt" title="at">adam temple</option> <option value="alexp" title="ap">alex potts</option> </select> <input type="submit" /> </form> after submitting form, url ends ?u=adamt . however, list has reverted blank element. is there way make list pre-selected correct option, without using javascript? add selected (its boolean attribute) appropriate <option> element in whatever server side language use process form.

contacts - Sizes For iPhone AddressBook Pictures? -

i programmatically generate contact pictures - gravatar does, although not exactly. are there size requirements on generated images such contact picture full-screen when user calls? there differences these size requirements between iphone 3/gs , iphone 4? i presume setting pictures using abaddressbook api provide no hurdles. in both cases - iphone 3 , iphone 4 (with retina display) wound setting image size 640 x 960. when set profile picture 320 x 480 iphone 3, image didn't scale fit full screen. so there go!

what is this error when deploying google python-appengine application? -

this error message .. appreciated . 2011-02-23 23:09:11 running command: "['c:\\python25\\pythonw.exe', '-u', 'c:\\program files\\google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=adham587@gmail.com', '--passin', 'update', 'c:\\users\\adham\\desktop\\images']" application: refacingme; version: 1. server: appengine.google.com. scanning files on local disk. initiating update. 2011-02-23 23:09:42,223 warning appengine_rpc.py:405 ssl module not found. without ssl module, identity of remote host cannot verified, , connections may not secure. fix this, please install ssl module http://pypi.python.org/pypi/ssl . learn more, see http://code.google.com/appengine/kb/general.html#rpcssl . password xxxxx@gmail.com: error 409: --- begin server output --- transaction user xxxxxxxx in progress app , major version. user can undo transaction appcfg.py's "rollback" command. --- end server output

sql server - Access SQL: solving error 3612? -

i'm trying create report on ms access. query originating report following: select t1.[order], t1.[hours], t1.[hours]/(select count(*) t2 t2 cstr(t1.[order]) = cstr(t2.[order])) espr1 t1; an example of data tables are: t1.[order] | t1.[hours] 1 | 100 1 | 100 2 | 300 2 | 300 2 | 300 t2.[order] | t2.[hours] 1 | 100 1 | 100 2 | 300 2 | 300 2 | 300 t1.[order] , t1.[hours] integer types. t2.[order] , t2.[hours] string types (please, don't ask!) the query executed correctly. creates additional column espr1 containing partition of t1.hours (or t2.hours) depending on count of lines having same order value. for example: [order] | [hours] | [espr1] 1 | 100 | 50 1 | 100 | 50 2 | 300 | 100 2 | 300 | 100 2 | 300 | 100 but when create text box in report the following source: = dsum([espr1]) ms access give me the error 3612 , not declares group clausole! someone of you, experienced programmers have

c++ - std::string messed up when using it as storage within (boost.)async_read_some -

i using async_read_some read data port saved in char[] called _data. buffer size big enough every request: void start() { socket_.async_read_some(boost::asio::buffer(data_,buffersize),make_custom_alloc_handler(allocator_,boost::bind(&attentionsession::handle_read, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); } void handle_read(const boost::system::error_code& error, size_t bytes_transferred) { string ip = socket_.remote_endpoint().address().to_string(); log->processdata(data_,ip,"memory"); strcpy(data_,""); } processdata adds additional information (like timestamp etc.) request copying newly alloced char*. char[] sent writetomemory(char*) append char* std::string memorybuffer: void writecachetofile() { // function writes buffer data log file char* temp = new char[memorybuffer.length() + 1]; strcpy(temp, memorybuffer.c_str()); writetofile(temp); d

database - What is the best way to make significant DB changes to an existing symfony project? -

i have large live database. best practices making schema (doctrine) changes? when doing development can build-all , reload fixtures , fine if data structure changes can manually adjust fixtures reload correctly. how do large live database thousands of records? if pull changes prod server , data dump rebuild , reload schema changes prevent data reloading (especially if have removed column). there standard way of handling sort of thing? i find table row ordering not preserved when reloading way. look doctrine migrations, made for. can't specifics, i'm propel guy.

python - Jython and the SAX Parser: No more than 64000 entities allowed? -

i've done simple test of xml.sax parser in jython on large xml file (800 mb) , encountered following error: traceback (most recent call last): file "src/project/xmltools.py", line 92, in <module> sys.exit(main()) file "src/project/xmltools.py", line 87, in main parser.parse(open(argv[1], "r")) file "/amd.home/home/user/workspace/jython-2.5.2/lib/xml/sax/drivers2/drv_javasax.py", line 146, in parse self._parser.parse(jyinputsourcewrapper(source)) file "/amd.home/home/user/workspace/jython-2.5.2/lib/xml/sax/drivers2/drv_javasax.py", line 59, in fatalerror self._err_handler.fatalerror(_wrap_sax_exception(exc)) file "/amd.home/home/user/workspace/jython-2.5.2/lib/xml/sax/handler.py", line 38, in fatalerror raise exception xml.sax._exceptions.saxparseexception: <unknown>:1:1: parser has encountered more "64,000" entity expansions in document; limit imposed application.

android - Database reference or recreation? -

i have quick performance question: quicker , efficient on memory use static singleton database reference or reopen every time need access something? thanks help, ~aedon in android databases aren't kept in memory keeping reference light on memory, use file locks. using singleton first choice, however, if you're using in service or single activity, doesn't need static. if you're database instance keeps reference context, means avoid making static because source of memory leaks.

windows - Cygwin automatic script launch -

im trying automatically run script using cygwin via cmd. created bat file goes directory , executes .sh file. sh files accosiated cygwin, , tried "cygwin update.sh" in command line. open cygwin. want cygwin automatically run script file. there easy way this, i've been trying find can't. thank you! you'll want call shell script particular shell, e.g. bash. when having cygwin open, call which bash figure out binary located. cygwin comes tools can convert paths between cygwin , win32 form, pretty helpful in cases yours. there 1 other thing may work, depending on setup. there environment variable named pathext declares file extensions deemed "executable" cmd. can used advantage, if windows configured shell's "open" verb executes correct shell file extension .sh (in case). good luck.

c++ - Editing listview control item -

how add or edit listview item double clicking on it? two things. first, have create list view control lvs_editlabels style, shown in using list-view controls . then, when want edit label, send lvm_editlabel message focused label. be sure handle lvn_endlabeledit message in parent.

Git blame -- prior commits? -

i love git blame command, useful tracking down people don't own writing code. :-) however, possible see edited specific line before commit reported git blame , e.g. history of commits given line? for example, run following (on superb uncrustify project): $ git blame -l10,+1 src/options.cpp ^fe25b6d (ben gardner 2009-10-17 13:13:55 -0500 10) #include "prototypes.h" how can find out edited line before commit fe25b6d ? , edited before that commit? sure possible, git-fu weak. git blame -l10,+1 fe25b6d^ -- src/options.cpp you can specify revision git blame starting (instead of default of head ); fe25b6d^ parent of fe25b6d .

c - float vs. double precision -

the following code float x = 3.141592653589793238; double z = 3.141592653589793238; printf("x=%f\n", x); printf("z=%f\n", z); printf("x=%20.18f\n", x); printf("z=%20.18f\n", z); will give output x=3.141593 z=3.141593 x=3.141592741012573242 z=3.141592653589793116 where on third line of output 741012573242 garbage , on fourth line 116 garbage. doubles have 16 significant figures while floats have 7 significant figures? why don't doubles have 14 significant figures? floating point numbers in c use ieee 754 encoding. this type of encoding uses sign, significand, , exponent. because of encoding, many numbers have small changes allow them stored. also, number of significant digits can change since binary representation, not decimal one. single precision (float) gives 23 bits of significand, 8 bits of exponent, , 1 sign bit. double precision (double) gives 52 bits of significand, 11 bits of exponent, ,

itertools - implementing argmax in Python -

how should argmax implemented in python? should efficient possible, should work iterables. three ways implemented: given iterable of pairs return key corresponding greatest value given iterable of values return index of greatest value given iterable of keys , function f , return key largest f(key) i modified best solution found: # given iterable of pairs return key corresponding greatest value def argmax(pairs): return max(pairs, key=lambda x: x[1])[0] # given iterable of values return index of greatest value def argmax_index(values): return argmax(enumerate(values)) # given iterable of keys , function f, return key largest f(key) def argmax_f(keys, f): return max(keys, key=f)

ruby on rails - Every other date -

i have logic print out dates def get_y_axis dates = "" ed = date.today sd = date.today - 30 sd.upto(ed) |date| dates << date.strftime("%b %d") dates << "|" end return dates end it prints this => "jan 24|jan 25|jan 26|jan 27|jan 28|jan 29|jan 30|jan 31|feb 01|feb 02|feb 03|feb 04|feb 05|feb 06|feb 07|feb 08|feb 09|feb 10|feb 11|feb 12|feb 13|feb 14|feb 15|feb 16|feb 17|feb 18|feb 19|feb 20|feb 21|feb 22|feb 23|" the problem need every other day...not every day ideas mark's solution fine, wanted show each_with_index method def get_y_axis dates = [] ed = date.today sd = date.today - 30 (sd..ed).each_with_index |date, i| dates << date.strftime("%b %d") if % 2 == 0 end dates.join("|") end also, in solution, "|" appended after last date. guess dont want that.

java - schedule management -

finally after trial , errors have managed make work wanted. but advice make code more readable , simple seems made lot of unnecessary code archive wanted. what basicly is, if turn on server app @ time schedule task should running, start task , let run time left when should have started otherwise schedule run @ hour supposed run. so if schedule time 13:00:00 , should run 120 minutes , start app @ 13:30 run 90 minutes. if start after time, schedule next day 13:00:00. calendar calendar = calendar.getinstance(); calendar.set(calendar.hour_of_day, hour); calendar.set(calendar.minute, 0); calendar.set(calendar.second, 0); long start_time = calendar.gettimeinmillis() - system.currenttimemillis(); if (start_time < 0) { long minutes = (start_time*-1) / (60 * 1000); if (minutes > 0 && minutes < 120) { runtimeleft = 120 - minutes; threadpoolman

android - TimeZone based on location -

i have following code: msavedtime = new time();//????always returns america/new york double latitude = 40.09596; double longitude = -74.22213; double elevation = 0; timezone timezone = timezone.gettimezone(msavedtime.timezone); my first question is: how elevation information lat\lon combination? second question is: how timezone string lon\lan combination? above code provide timezone string clock on cell phone set (returns america/new york). want string according lat\lon setup me. try code use google time zone api: private string get_utc_datetime_from_timestamp(long timestamp){ try{ calendar cal = calendar.getinstance(); timezone tz = cal.gettimezone(); int tzt = tz.getoffset(system.currenttimemillis()); timestamp -= tzt; // dateformat sdf = new simpledateformat("yyyy-mm-dd hh:mm:ss",locale.getdefault()); dateformat sdf = new simpledateformat(); date

Android - Same Id for multiple widget -

i have multiple activity. of activity have same buttons such "continue" or "cancel" etc. each of have different actions. question is, can use same id button's in different activity? is, can use "android:id="@+id="continue_button" continue button's in different activity. or should use "continue_button_1" "continue_button_2" ........... 'views may have integer id associated them. these ids typically assigned in layout xml files, , used find specific views within view tree...view ids need not unique throughout viewtree, practice ensure @ least unique within part of tree searching. ' (http://developer.android.com/reference/android/view/view.html)

java - How can i fetch any string value in JSP page -

if "id" set value in servlet class how can access value on jsp page. know there several methods helps fetch value using session management tired of it. please me out. thanks in advance. from servlet, set file name in request context: request.setattribute("filename", filenamestr ); in jsp write: <%=request.getattribute("filename")%>

python - Recording keystrokes with pyHook -

i've been trying work time (to keyid print in text, a="a", not a=125.) here code, either prints "none" , prints wrong type, or keyid again. (with different idtoname arguments) import pyhook pyhook import hookmanager pyhook.hookmanager import hookconstants import time import pythoncom def onkeyboardevent(event): print hookconstants.idtoname(event.ascii) hm = pyhook.hookmanager() hm.keydown = onkeyboardevent hm.hookkeyboard() while true: pythoncom.pumpmessages() why not use event.key ? xx