Posts

Showing posts from February, 2015

Json.NET (Newtonsoft.Json) - Two 'properties' with same name? -

i'm coding in c# .net framework 3.5. i trying parse json jobject. the json follows: { "tbox": { "name": "smallbox", "length": 1, "width": 1, "height": 2 }, "tbox": { "name": "medbox", "length": 5, "width": 10, "height": 10 }, "tbox": { "name": "largebox", "length": 20, "width": 20, "height": 10 } } when try parse json jobject, jobject knows largebox. information smallbox , medbox lost. because interpreting "tbox" property, , property being overwritten. i receiving json service that's coded in delphi. i'm trying create c# proxy service. on delphi-side of things, "tbox" understood type of object being returned. inner properties ("name", "length...

c# - Generic string to enum conversion -

suppose enum: public enum syslogsapptypes { none, monitorservice, monitortool }; and here function convert tostring() representation enum : private syslogsapptypes str2syslogsapptypes(string str) { try { syslogsapptypes res = (syslogsapptypes)enum .parse(typeof(syslogsapptypes), str); if (!enum.isdefined(typeof(syslogsapptypes), res)) return syslogsapptypes.none; return res; } catch { return syslogsapptypes.none; } } is there way make generic ?? i tried: private t str2enum<t>(string str) { try { t res = (t)enum.parse(typeof(t), str); if (!enum.isdefined(typeof(t), res)) return t.none; return res; } catch { return t.none; } } but get: 't' 'type parameter', not valid in given context there t.none any ? i think default keywo...

html - Having strange issues with inline inputs in IE -

i've been building form day , doing of dev in webkit browsers because of developer tools. went test in ie , i'm having strange results regards having 3 columns of divs in row. can't seem find fix. has seen issue before (see link below)? http://65.61.167.68/form/ i suggest avoiding use of display: inline-block , since ie 6 , 7 don't implement properly. in case, can solve issue in ff changing line 33 of stylesheet. remove display: inline-block , instead, float left. #paydayform .row .column { float:left; margin-bottom:5px; margin-right:18px; margin-top:5px; width:170px; }

javascript - Node.js return result of file -

i'd make node.js function that, when calls, reads file, , returns contents. i'm having difficulty doing because 'fs' evented. thus, function has this: function render_this() { fs.readfile('sourcefile', 'binary', function(e, content) { if(e) throw e; // have content here, how tell people? }); return /* oh no can't access contents! */; }; i know there might way using non-evented io, i'd prefer answer allows me wait on evented functions i'm not stuck again if come situation need same thing, not io. know breaks "everything evented" idea, , don't plan on using often. however, need utility function renders haml template on fly or something. finally, know can call fs.readfile , cache results on, won't work because in situation 'sourcefile' may change on fly. ok, want make development version automatically load , re-render file each time changes, right? you can use fs.watchfil...

actionscript 3 - Change BorderContainer background color with AS - Flex 4 -

i'm trying change background color , or text color of bordercontainer in flex 4 using action script, have not idea how to. the border container component doesn't seem have properties like: idname.color = "#333333"; idname.backgroundcolor = "#333333"; how might go doing this? thanks! you can set styles (which different properties) in actionscript so: idname.setstyle("backgroundcolor", 0xff0000);

collections - what is the best linq query for this -

i have collection of calendar objects. calendar has property id . ienumerable<calendar> calendarstoview; i have collection of event objects. event objects have property of calendarid ienumerable<calendarevent> events; i want filter events collection return events calendarid in calendarstoview collection. what best way of doing this? do join var eventsiwant = e in events c in calendarstoview c.calendarid = e.calendarid select e

C++ cout fresh array gibberish -

when "cout" empty array, gibberish. why? int main() { char test[10]; cout << test; return 0; } ...returns unicode blather. easy answer i'm sure. since didn't initialize array got garbage value (test[0] printing out). initialize it: int main() { char test[10] = {}; cout << test; return 0; } just note: just because compilers initialize stuff (like compilers initialize ints, floats etc., @ 0) not case, , can garbage value otherwise.

.net - Using C# WinForm to send application registration information to a my gmail -

i have application i'm working on , includes form allows user register it. have information stored in string , information emailed gmail account. searched online , able send using gmail account not has gmail , code requires password sender. is there way this? in code can provide credentials your gmail account can use send emails other accounts. check system.net.mail namespace - can start here: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx

focus - Android layout - ImageView focused, but doesn't show anything on screen (no highlight) -

if set imageview both clickable , focusable, works, have no way tell image focused. what's best way draw orange border around view user knows it's in focus? i tried dropping in linearlayout , setting focusable , clickable instead, didn't have luck. when put margin on it, there's nothing indicate selected. you can use drawable selector background. for example, have gallery_image_bg.xml in res/drawable: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantsize="true"> <item android:state_selected="true"> <shape android:shape="rectangle"> <solid android:color="#e6e4e0"/> <stroke android:width="3dp" android:color="#f9c11e"/> <padding android:left="3dp" android:top="3dp" andr...

uiview - How to do calculations only for visible cells in iPhone? -

i have many cells in table view 500. each , every cells have own images , string paragraphs. draw images & strings of uiview's drawrect method. need calculate image , each string's position (including width & height measure cell height , wrapping areas). if did calculation @ time cells, takes time.. thats not good. want show cells quickly. want calculations visible cells , want show visible cells. calculation other cells should happend in background. 1 more thing, calculations once each cell. once did, store values in array. next time show things according array values, not calculations.. please me it... want know whether possible? if yes, procedure achieve it? thanks in advance... there no "procedure" this. uitableview behaves way. provide callbacks tell how many sections , rows-per-section there are, , how populate each cell. uitableview ask populate cells visible, , recycle cells when scroll off edge (as opposed creating them ad infinitum)....

olap - Flex OLAPDataGrid Sorting -

i'm trying provide default sorting within olapdatagrid component in flex. there appears datacomparefunction on olapattribute, nothing seems trigger calls method. suggestions around using method or others provide sorting of dimensions on olapdatagrid? the issue datacomparefunction not used unless userdatafunction on olapattribute set (see: defaultcubeimpl.as). note edit: guess link defaultcubeimpl.as

visual studio 2010 - Database Explorer option missing in view menu -

Image
i'm not able see "database explorer" link in view or view-other menu. rishi i think you're looking 'server explorer' on view menu. default key binding ctrl+alt+s

mysql - Confusion about varchar datatype -

my server has sql version of 5.0.91-community, have store long string of approx 500 character more or less, thought of going text data type told me slows performance, wanted know more varchar , it's limit. i used think varchar limited 255 characters, read somewhere capable of storing more in newer version i.e >= 5.0.3 , using 5.0.91 think should use? if use varchar(1000) still valid? thank you. the documentation here , varchar has max size of 65,535 in mysql 5.0.3 , later , before 5.0.3 limit 255 note effective size less, the effective maximum length of varchar in mysql 5.0.3 , later subject maximum row size (65,535 bytes, shared among columns) , character set used. you have specify max size, e.g. varchar(1000) . stating varchar isn't enough.

datetime - PHP: Date format conversting string 2010-09-02T09:46:48.78 to dd/mm/yyyy -

i pulling date string api. returned string looks this: 2010-09-02t09:46:48.78 i want convert 02/09/2010 (dd/mm/yyyy) but date_format($note['createdate'], "d/m/y") results in error: warning: date_format() expects parameter 1 datetime, string given in can steer me in right dirtection, ta, jonesy echo date('d/m/y',strtotime('2010-09-02t09:46:48.78')); why make complicated ?!

sql - How to pass a record as parameter for PL/pgSQL function? -

i keep looking answer online cannot find it. i trying pass 1 record on pl/pgsql function. tried in 2 ways. fist way : create or replace function translatetoreadabledate(mrecord dim_date%rowtype) returns void $$ that ouput : psql:requestexample.sql:21: error: syntax error @ or near "%" line 1: ... function translatetoreadabledate(mrecord dim_date%rowtype) ... ^ second way : create or replace function translatetoreadabledate(mrecord record) returns void $$ and there output psql:requestexample.sql:21: error: pl/pgsql functions cannot accept type record someone know how please ? create or replace function translatetoreadabledate(mrecord dim_date) returns void $$ begin select dim_day.name || ' (' || dim_day_in_month.id || ') ' || dim_month.name || 'is ' || dim_week.id || ' week of year. ' "une phrase", dim_quarter.id, dim_year.id dim...

php - Module-specific Controller plugins in Zend Framework -

my zend framework project divided modules. each module has specific controller plugins. now, problem all plugins loaded , registered (and thus, called) - no matter module user trying access. i could test in module , stop execution directly in plugins, have in each , every plugin... is there elegant way register module-specific plugins? or trying solve wrong problem here? this example of module specific plugins taken http://weierophinney.net/matthew/archives/234-module-bootstraps-in-zend-framework-dos-and-donts.html class foomodule_plugin_layout extends zend_controller_plugin_abstract { public function dispatchloopstartup(zend_controller_request_abstract $request) { if ('foomodule' != $request->getmodulename()) { // if not in module, return return; } // change layout zend_layout::getmvcinstance()->setlayout('foomodule'); } } update: in case missed , there other ways li...

database design - mysql: how to write a table of views -

i think question best explained via example: suppose want write webserver streaming music. have following columns in songs table: |song_id|song_name|song_genre|song_length|artist i enable users save playlists, don't want playlists defined explicitly specifying songs in playlist, rather "all songs ringo starr", mean when new songs ringo starr added table, playlist automatically have them. want table called playlists contains list of mysql views. the naive approach have table called playlists , , 1 of it's columns called playlist_query store above example string "select song_id songs artist='ringo starr' . this of course incredibly insecure, suffice in case there no better solution, since application used internaly inside our company few employees programmers know way around mysql. so suggest? go ugly solution, or there easier way this? you store name of view in playlists table instead of query itself. you'd still have create...

jquery - google maps custom markers / shadow help needed -

so have google maps directions on website, have managed change icon, although can't seem align original marker shadow (which need removing also, it's point show custom marker off). hope made sense? the url is: http://www.emuholidaypark.com.au/location.html as you'll see, there custom marker (not aligned properly) , original shadow (which can't seem rid of?) the code is: var gdir, fromaddress, toaddress; function initialize() { if (gbrowseriscompatible()) { //settings var companymarkerimage = "/templates/home/images/mymarker.png"; var companylatlng = new glatlng(-37.056800, 142.329023); var companymarkersize = new gsize(91, 53); //width, height toaddress = "emu holiday park"; var defaultzoomlevel = 13; //end settings //setup elements map = new gmap2(document.getelementbyid("map_canvas")); gdir = new gdirections(map, document.getelementbyid("directions")); //error ...

CruiseControl.net - CCNetUser property empty -

looking @ recent build log noticed ccnetuser property set empty, should not user has requested build? <cruisecontrol project="..."> <parameters> .... <parameter name="$ccnetuser" value="" /> i want username of person who's requested force build can send them e-mail. the cnetuser property can empty if it's not force build. if build triggered source control/project trigger property empty. if build forced via dashboard , not cctray property may empty too.

C# Copy a file to another location with a different name -

if conditions met, want copy file 1 directory without deleting original file. want set name of new file particular value. i using c# , using fileinfo class. while have copyto method. not give me option set file name. , moveto method while allowing me rename file, deletes file in original location. what best way go this? system.io.file.copy(oldpathandname, newpathandname);

c# - ASP.NET ScriptManager output not included in ASP.NET partial cache (ascx) -

i wrote simple control, implements scriptcontrol. holder jquery framework: /// <summary> /// generic control client behavior handled via jquery /// </summary> public abstract partial class jqcontrol : scriptcontrol, inamingcontainer { /// <summary> /// client method called after jquery initialization /// </summary> [persistencemode(persistencemode.innerproperty)] public jqraw afterinit { get; set; } /// <summary> /// client method called before jquery initialization /// </summary> [persistencemode(persistencemode.innerproperty)] public jqraw preinit { get; set; } /// <summary> /// data initialize control (name-value pairs) /// </summary> public idictionary<string, object> initdata { get; set; } /// <summary> /// authorization templates registered , used privilege manager /// </summary...

Sharepoint 2010: company with several departments site structure question -

i have create team site sharepoint 2010 company has several departments. requirements (simplified) are: top menu: company / department-a / department-b main-page (default, home page): company news department-a tasks department-b tasks company quick launch menu (on left) department-a-page department-a news department-a tasks department-a quick launch menu (on left) department-b-page department-b news department-b tasks department-b quick launch menu (on left) so have 2 lists of departments tasks share between pages. have create personalized quick launch menu per each page (home, department-a, department-b) also. how can this? if create several site pages (one page per department) , customize top level menu, can't customize quick launch menu per page. because seems 1 whole site. if create nested team sites (one site per department) can't share task lists anymore? what ways customize quick launch menu per every page or share lists between ...

Python 2.6 to 2.5 cheat sheet -

i've written code target python 2.6.5, need run on cluster has 2.5.4, wasn't on horizon when wrote code. backporting code 2.5 shouldn't hard, wondering if there either cheat-sheet or automated tool me this. things, with statement, right __future__ imports trick, not other things. have read what's new in python 2.6 document? describes 2.5->2.6 direction, should able figure out reverse it. as far know, there no automated tools 2.6 2.5. tool know of 2to3 app going python 3.

sql - merge of two tables from two databases -

thanks attention answer questions. how can merge 2 tables different databases? again if have same amount of columns, columns have same types , in same order, can simple (merges db1.a , db2.b c of selected db): insert c select * db1.a; insert c select * db2.b;

Sync two folders on same machine using c# -

i have 2 folders on same machine - "folder 1" & "folder 2". anytime add/remove/modify folder/file within folder 1, should sync "folder 2" immediately. found similar article on @ code project (http://www.codeproject.com/kb/files/filesync.aspx) reason doesn't sync , there no errors. any pointers? try having @ microsoft sync framework. 1 of samples involves syncing files between directories. you can use filesystemwatcher trigger sync process.

asp.net - how to add session in navigate url -

adding book basket , clicking on view basket displays basket fine. when clicking on top right hand basket link screen displays basket empty though book has been added you want update basket, you'll have postback. seem allready because item gets added, guess "add" button in updatepanel. if put updatepanel around "basket" should update fine, or maybe you'll have add code update basket.

How to increase the Amazon Elastic Block Store (EBS)? -

once run out of space, there easier way increase amazon elastic block store (ebs) storage? what mean easier way? you create snapshot of current volume. use snapshot basis new volume increased size.

documentation - How do I get rid of the "Release 1" in the Page Header of the Sphinx Latex Output? -

i'm using "manual" document class of sphinx , i'm quite happy how latex output looks like, except page header. contains title of paper, "release 1". since i'm writing paper , not documentation, don't need release information. unfortunately, hard find information on how customize sphinx latex output. does know how it? to suppress release info @ top of latex output, need set release , latex_elements['releasename'] empty strings in conf.py . might add or modify in conf.py : release = '' latex_elements = { 'releasename': '' } then release info hidden.

c# - Javascript Compiler in .Net giving errors -

i have following code: dim compiler icodecompiler = new microsoft.jscript.jscriptcodeprovider().createcompiler dim params new compilerparameters params.generateinmemory = true dim res compilerresults = compiler.compileassemblyfromsource(params, textbox1.text.trim) dim ass assembly = res.compiledassembly dim instance object = activator.createinstance(ass.gettype("foo")) dim thismethod methodinfo = instance.gettype().getmethod("findproxyforurl") dim str(1) string str(0) = "" str(1) = "" messagebox.show(thismethod.invoke(instance, str)) trying compiler folowing javascript code: class foo { function findproxyforurl(url, host) { alert('test') return "proxy myproxy.local:8080"; } } and getting error on - compiler.compileassemblyfromsource(params, textbox1.text.trim) {c:\users\me\appdata\local\temp\zfwspah4.0.js(...

java - testng: why I can not run test based on group -

i want lauch integration tests (group=inttest) write xml config: <!doctype suite system "http://testng.org/testng-1.0.dtd"> <suite name="service integration test" parallel="none"> <test verbose="1" name="service integration test"> <groups> <run> <include name="inttest.*"/> </run> </groups> </test> </suite> but when ran intellij, no tests ran. if add 'classes' section this: <!doctype suite system "http://testng.org/testng-1.0.dtd"> <suite name="service integration test" parallel="none"> <test verbose="1" name="service integration test"> <groups> <run> <include name="inttest.*"/> </run> </groups> <classes> <class name="com.service.mytestclass" /> ...

actionscript 3 - Simple post to Facebook page from flash using querystring -

hi can point me simple example of posting user's facebook pages using query string? ie i'm not using facebook connect. the simplest way able post user's facebook page use facebook's share button , super simple use passing current url ( if using swfaddress deeplink them applications current section) replacing url params point u=[your website] & t=[message share]. also include picture next shared message need in facebooks's open graph , focus on making sure include og:image meta property on base url of site, show next share content posted flash. <meta property="og:image" content="http://www.yourwebsite.com/squareimage.jpg">

anyone know what changes if any were made to asp.net wizard control in framework 3.5? -

hi, i know differences if there between .net framework 3.5 asp.net control compared .net 2.0 framework version none whatsoever. asp.net 3.5 not introduce changes system.web.dll . the changes in asp.net 3.5 in new system.web.extensions.dll .

iphone - Returning data from data-grabbing class from web? -

i'm trying create class let me requested data web service. i'm stuck on how return values. // fooclass.m // datagrabber class supposed values datagrabber = [[datagrabber alloc] init]; xmlstring = [datagrabber getdata:[nsdictionary dictionarywithobjectsandkeys:@"news", @"instruction", @"sport", @"section", nil]]; in example, it's supposed sports news. problem datagrabber gets data asynchronously , ends hopping several nsurlconnection delegate methods. how know in fooclass when data has been received? the delegate pattern used strict protocol useful (that's how datagrabber find out when nsurlconnection done, right?). have written number of web apis consume xml , json information way. // in view controller - (void) viewdidload { [super viewdidload]; datagrabber *datagrabber = [[datagrabber alloc] init]; datagrabber.delegate = self; [datagrabber getdata:[nsdictionary dictionarywithobjectsandkeys:@"new...

iphone - Saving Geotag info with photo on iOS4.1 -

i having major issues trying save photo camera roll geotag info on ios4.1. using following alassetslibrary api: - (void)writeimagedatatosavedphotosalbum:(nsdata *)imagedata metadata:(nsdictionary *)metadata completionblock:(alassetslibrarywriteimagecompletionblock)completionblock i have gps coordinates wish save photo input. unfortunately, there no documentation or sample code describes how form metadata nsdictionary encapsulates gps coordinates. can post sample code known work ? i have tried using iphone exif library save geo info in imagedata rather using metadata, unfortunately iphone exif library crashing. appreciated. here code copy available information cllocation object proper format gps metadata dictionary: - (nsdictionary *)getgpsdictionaryforlocation:(cllocation *)location { nsmutabledictionary *gps = [nsmutabledictionary dictionary]; // gps tag version [gps setobject:@"2.2.0.0...

c# - Please help me choosing the language and framework for my undergraduate project -

i final year computer science student mumbai university, india. the topic of our undergraduate project soa. under project supposed build 3 service components , 1 example website uses components. quite java , have no experience whatsoever c# or .net. i having hard time deciding language , platform our project. can please suggest platform should go for? please give me brief comparison between java/java ee , c#.net/asp.net in terms of complexity, ease of development, ease of deployment etc. edit: original reason why put question is:- we have final year project in group of three. both partners want project in c# , asp.net , want in java. since our project more of server side, java holds advantages cross platform on c# also point:- what if implement 2 parts in c#.net(which build) , 1 part in java(which build) , use them build sample website. what level(kind) of difficulty accompany? i quite java , have no experience whatsoever c# or .net. well then, have...

.net - jQuery validation plugin -

i using jquery validation plugin validate form on client side. adding new method using addmethod function every html control have regex (custom) attribute. html control like. <input type="text" id="txtinf" name="txtinf" regex="some regular exp" error="check inf"></input> $("*[regex]").each(function () { var controlid = $(this).attr('name'); var regex = new regexp((this).attr('regex')); var error = $(this).attr('error'); $.validator.addmethod(controlid, function (value, element) { return this.optional(element) || false; }, error); $(this).rules("add", { '" + controlid + "': "^[a-za-z'.\s]{1,40}$" }); $(this).validate(); }); here giving method name controlid txtinf . in below line, need give txtinf,...

c# - Buttons Are Automatically Selected (how to turn this off?) -

i have winform buttons when load form, button selected. mean selected, if "enter" pressed, button pressed. how can change buttons don't anymore? your tab order set in order in add controls on form. if first control can pressed/selected/edited button getting pressed, focus automatically on when form loaded. you can cheat setting focus other control (maybe not visible? !hint * hint!) avoid button selected @ first. but make sure tht button not acceptbutton of form.

javascript - Opening HTML pop-up windows -

i'm trying figure out best , simplest way of opening html pop-up windows. update: not intended spam. pop-up mean new window without toolbars. need similar facebook connect api. i'm using js <script type="text/javascript"> function popup(url) { id = "hello"; eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=628,height=326,left = 406,top = 287');"); } </script> and adding link <a href="javascript:popup('http://www.google.com')">pop up</a> it works fine i'm not sure if method has been depreciated. pop-ups annoying. best way if have make accessible people turn of javascript: <a href="http://google.com/" target="_blank" onclick="popup('http://google.com/'); return false">

jquery - Creating interactive ajax javascript widgets in ruby / rails -

looking create interactive javascript widget using ruby-on-rails can placed on website. i able create basic widget. straightforward (eg. using document.write) works fine taking data server , putting widget static. but how create more dynamic / interactive / ajaxy? i want able ajax calls using link_to_remote or , able pull data server , update widget user interacts it. any ideas? if can point me in right direction great. thanks! since goal widget can used website, can't use "ajax" due same origin security policy. what can create interactive widget uses jsonp pattern fetch data server. using jsonp, widget can interact website though part of other webpage has nothing website. there libraries using jsonp within javascript program. include: yui jsonp library yahoo jquery support and others. in case, can use rails backend.

testing - How to write a functional test with user authentication? -

i writing functional test page requires user authentication. using sfdoctrineguard plugin. how authenticate user in test? do have enter every test through sign in screen? here incorrect code: $b->post('/sfguardauth/signin', array('signin[password]' => 'password', 'signin[username]' => 'user', 'signin[_csrf_token]' => '7bd809388ed8bf763fc5fccc255d042e'))-> with('response')->begin()-> checkelement('h2', 'welcome humans')-> end() thank you yes, have sign in carry out tests. fortunately, simpler method illustrate above. see "better , simpler way" on blog post . you make signin method part of testfunctional class according how you've structured tests.

jquery - Hacking Vertical Scroll into Horizontal Scroll -

i know goes against every usability rule in book, have ideas forcing vertical scroll scroll horizontally? so if: the user viewing page, , scrolled downwards, page scroll horizontally? thanks! with respect, sounds strange thing , preliminary tests show can done, result practically useless. try this: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>scrolling test</title> <!-- jquery library - google api's --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $(window).scroll(function(event){ var topscroll = $(window).scrolltop(); var leftscroll = $(window).scrollleft(); ...

wpf - Add controls to empty cells in a Grid that's the ItemsPanelTemplate for a ListView -

i have wpf listview, has grid itemspaneltemplate. display items in correct column , row based on property of item. put controls in empty cells of grid. this simplified version of code , xaml: in resources: <itemspaneltemplate x:key="thetemplate"> <grid> <grid.columndefinitions> <columndefinition width="1*" /> <columndefinition width="1*" /> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="1*"/> <rowdefinition height="1*"/> </grid.rowdefinitions> </grid> </itemspaneltemplate> in xaml: <controls:customlistview itemssource="{binding thecollection}" itemspanel="{dynamicresource thetemplate}"> </controls:customlistview> finally, in customlistview: protected override void preparecontaine...

wpf - Toolbar Button with Context Menu? Like New Project Button in Visual Studio -

i need toolbar button similiar "new project" button in standard visual studio toolbar. when clicked, pops dialog. however, has small little down-arrow next icon graphic that, when clicked, expands context menu more options. is there standard control available functionality? i don't think there's built in functionality splitbutton in wpf currently. here's thread may out though: wpf splitbutton? you combine couple of controls make 1 quickly. might make new usercontol out of can re-used throughout app well. also, quick search on wpf splitbutton return lot of examples on how make 1 or 1 off of codeproject or codeplex (though i'm not sure if they'll come image property automatically).

java - Using JTextArea to simulate a text console -

my objective here obtain console-like-behaving component in java, not in jtextarea, seemed logical thing try first. output simple enough, using methods provided jtextarea, input thing. want intercept input, , act on - character character. i've found examples on using documentlistener vaguely related, doesn't seem allow me check typed in, need decide how act upon it. am going correctly? there better method this? i enclose pertinent parts of application code. public class myframe extends jframe { public myframe() { dimension screensize=toolkit.getdefaulttoolkit().getscreensize(); dimension framesize=new dimension((int)(screensize.width/2),(int)(screensize.height/2)); int x=(int)(framesize.width/2); int y=(int)(framesize.height/2); setbounds(x,y,framesize.width,framesize.height); console = new jtextarea("",25,80); console.setlinewrap(true); console.setfont(new font("monospaced",font...

Java Array Manipulation -

i have function named resize, takes source array, , resizes new widths , height. method i'm using, think, inefficient. heard there's better way it. anyway, code below works when scale int. however, there's second function called half, uses resize shrink image in half. made scale double, , used typecast convert int. method not working, , dont know error (the teacher uses own grading , tests on these functions, , not passing it). can spot error, or there more efficient way make resize function? public static int[][] resize(int[][] source, int newwidth, int newheight) { int[][] newimage=new int[newwidth][newheight]; double scale=newwidth/(source.length); for(int i=0;i<newwidth/scale;i++) for(int j=0;j<newheight/scale;j++) (int s1=0;s1<scale;s1++) (int s2=0;s2<scale;s2++) newimage[(int)(i*scale+s1)][(int)(j*scale+s2)] =source[i][j]; return newimage; ...

elisp - Simplest Emacs syntax highlighting tutorial? -

i create syntax highlighting minor mode emacs. have "writing gnu emacs extensions" o'reilly, not go depth of detail. there simple tutorial real or fake programming language highlighting mode? thank you defining custom generic mode best place start. can define basic syntax highlighting language following snippet. (require 'generic-x) (define-generic-mode 'my-mode ;; name of mode '("//") ;; comments delimiter '("function" "var" "return") ;; keywords '(("=" . 'font-lock-operator) ("+" . 'font-lock-operator) ;; operators (";" . 'font-lock-builtin)) ;; built-in '("\\.myext$") ;; files trigger mode nil ;; other functions call "my custom highlighting mode" ;; doc string ) it's great defin...

What python html generator module should I use in a non-web application? -

i'm hacking quick , dirty python script generate reports static html files. what module build static html files outside context of web application? my goals simplicity (the html not complex) , ease of use (i don't want write lot of code output html tags). i found 2 alternatives on first goolge search: markup.py - http://markup.sourceforge.net/ html.py - http://www.decalage.info/en/python/html also, feel using templating engine over-kill, if differ please , why. any other recommendation? maybe try markdown instead, , convert html on fly?

actionscript - Flash Command Line Interface -

i looking build flash/actionscript 2 command line interface simulator acts unix/dos cli. know how this, or have resource tutorial it. i've been scouring web solution, seem able find tutorial effect, not having interactive. a similar effect done javascript can seen here: http://thrind.xamai.ca/ thanks respond. long time ago started work on this. the code on github . but, there isn't documentation , there's work done. never less, it's pretty solid base, if care read through code. hope helps. arthur

Java Loop Efficiency. if-continue OR if -

the question being thought today while completing task loop efficiency.. lets say. have array {'a','x','a','a'} , loop should avoid 'x' element wonder how these 2 approach differ in term of efficiency - not taking while or do-while or loops differentiation char[] arrexample = {'a','x','a','a'}; for(int idx = 0; idx<arrexample.length; idx++){ if(arrexample[idx] == 'x') continue; system.out.println(arrexample[idx]); } and common loop this char[] arrexample = {'a','x','a','a'}; for(int idx = 0; idx<arrexample.length; idx++){ if(arrexample[idx] != 'x') system.out.println(arrexample[idx]); } so.. expert comments pleased. thanks! even if went nonoptimized byte-code, identical. there's 2 real differences. first placement of jump statement, jump statement still executed same number of times. also, == , != operato...

java - Alternative strategy to query aggregation ("group by") in google app engine datastore -

app engine datastore cannot queried aggregate result. example: have entity called "post" following fields: key id, string nickname, string posttext, int score i have many different nicknames , many posts each nickname in datastore. if want leader board of top ten nicknames of total scores, typically have sql follows: select nickname, sum(score) sumscore post group nickname order sumscore limit 10 this type of query not possible in google app engine datastore java api (jdo or jpa). what alternative strategies use achieve similar result? crudely , brutely, load every post entity , compute aggregation in application code. not efficient on large datasets. what other strategies can employ? create nickname model, , each time add new post, retrieve corresponding nickname , increase stored score sum there. essentially, computation @ insert/update-time, not query-time.

How to set up a new Access Point in Android phone, programmatically? -

i have searched lot on not find on google or stack overflow. i have found 1 approach on android developers propose using contentresolver example of implementation have not tried that. also, useful blog that http://blogs.msdn.com/b/zhengpei/archive/2009/10/13/managing-apn-data-in-google-android.aspx key thing content provider uri: "content/telephony/carriers".

ubuntu - CakePHP Installation Broke (Probably Apache2 Problem) -

i tried install cakephp on home ubuntu 10.04 desktop development/testing purposes, , believe have gone through appropriate steps. however, still running problem layout broken. believe documentroot or mod_rewrite problem, don't have enough experience in apache diagnose , fix it. /var/www/cakephp/.htaccess 1 <ifmodule mod_rewrite.c> 2 rewriteengine on 3 rewriterule ^$ app/webroot/ [l] 4 rewriterule (.*) app/webroot/$1 [l] 5 </ifmodule> /var/www/cakephp/app/webroot/.htaccess 1 <ifmodule mod_rewrite.c> 2 rewriteengine on 3 rewritecond %{request_filename} !-d 4 rewritecond %{request_filename} !-f 5 rewriterule ^(.*)$ index.php?url=$1 [qsa,l] 6 </ifmodule> firebug gives this: 404 not found not found the requested url /cakephp/css/cake.generic.css not found on server. apache/2.2.14 (ubuntu) server @ localhost port 80 i tried setting permissions ...

software design - Dependency injection OR configuration object? -

i have following constructor class public myclass(file f1, file f2, file f3, class1 c1, class2 c2, class3 c3) { .......... } as can seen, has 6 parameters. on seeing code, 1 of seniors said instead of passing 6 parameters should rather pass configuration object. i wrote code way because have read "dependency injection", says "classes must ask want". think passing configuration object against principle. is interpretation of "dependency injection" correct? or should take senior's advice? "configuration object" obtuse term apply in situation; frames efforts in purely mechanical sense. goal communicate intent class's consumer; let's refactor toward that. methods or constructors numerous parameters indicate loose relationship between them. consumer has make more inferences understand api. special these 3 files these 3 classes ? information not being communicated. this opportunity create more meaningful , intentio...

Form submit button with css sprites? -

i having problem creating form submit button css sprites. it's button onrollover state. have .css button part .buttonsubmit { background-image: url(../imgs/button_states_submit.png); background-repeat:no-repeat; margin-top: 10px; float:left; height: 100px; width: 160px; } a.buttonsubmit:hover { background-position:0 -100px; } and html have <input name="" value="" class="buttonsubmit" type="image" /> the button submits form onrollover state doesn't work??? when test simple href onrollover state works, don't know jquery selector use submit form <a href="#" id="buttonsubmit" class="buttonsubmit"></a> in combo jquery $('#buttonsumbit').click(function(){ regards your css: .buttonsubmit { background-image: url(../imgs/button_states_submit.png); background-repeat:no-repeat; margin-top: 10px; float:left; heigh...

java - How to Realize an Update Service is Running in the Background? -

i'm working on app android os displays data. ensure data up-to-date, required app fetches updates remote server time time. data not change often, update should carried out once per week. want give user ability choose weekday , daytime of update (and optionally disable feature completely). the thing is: update should carried out when user not using phone @ moment, when phone sleeping , when phone has been rebooted , app hasn't been started yet. the first thing thought of remote service starts @ system boot, determines time when run update, sets timer , waits/sleeps timer fire. now, told should rather use alarm timers or kind of handlers... more read topic, more ways seem exist. now, i'm bit lost method best me... here need: i want execute code @ time specified. this timer used trigger execution of code 7 days in future. (i.e., every week @ given weekday , time) the code should run without waking phone if "sleeping" (screen dimmed). when running code, ...

c - Is ARPACK thread-safe? -

is safe use arpack eigensolver different threads @ same time program written in c? or, if arpack not thread-safe, there api-compatible thread-safe implementation out there? quick google search didn't turn useful, given fact arpack used heavily in large scientific calculations, i'd find highly surprising first 1 needs thread-safe sparse eigensolver. i'm not familiar fortran, translated arpack source code c using f2c , , seems there quite few static variables. basically, local variables in translated routines seem static, implying library not thread-safe. fortran 77 not support recursion, , hence standard conforming compiler can allocate variables in data section of program; in principle, neither stack nor heap needed [1]. it might f2c doing, , if so, might it's f2c step makes program non thread-safe, rather program itself. of course, others have mentioned, check out common blocks well. edit : also, check explicit save directives. save means value of var...