Posts

Showing posts from April, 2014

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

entity framework - EF CTP 5 create and persist object graph trouble -

code: something smt = new something(){ prop = 123, prop2 = "asdad" } foreach(var related in relatedsomething) { smt.related.add(new related(){ relatedprop = 123, }; } runtime gives me error null reference. related virtual icollection. no foreign key fields in entities defined. on contrary if do foreach(var related in relatedsomething) { db.related.add(new related(){ relatedprop = 123, = smt }; } it works. although, want work in first snippet. doing wrong? 'cos in shipped ef4 works both ways. model classes (relevant part): public class printer { public int id { get; set; } public string name { get; set; } public virtual icollection<replica> replicas { get; set; } } public class replica { public int id { get; set; } public virtual printer printer { get; set; } } public class printerscontext: dbcontext { public dbset<printer> printers { get; set; } public dbset<replica> replica

process - Python - what is difference in os.popen and subprocess.Popen? -

python - difference in os.popen , subprocess.popen? the os process functionality considered obsolete. subprocess module introduced in python 2.4 unified, more powerful replacement several older modules , functions related subprocesses. listed here : os.system os.spawn* os.popen* popen2.* commands.* os.popen deprecated in python 2.6 (but, interestingly, not deprecated in python 3.1). there paragraph in documentation on how replace subprocess.popen .

WebView android proxy -

i know how setting proxy manually , use in webview. settings -> wireless networks ->mobile networks-> access point names->telkila. enter proxy server address , port (which 80). webview.enableplatformnotifications(); but can set proxy setting code? user didn't have set manually? thanks there no legal way change webview proxy settings programmatically. it's possible use java reflection change mproxyhost value android.net.http.requestqueue class. it's private value , there no setters it, reflection seems possible variant. used in project , works. here sample of method: private boolean setproxyhostfield(httphost proxyserver) { // getting network class networkclass = null; object network = null; try { networkclass = class.forname("android.webkit.network"); field networkfield = networkclass.getdeclaredfield("snetwork"); network = getfieldvaluesafely(networkfield, null); } ca

.net - WPF and creating a "endless" canvas -

i trying make small drawing program small children. thinking on making canvas , , allowing them draw on it. not want specify size, want zoom out , allow "endless" piece of paper (using pan + zoom navigate). how do this, canvas seems have fixed size, , resizing doesn't seem work, how zoom, drawings doesn't seem vector based, "jagged" when zooming close. any other control better? have @ inkcanvas control, gives area board may draw or handwrite; apart provides various other features out of box. can find sample implementing zooming in inkcanvas. helpful links - draw using inkcanvas: http://www.kirupa.com/blend_wpf/inkcanvas_pg1.htm seres of articles on using inkcanvas- http://blogs.msdn.com/b/swick/archive/tags/fun+with+ink+_2600_amp_3b00_+xaml/

php - How do I use phpdocumentor web interface? -

i'm trying document code using phpdocumentor.. know how use phpdocumentor web interface or tutorial explaining this? have read phpdoc tutorials , quickstart ? it tells need know supported tags through how install , run documentation generator, etc. it mentions how use docbuilder web interface .

c# - Watin : Get Row Count from table -

hi i'm trying row count table using watin ie 1.get table (done) 2.count rows in table (not done) 3.compare count (already have idea) how row count table,using watin?any ideas?can point me right direction hi guys;thanks helping,i hit roadblock here i'm using this int countnumberofrows = this.elements.joblistinggrid.owntablerows .skip(1) .where(r => !r.classname.contains("rowhidden")) .count(); ok i'm able count '21' :),my problem page using same control,and number of row each page same if click activelink rows 21 , if click on pendinglink although rows hidden still 21.i need differentiate number of rows because way me this if (countnumberofrows != 0) { this.elements.activelink.click(); } else { this.elements.pendinglink.click(); } is idea possible?or need @ way if have table tablerows collection gives number of rows:

C# Foreach usercontrols I added to a page -

i've got code: protected void ddltemplate_selectedindexchanged(object sender, eventargs e) { template t = new template(); t.loadbyid(convert.toint32(ddltemplate.selecteditem.value)); foreach (widget w in t.templatewidgets) { usercontrols_widget ucwidget = (usercontrols_widget)loadcontrol("~/usercontrols/ucwidget.ascx"); ucwidget.widgettitle = w.name; ucwidget.parameters = w.parameters; pnlwidgets.controls.add(ucwidget); } } protected void lnksubmit_click(object sender, eventargs e) { foreach (control cc in pnlwidgets.controls) { } } basically i'd foreach widgets added page in ddltemplate_selectedindexchanged event. question how usercontrols added. you can add usercontrols list<usercontrols_widget> , loop through instead of looping through controls on page.

php - Solutions for testing entire features of an app -

edit: clarify - asking advice on both unit testing and user interface testing. currently, don't use tdd. while developing application testing working on. testing iteration minor function changes entire models. try not code before test. instant feedback. of course, experience can see potential problems or bugs occurring i'm coding. but, after application complete go through entire app on frontend , ensure functions working expected. means literally everything. every add/edit/delete, sort, filter, broken links , such. this can take lot of time ensure work hardly ever contains bugs after deployment. however, i'm looking more standard solution. experienced developers do? assume moment single developer , not have testing department etc do hire beta testers (no if app sensitive public use)? is viable build series of 'general' unit tests can example test sorting, filter functions. 1 testing add/edit/delete functions. love hear feedback. changing way de

Sharepoint change Content Type in Sharepoint Designer using workflow -

i trying change document content type. must use workflow, , best way workflow create in sharepoint desingner. know how programatical in visual studio i know old question, figured out: you can using spd workflow (spd 2007 or 2010). can call content type field in 2 ways: in workflow, use "if [field] equals [value]" or "set [field] [value]" for "if" statement, field called "content type". "set" statement field called "content type id". in either case can assign value based on available content types. you need enable content types on list or library settings. here's example workflow based on custom list record accounts payable entries: list column: request type (choice column choices of reimbursement, department expense, other) list content types: default, accounts payable, accounts receivable if [request type] equals [reimbursement] set [content type id] [accounts payable] when workflow fires, se

iphone - iOS keyboard with "Go" button instead of return -

Image
is there way use keyboard "go" key instead of "return" key when accessing login fields in safari? i'm guessing should trivial searches aren't turning anything. :( thanks in advance. for uitextfield or editable uitextview : [mytextfield setreturnkeytype:uireturnkeygo]; you can configure in interface builder, under text input traits text field/view:

c# - Manually telling my ListBox's scrollbar where to be -

private void button2_click(object sender, eventargs e) { listbox1.autoscrolloffset.y = 10; } i'm trying manually set location of vertical scrollbar using code during runtime. i've tried. the .y property says: "gets or sets y coordinate of point". why doesn't compile , give me exception: error 1 cannot modify return value of 'system.windows.forms.control.autoscrolloffset' because not variable this crucial difference between value types , reference types. autoscrolloffset of type point, struct makes value type. when use property getter, copy of value. setting y property sets property on copy . c# compiler can recognize particular usage problem. not one: private void button2_click(object sender, eventargs e) { var offset = listbox1.autoscrolloffset; offset.y = 10; // compiles, doesn't work } to make work if have assign property value of type point: private void button2_click(object sender, eventar

c# - Need help in building regular expression -

what regular expression od -0d -123d -145y 234w , not +234d or -678m etc. i have string exp_regex_valid_literal = @"[0-9]*[d|d|w|w|m|m|q|q|y|y]"; regex regex = new regex(exp_regex_valid_literal); return regex.ismatch(inputstring); but failing "/0345d" validation rules: the expression alphanumeric one(where alphabets optional) alphabets can d|d|w|w|m|m|q|q|y|y , can appear after numerals. if character can come before numerals can minus.so -123 valid or -123d or 123d or 123w valid. not 23dw or +12d etc. thanks if understand want, may work: /^-?\d+[dwmqy]$/i c# syntax (not quite sure): regex.match("/0123d", "^-?\d+[dwmqy]$",regexoptions.ignorecase); where: ^ begining of string -? optionnal - \d+ 1 or more digits [dwmqy] 1 of these char $ end of string case insensitive

jQuery ancestors -

is there easier way say $('element').parent('parentelement').parent('grandparentelement'); answer : try parents () or closest () $('element').closest('grandparentelement');

mysql - Select from multiple tables with same condition, avoid ambiguity error -

how can avoid error column common_reference ambiguous ? know it's ambiguous, want select table_one results common_reference there, , table_two same. select * table_one, table_two common_reference = 42 this not going work, how use subqueries achieve need? start with... select * table_one, table_two table_one.common_reference = 42 ...and continue road: select * table_one t1, table_two t2 t1.common_reference = 42

Identify empty string in Perl -

there easy solution this, can't figure out. looking to: take csv file array loop through array , split fields variables if array field empty set variable "n/a" note: setting $variable " n/a " cannot working. for example: foreach $var (@list) { ($name,$date,$size, etc...)=split(/,\"/,$var); } how set $date " n/a " if field in array empty? so produce: $name = jim $date = n/a $size = small i hope makes sense , easy fix. -thanks assuming variable $date undefined when "empty": if (!defined($date)) { $date = 'n/a'; } or more concisely: $date //= 'n/a'; or if empty string, i.e. $date = ''; (this work in case $date undefined, don't want use if only want identify case undefined): if ($date eq '') { $date = 'n/a'; } or more concisely (note set $date n/a if $date '0' due perl's weak typing): $date ||= 'n/a';

windows - Turn Outlook VBA into a standalone script -

i've written vba accesses users outlook notes , contacts, performs manipulations, modifies notes , contacts , @ same time outputs text files. works well. at present runs (like other vba code) inside outlook doing tools > macro > macros... installation pain non-tech savvy users , given is simple bas module (no forms), doesn't need run in way. a script file executed double-clicking within explorer far better option. easier re-distribute , mean use it. assuming possible turn vba standalone script... how do it? what should know? caveats or things aware of? code i'll need change? thanks. i realize post old, vb6 com dll option? here's simple example of can do: http://support.microsoft.com/kb/316983 and can use installer inno setup create exe install , register dll on each computer.

java gregoriancalendar off by an hour -

i did: gregoriancalendar gc = new gregoriancalendar(locale.french); and hour off 1 hour. 14:17 instead of 15:17. first thought dst, think gregoriancalendar takes account. the time set correctly on pc. the constructor use creating calendar default timezone ( javadoc ), might not timezone correct fpr given locale. @ leasst, thats how read javadoc. try using different constructor , pass tz in.

How to take a screenshot in Java? -

possible duplicate: is there way take screenshot using java , save sort of image? how take screenshot in java? use robot#createscreencapture() . bufferedimage image = new robot().createscreencapture(new rectangle(toolkit.getdefaulttoolkit().getscreensize())); imageio.write(image, "png", new file("/screenshot.png"));

javascript - determine if an element is scrollable in html document -

hi i'm trying check if html element scrollable.only gecko support needed (and webkit support nice not necessary). documentation tells scrollheight , clientheight same when element has no vertical scrollbar https://developer.mozilla.org/en/dom/element.scrollheight discovered gecko adds margin size scrollheight. so, element margins, scrollheight superior clientheight. https ://bugzilla.mozilla.org/show_bug.cgi?id=576976#c2 so, use like: var clientheight = element.clientheight; var bordertop = window.getcomputedstyle(element,null).getpropertyvalue('border-top-width'); var borderbottom = window.getcomputedstyle(element,null).getpropertyvalue('border-bottom-width'); var scrollheight = element.scrollheight - parseint(bordertop, 10) - parseint(borderbottom, 10); it works fine except in 1 case: when use firefox zoom. let's have border of 1px around element. clientheight , scrollheight have difference of 2px (1 top, 1 bottom). unfortunately, window.getcompute

javascript - AnythingSlider throws Error "base.panelSize[page] is undefined" -

can tell me, what's wrong code if anythingslider (or rather firebug) throws following error when initialised? base.panelsize[page] undefined width: base.panelsize[page][0], jquery.anythingslider.js, line 442 js-code (inside of $(document).ready-function)): $('#slider').anythingslider({ width: 800, height: 564, startpanel: 1, autoplay: false, startstopped: true, animationtime: 600, hashtags: false, buildnavigation: false, pauseonhover: false, starttext: "", stoptext: "" }); i tried latest version (1.5.6.2) motties' fork of chris coyers' anythingslider (available here ). problem solved, provided. code-blind , applied #slider div instead ul... (i believe worked in prior version, i'm not sure, anymore)

MYSQL Query - Some results don't return -

i have problem im sql query: select table_2.id, sum(table_2.time + table_4.time + table_6.time + table_8.time + table_10.time + table_12.time) total_time, sum(table_2.connects + table_4.connects + table_6.connects + table_8.connects + table_10.connects + table_12.connects) total_connects table_2 inner join table_4 on table_2.id = table_4.id inner join table_6 on table_2.id = table_6.id inner join table_8 on table_2.id = table_8.id inner join table_10 on table_2.id = table_10.id inner join table_12 on table_2.id = table_12.id group table_2.authid order total_time desc ok, have script grabs user ids , time spent , puts in mysql tables depending on forum have entered. query above seems working fine users have entered forums, because others haven't entered in forums don't return result. the id same, users id , connects number of times user enters specific forum. if understand problem , know answear please let me know, otherwise i'll try explain better th

visual studio - Installing VS.NET on a 64-bit Computer -

i trying install visual studio .net on windows 7 64-bit computer. when run setup, error message: "unable install visual studio .net on 64-bit operating system." searching google tells me other people have run this, don't see solutions. has found way around this? no, can't install vs.net on 64-bit computer. can install on windows 7 x86. i saw claims worked on windows 7 x64, i've since become convinced won't work. if need on 64-bit computer, create 32-bit virtual machine , install there.

scope - Jquery Dialog issue -

in order use jquery ui dialog module use of $.extend() method , wrote this: user.confirmationdialog = function(options) { if(undefined === options.selector) { return false; } this.close = function() { modal.dialog('close'); } this.forward = function() { if(undefined !== trigger.attr('href')) { document.location.href = trigger.attr('href'); } } var modalbuttons = {}; if(undefined !== options.buttons) { for(var buttontitle in options.buttons) { modalbuttons[buttontitle] = (function(e, f) { return function() { e.call(f); } })(options.buttons[buttontitle], this); } delete options.buttons; } var modalhtmlelementid = 'confirmdialog'; if(undefined !== options.id) { modalhtmlelementid = options.id; delete options.id; } var modaloptions = jquery.extend({ autoopen: false, width: 410, height: 'auto',

default language in Prestashop -

i want shop in 1 language example in hindi.i install new language , set default language , remove language block front end of shop.but when shop opens still english default language , have switch hindi. how can solve issue? once have changed site default language else english, have go localization > language , there, make sure desired language, in case hindi, enabled. once done, can disable english. if delete language block front office, not change language - removes possibility user change language.

javascript - Annoying IE8 dropdown issue in XP but not windows 7 -

i have annoying issue select html element cuts off text in dropdown when longer set width of select html element. the select elements need set width stop page misalinging, every browser seems work except ie8 running on xp. why? random , bad compatibility. please let me know if need more infomation. thanks! it's how ie interprets should render drop downs ... unfortunately,there's no easy fix, can create replacement drop downs handles in different way, can work consistently across browsers ... here's solution came with http://weblogs.asp.net/jaimedelpalacio/archive/2008/11/22/custom-html-dropdown-control-part-1.aspx

php - Can any one give me some advice to make my for loop more efficient? -

so have loop 36 if-queries inside. advice on making more efficient? can view complete code here here's sample of looks like: $numbers = range(1, 36); shuffle($numbers); ($m =0; $m<37; $m++){ if ($numbers[$m] == "1"){ $mirza[$m] = "ruthie"; $mage[$m] = "3"; $mquote[$m] = "i learn lot of new things here, sign language!"; $link[$m] = "http://www.google.com"; } if ($numbers[$m] == "2"){ $mirza[$m] = "aida"; $mage[$m] = "82"; $mquote[$m] = "this club , know , members. it's therapy."; $link[$m] = "/about/"; } if ($numbers[$m] == "3"){ $mirza[$m] = "amire"; $mage[$m] = "4"; $mquote[$m] = "i learning how share , make friends."; $link[$m] = "/about/"; } } when have data should in database (maybe x

sql - Query Join Condition -

i have 2 tables named account , assignedgroup. in account table there 2 columns named id , sourceaccount , in assignedgroup have 2 columns named id , assignedgroup. i want select id joining account , assignedgroup tables. did this: select a.id account left outer join assignedgroup b on a.sourceaccount = b.assignedgorup but null output reason being values in sourceaccount this sourceaccount: sample sample and whereas values in assignedgroup this assignedgroup: sample-l1 sample-p-l1 can me on how join these 2 tables? i want id's whenever there sample value in both sourceaccount , assignedgroup. it comparing sample sample-l1 since not equal returning null want id if has values that. mean if somepart of column values matches want values displayed select a.id account left join assignedgroup b on b.assignedgorup a.sourceaccount + '-%'

deployment - How to build and install rails application dependencies on different hosts -

i have rails 3 application i'd deploy. deployment environment not have build tools installed , cannot install dependencies native extensions. i have build host configured build tools can build native extensions. how can deploy native extensions build host ? i have tried doing bundle package on build host , bundle install --local on remote host. correctly installs gems without native extensions still tries build native extensions on production host. it bad practice build on production servers. when deploy django or rails build toolchain whatever os package management system doesn't cover. develop , deploy toolchain. assures uses same versions of tools. to create toolchain need install packages , supporting executables in directory. need make sure relocatable. for example use django on redhat. redhat doesn't use latest version of python, , many of python libs use rev more repository maintainers pick them up. result there no rpms latest software

Command to Change DB Column in Ruby on Rails -

is there quick console command can run change type have object? it's ruby date type, ruby time type. i started scaffold command: $ rails generate scaffold post title:string content:text postdate:date but wish have done following: $ rails generate scaffold post title:string content:text postdate:time is there command , can run make update? sometimes have write actual code, in rails. try creating migration , using change_column method. like change_column :my_table, :my_column, :new_type you put in db migration file, not in shell.

jquery - DataTables Server Side Individual Column Filtering -

i hoping can me this. have been running myself crazy this. i have situation load datatables grid (awesome piece way!) , great. go search , run problems. data being populated in grid coming 2 different database tables (which fine) when executes search have no way of knowing go , data. need know criteria search (i.e. title or contact). see when search called server via default search box there variables "ssearch_0" unset, how set? here initialization code table: otable = $('#example').datatable({ "bjqueryui": true, "bfilter": true, "spaginationtype": "full_numbers", "bpaginate " : true, "bserverside" : true, "sajaxsource" : "php/tabledata.php", "aocolumndefs": [ { "bsortable": false, "atargets": [ 0,6,8 ] }, { "sclass": "tdcenter", "atargets": [ 0,1,2,3,4,5,6,7,8 ] } ], "fnserverdata": function ( ssour

ruby - Rails: How to pass value from textfield to a partial -

how can pass value auto_complete textfield partial. <%= text_field_with_auto_complete :participant, :name, {}, {:url => {:controller => "contentcom/discussions", :action => :get_users_for_auto_complete}, :method => :get, :param_name => 'search'} %> <%= button_to_function(:ok) |page| page.insert_html :top, :participants, :partial => 'participant', :locals => end %> bye, nico first of need know helpers text_field_with_auto_complete , button_to_function not handle user actions, generate html , javascript code. generated javascript code can interact user. in case text_field_with_auto_complete generates following (approximately): <input type="text" id="participant_name" name="participant[name]" size="15" /> <div id="participant_name_auto_complete" class="auto_complete"> </div> <script type="text/jav

perl - Conditional statement- compare to values store in array -

need figuring out working perl code put in place of "any of elements in @array" %hash = (key1 => 'value1',key2 => 'value2',key3 => 'value3',); @array= ('value3','value4','value6'); if ($hash{ 'key1' } ne <<any of elements in @array>>) {print "yay!";} you use grep function. here's basic example: print "yay!" if grep { $hash{'key1'} eq $_ } @array; in scalar context grep give number of matching entries in @array . if that's non-zero, have match.

java - How to convert colorspace using JMagick? -

how convert colorspace using jmagick api? for example cmyk --> rgb , rgb --> cmyk. i didnt test below snippet might starting point you. imageinfo info = new imageinfo("myimage.jpg"); boolean iscmyk = info.getcolorspace() == colorspacetype.cmykcolorspace; if(iscmyk) { info.setcolorspace(colorspacetype.rgbcolorspace); }

php - xml xpath read big file, from one part to other -

i have long xml file, this: <cars> <car> <name>ford</name> <number>f33</number> <color>blue</color> </car> <car> <name>ford</name> <number>f43</number> <color>red</color> </car> <car> <name>ford</name> <number>f53</number> <color>red</color> </car> <car> <name>audi</name> <number>a001</number> <color>red</color> </car> <car> <name>audi</name> <number>a032</number> <color>white</color> </car> ....... </cars> how php xpath read 1 part ather. for example sql limit 10, 30 show elemens 10 30 how php xpath read 1 part ather. for example sql limit 10

windows - Merging two dynamic libraries -

i use program called molebox-pro bundle dll executable uses dll. way when distribute executable don't need ship external dll it, goes in 1 large exe. it's practical. wonder though if exists bundle 2 dlls (one depends on presence of other: need in same folder or in path)? have c source code 1 dll (my-dll) compile gcc, other dll on my-dll depends don't have source code. @ possible? tool exist merging 2 dlls exists merging exe dll (molebox)? put 1 resource section of another, or elsewhere, , extract , load loadlibrary.

android - huawei ascend (m860) not recognized by adb on mac -

i trying use huawei ascend (m860) (this particular model cricket mobile) low-end android test device. i've turned usb debugging on device. plug mac, run "./adb devices" terminal , there no devices listed. has connected device mac android development? my setup: mac osx 10.6.5 eclipse 3.5.2 android adt plugin 0.9.9 android debug bridge version 1.0.26 thanks! according thread @ xda-developers forum , another thread @ androidforums , can't use adb because of sort of lock. you better off rooting phone first installing wireless adb. also, further questions on want ask on forums (xda-developers , androidforums).

qooxdoo - custom listitem widget selection -

i made custom listitem view (based on http://news.qooxdoo.org/tutorial-part-4-2-custom-widgets-4 ). i have problem selection items on list. there selected first element (no matter element on list click). what should resolve problem? here list-item widget: qx.class.define("project.myview", { extend : qx.ui.core.widget, include : [qx.ui.form.mmodelproperty], construct : function() { this.base(arguments); var layout = new qx.ui.layout.grid(4, 2); layout.setcolumnflex(1, 1); this._setlayout(layout); this._createchildcontrol("icon"); this._createchildcontrol("date"); this._createchildcontrol("description"); }, properties : { appearance : { refine : true, init : "listitem" }, icon : { check : "string", apply : "_applyicon", nullable : true

java - JDOM.Element.getChild(String) is returning unexpected results -

according api @ jdom.org , semantics of getchild(string name) : this returns first child element within element given local name , belonging no namespace. if no elements exist specified name , namespace, null returned. therefore, if have xml structure like: <?xml version="1.0" encoding="utf-8"?> <lvl1> <lvl2> <lvl3/> </lvl2> </lvl1> i have jdom element pointing <lvl1> . should able make following call: element lvl3 = lvl1element.getchild("lvl3"); and lvl3 should have non-null. however , i'm finding lvl3 null . missing something? here sample code snippet should work: import java.io.stringreader; import org.jdom.*; public static void main(string[] args){ document doc = new saxbuilder().build(new stringreader("path file")); element lvl1element = doc.getrootelement(); element lvl3element = lvl1element.getchild("lvl3"); //is null. why? }

android - How to: Define theme (style) item for custom widget -

i've written custom widget control use throughout our application. widget class derives imagebutton , extends in couple of simple ways. i've defined style can apply widget it's used, i'd prefer set through theme. in r.styleable see widget style attributes imagebuttonstyle , textviewstyle . there way create custom widget wrote? yes, there's 1 way: suppose have declaration of attributes widget (in attrs.xml ): <declare-styleable name="customimagebutton"> <attr name="customattr" format="string"/> </declare-styleable> declare attribute use style reference (in attrs.xml ): <declare-styleable name="customtheme"> <attr name="customimagebuttonstyle" format="reference"/> </declare-styleable> declare set of default attribute values widget (in styles.xml ): <style name="widget.imagebutton.custom" parent="android:style/widget.i

android toast a Chinese message to user -

basically need toast message written in chinese user. don't know how achieve such thing. solution can me? i'm not android programmer, doesn't work? context context = getapplicationcontext(); charsequence text = "中国的网页"; int duration = toast.length_short; toast toast = toast.maketext(context, text, duration); toast.show(); code ripped here . (apologies if means offensive. ripped random characters here ).

asp.net - ActiveRecord initialize method in Application_Start -

i have site uses activerecord. i'm getting exception says "an activerecord class () used framework seems not initialized. did forget activerecordstarter.initialize() ?" web application, , initialize() method called application_start event handler. i created new page calls initialize() method. if visit page once, rest of site works. if visit second time, exception stating initialize() method can called once. i've tried modifying web.config , resetting application pool force application_start run. this happens in production; dev, stage, , client stage fine. production load-balanced environment--i'm not sure if comes play. edit: have site deployed in same environment uses activerecord same initialization code. 1 difference site working has activerecord code in application_start; site doesn't sets url routing in application_start. any ideas cause this? it turns out application_start never called. there file called precompiledapp.config must

html - How do you keep relative positioning from poping out of the box? -

i trying use relative positioning other reasons, , data in div popuping out of container div in ie7. can guys give me idea going? also, can remove position: relative;. need line highlighting code. thanks, grae here code: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <meta http-equiv="x-ua-compatible" content="ie=emulateie7" > <html> <head> </head> <body> <div style="overflow:auto; height:350px; border: 1px solid #00ff00"> <table> <tr> <td> <div style="position:relative;"> <pre> test line test line test line test line test line test line test line test line test line test line test line test line test line test line test line test line test line test line test line test line test line test li

symfony1 - Doctrine Searchable Behavior vs Zend Lucene in symfony -

i need search keywords in 2 table, simple thing i undecided using 1 or other? suggestion performance wise? thanks! as cuhuak mentioned, lucene fulltext search. since written in java, additionaly need java server (tomcat example). if don't want additional server, zend lucene implementation (as noted in comments matt gibson) may worth looking into. additional server , if have small host, may not performance wise. also, lucene needs more configuration , set-up doctrine solutions. on performance side of things: lucene built index millions of words , search within these in milliseconds. millions of words in "regular" rdbms, things slow. set fulltextsearch in database too, again needs setup , knowledge do. so generall thought: if site small (in terms of things searc), go doctrine approach, if plan serious amounts of data, go lucene.

How to use ruby win32ole to set Microsoft Exchange proxy settings? -

using outlook access work exchange inbox via https proxy used straightforward until employer changed principal name have use. mysteriously, in background, principal name gets reset old value. pretty every time log in, , several times in login session, have reconfigure principal name new value in order use vpn-less outlook. reconfiguring https proxy principal name requires ten mouse clicks right text field (control panel -> mail, etc), then, once i've changed it, 7 further mouse clicks save it. winds me employer can't find solution this. i love able script this. know (a) if possible , (b) how access exchange proxy settings via ruby's win32ole? i've googled , googled nobody else appears have done this. kind regards, rob through registry maybe? (win32/registry.rb)

android - Different Instance of Applicationcontext in Broadcastreceiver -

i want access "global" variable in myapp(extends application) broadcastreceiver (registered in manifest) , e.g. multiple activities. seem have different instances of myapp: 1 bcr , 1 activities. sb me problem? alot joerg what trying create method having single context object. first off, need singleton pattern of myapp create "global" variable. advice against these reasons: different application components default have different contexts (base, application). a broadcastreceiver defined in manifest invoked os, not application. using singleton pattern context object lead nasty dependencies. you going against design , beauty of android framework. i suspect reason doing myapp class can start different activities. makes sense, but... can context object anywhere. many things in android extend contextwrapper class (think java objects object class). there no reason ever have "global" instance of this. in fact broadcastreceiver's onre

java - Why does JDO think this detached object is clean? -

i trying learn jdo (and @ same time gae , spring intricacies) creating small web app, , having trouble getting updated domain objects persist database. grab entity db , detach can show user , allow them change it. once user has made changes , posts form app, again grab entity db (detached), update properties, , call pm.makepersistent() . abbreviated code follows: user domain object: @persistencecapable(detachable="true") public class user extends baseentity { @persistent private string firstname = ""; @persistent private string middleinitial = ""; @persistent private string lastname = ""; } dao read method: public user read(key key) throws dataexception { persistencemanager pm = pmf.get().getpersistencemanager(); user pkg, detached = null; try { pkg = (user) pm.getobjectbyid(user.class, key); detached = pm.detachcopy(pkg); detached.setisalreadyindb(true); } catch (exc

Android: How to get a View position before and after an layout update? -

i'm trying create animation link 2 position of view. position of view defined overridden method onlayout. i'm getting position before , after position update getlocationonscreen method. here code simplified: int[] startposition = new int[2]; view.getlocationonscreen(startposition); // layout update changed view position on screen requestlayout(); invalidate(); int[] endposition = new int[2]; view.getlocationonscreen(endposition); animation anim = new translateanimation(startposition[0], endposition[0], startposition[1], endposition[1]); anim.setduration(100); view.startanimation(anim); the problem onlayout method isn't called after layout update , call requestlayout... found calling requestlayout schedule layout pass of view tree. question is: how make layout calculation synchronously ? or wait end ? use postdelayed or add event system onlayout method, i'd test cleaner methods first... call onlayout method myself, don't know how calculate arguments.

javascript - What is the best way in PHP or JS to expand shortened URLs like Bitly, Tinyurl to find the original URL? -

i using twitter , facewbook api pull posts potentially contain shortened urls using bit.ly or tinyurl services. need real-time expansion original url pull content url app. you can use curl expand short url. try this: function traceurl($url, $hops = 0) { if ($hops == max_url_hops) { throw new exception('too_many_hops'); } $ch = curl_init($url); curl_setopt($ch, curlopt_header, 1); curl_setopt($ch, curlopt_nobody, 1); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_ssl_verifypeer, 0); $r = curl_exec($ch); if (preg_match('/location: (?p<url>.*)/i', $r, $match)) { return traceurl($match['url'], $hops + 1); } return rtrim($url); } you can use function traceurl('http://bit.ly/example') . function recursive in sense find short urls shortened (if ever happens). make sure set

java - how to show data in listview from web service in android -

my webservice return data in format ab cdef have show return data in listview here welcome.xml in have display data welcome.xml <?xml version="1.0" encoding="utf-8" ?> - <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <imageview android:id="@+id/welcome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/main" android:layout_gravity="center_horizontal" /> - - <relativelayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margintop="10dip" android:id="@+id/relative01"> <listview android:id="@+id/lvevent" android:layout_width="fill_parent" android:layout_he

jquery - Uniformly update jQueryUI Progressbar over N seconds -

given variable n, reflecting number of seconds, i'd have jqueryui progressbar smoothly update being empty reflecting completion on period of time. in other words, i'd function n_sec_progressbar(n) { ... } shows progressbar, , on n seconds progressbar uniformly advances value of 0 100. before go ahead , start fiddling settimeout on own, i'd grateful suggestions or direction towards that's been done. thank reading. brian make function this (function( $ ) { jquery.fn.fillprogressbar = function(option){ var settings = jquery.extend({ fromvalue : 0, tovalue : 0, interval : 1000 },option); function fillprogressbar(element,initialvalue,tovalue,interval){ // console.log("out "+initialvalue); if(initialvalue<=tovalue){ /* $j(element).progressbar({ value : initialvalue++ });*/ $j(element).progressbar( "value", initialvalue++ );

asp.net mvc - MVC data annotaion for validating data type -

how customize data annotation validation scenario. i receiving error: the value 'select province' not valid province. i want this please select country my viewmodel looks this: [displayname("province")] [uihint("provincedropdown")] public long? provinceid { get; set; } my view select list : <select name="provinceid" id="provinceid" class="input-validation-error"> <option value="">select province</option> <option value="613">allen </option> <option value="614">anderson</option> // data truncated .... </select> you need add errormessage = "please select country" annotation attribute, similar the example here: [range(0, 50, errormessage = "quantity on order must between 0 , 50.")] public int onorder { get; set; }

sql - How to format many values in a database? -

i have database (in sqlite) in entries (or possibly all) strings first character space. the database may small enough me export csv file , regular-expression search-and-replace delete leading space. there sql statement can achieve same result? (the database has on 60 columns---listing each 1 might tedious.) you can strip unneeded spaces right in select query: select trim(field) or once on rows update table set field = trim(field)

Difference between MySQL release versions -

what difference between mysql-5.5.8.zip , mysql-5.5.8-win32.zip in http://dev.mysql.com/downloads/mysql/ download page. have win 2k environment, binary should use , why have huge size difference between above? the smaller package not contain test suite , embedded server. anyway, suggest use msi installer instead - installation , configuration way more straightforward.

using jquery.noConflict() -

i have 2 files. html , .js files. in code.js, have written jquery code , in html file, including code.js following: <script src="jquery-1.4.2.js"></script> <script src="jquery.interval.js"></script> <script src="code.js"> jquery.noconflict(); var $jcode = jquery; </script> in code.js, have written following: jcode(document).ready(function() { jcode.interval(checkforms, 2000); }); when run it, gives me error can not read property of interval undefined. think there wrong usage of noconflict. can please help? thanks the problem encountering in use of src attribute script tag contains inline code. either move call noconflict code.js or create new script tag calls noconflict prior referencing code.js. <script> jquery.noconflict(); var $jcode = jquery; </script> <script src="code.js"></script> also, noted others, sure use $jcode instead of jcode when referencin

Setup that selects automation server (written in .NET) in excel -

we have excel formulas written in .net , exposed excel via com. user wants use our formulas have to: run bat file registers dll's com (using regasm) then in excel (2010) select file|options|add-ins|excel add-ins|automation|select our server|go|go we want avoid (2.) using automatic setup. have idea how can accomplished? thanks in advance. you have not had answer in time. not know work, may worth trying: sub add_an_addin() dim oaddin addin dim otempbk workbook set otempbk = workbooks.add set oaddin = addins.add("e:\costbenefit1.0.xla", true) oaddin.installed = true otempbk.close end sub from: http://vbadud.blogspot.com/2007/06/excel-vba-install-excel-add-in-xla-or.html

c++ - Problem with Tail Recursion in g++ -

i'm messing around tail-recursive functions in c++, , i've run bit of snag g++ compiler. the following code results in stack overflow when numbers[] on couple hundred integers in size. examining assembly code generated g++ following reveals twosum_helper executing recursive call instruction itself. the question of following causing this? a mistake in following overlooking prevents tail-recursion. a mistake usage of g++. a flaw in detection of tail-recursive functions within g++ compiler. i compiling g++ -o3 -wall -fno-stack-protector test.c on windows vista x64 via mingw g++ 4.5.0. struct result { int i; int j; bool found; }; struct result gen_result(int i, int j, bool found) { struct result r; r.i = i; r.j = j; r.found = found; return r; } // return 2 indexes numbers sum target. struct result twosum_helper(int numbers[], int size, int target, int i, int j) { if (numbers[i] + numbers[j] == target) return gen_re

php class extend approch vs static approch,which one is better -

approch 1: class storage extends saestorage { public function save($data,$name){ if (! $this->write ( st_domain, $name, $data )){ $error_message = $this->errmsg(); $result['error'] = $error_message; return $result; }else{ $url = $this->geturl ( st_domain, $name ); return $url; } } } approach 2: class storage { public static function save($data,$name){ $saestorage = new saestorage(); if (! $saestorage->write ( st_domain, $name, $data )){ $error_message = $this->errmsg(); $result['error'] = $error_message; return $result; }else{ $url = $saestorage->geturl ( st_domain, $name ); return $url; } } } i propose use dependency injection pattern. here example

iphone - Mobile Safari video question -

i'm playing iphone's safari html5 <video> tag , wondering if there's way programmatically quit fullscreen mode once video done playing? you start fullscreen mode using play()-function, how end it? thanks in advance, thomas use "ended" event , webkitexitfullscreen() method. if using jquery how that: // #video id of <video> element. $('#video').bind('ended', function() { var videoel = document.getelementbyid('video'); videoel.webkitexitfullscreen() }); the trick sending video fullscreen mode , playing video 1 click on thumbnail. life of me can't figure out!

Jquery and dynamic content -

i have following html code: <div id="summary_form"> <textarea class="summary">please fill in</textarea><br/> <textarea class="summary">please fill in</textarea><br/> <div> and have following js code called on document.ready: var summaries = $('textarea.summary'); this js grabs textareas class name 'summary' , stores in summaries variable. i have link when users click on it, dynamically add textarea 'summary' class name using ajax, follows: $("#add_summary").click(function(){ $('#temp').load("/addsummary.html", function() { $("#summary_form").append($('#temp').html()); summaries = $('textarea.summary'); }); the addsummary.html contains following html: <textarea class="summary">please fill in</textarea><br/> when form submitted, running following code clear textareas

vb.net - How to revert Corporate Windows 7 Theme -

as christmas week side-project thought i'd knock quick console app can run windows start-up folder. the application going delete unwanted global corporate desktop icons (i run clean desktop - common?) , reset windows 7 theme lovely visual studio 2010 graphics. i have read reasons why shouldn't done pro grammatically user feel case different every morning manually deleting icons , resetting theme (policy not stopping - reapplying every morning) though little side project save me time in long term. i deleting icons ok struggling set theme ala: dim key registrykey = my.computer.registry.currentuser.opensubkey("software\microsoft\windows\currentversion\themes", true) key.setvalue("currenttheme", "c:\users\myprofile\appdata\local\microsoft\windows\themes\vs2010.theme") key.close() this setting registry key correctly not applying it. suggestions how make work or alternatives appreciated. may try simple wallpaper set use them

Unit testing cookies in PHP -

the default practice unit testing functionality relies on session/cookie information use abstraction library. if want write , unit test abstraction library? documentation php setcookie function says cookie available on next request. using command line tool testing, there no such thing "request". how can unit test correct cookie settings? i want test if parameters of setcookie function set correctly abstraction library. parameters set according conditions , method calls. the solution can think of mock setcookie function runkit extension, don't want install. other ideas? i found another, simple solution: class wrapper around php setcookie function simple, not need unit tested: /** * wrapper around setcookie function better testability */ class cookiesetter { public function setcookie($name, $value = "", $expire = 0, $path = "", $domain = "", $secure = false, $httponly = false) { return setcookie($name, $v

c# - copy database row with all dependency with others Tables -

hi have below mentioned tables , every table id auto incremented in db (i can't change property). box_table id name cost 1 box1 100 2 box2 175 fruit_table id name cost 1 apple 100 2 orange 75 3 bannana 25 box_fruit_table id box_id fruit_id 1 1 2 2 1 3 3 2 1 4 2 2 i trying duplicate row of table box_table. i trying in wpf using dataset adding 1 row dataset , copying content of duplicating row except id , doing commiting. after getting duplicated id have update box_fruit_table. problem facing is : id autoincrement in db, after commit generated id. because of not able update box_fruit_table duplicated row. do following steps 1- save in parent table 'box_table' 2- latest id generated 3- update box_fruit_table new id.

objective c - How to add an image as html and load it to webview in iPhone sdk? -

i implementing webview based application, in tried load image not coming expected. don't know problem. following code tried. please suggest me if did thing wrong. nsstring *returnstring = @""; returnstring = [returnstring stringbyreplacingoccurrencesofstring:@"<html><body>" withstring:@"<body> <p>hello sekhar"]; returnstring = [returnstring stringbyappendingstring:@"<img src='tutorial/images/bg1.png'"]; returnstring = [returnstring stringbyappendingstring:@"alt='footer'"]; returnstring = [returnstring stringbyappendingstring:@"align='middle' width='140' height='32' />"]; returnstring = [returnstring stringbyappendingstring:@"</p></body></html>"]; [mywebview loadhtmlstring:returnstring baseurl:[nsurl urlwithstring:@"http:www.google.com"]]; nsstring *bundlepath = [[nsbundle mainbundle] bundlepa

iOS Barcode Scanner -

i'm interested in creating app uses camera barcode scanner. have vague idea must no idea how or if i'm right. i know entails image processing, analyse barcode (white spaces/blackspaces), maybe image framing right, no idea how start. can point me in right direction? thanks you might take @ zxing . free, open source implementation of barcode scanning based on image processing. written android platform, portions have been ported various other platforms , @ least reference guide on how type of thing.

iphone - open another view controllers view from right side of the screen -

i want open viewcontroller right side of screen. that on doing [self presentmodalviewcontroller:pvc animated:yes]; i want viewcontroller's view appear if sliding right of screen instead of appearing if coming bottom of screen :) how can achieve that. please :) look uinavigationcontroller - class reference . lets organize hierarchy slide in side. or can play uiview animation blocks . figure out whats best app. if have several things pushing side, categories, use uinavigationcontroller. if have simple view want come in side , leave, you'll want use uiview animation or other animation methods. uiview animation this: [uiview beginanimations:nil context:nil]; //code move view on screen [uiview setanimationduration:0.5]; [uiview commitanimations];

hook - hooking ADO.Net -

i want hook functions when process using ado.net, native function ado.net uses connect database? dlls use? ado.net implementations use managed code execute database operations. there not single native function set looking for.

c# - How to tell the debugger to ignore breaking on thrown exceptions? -

Image
i have textbox in validate input third party library. however, library throws custom exceptions when syntax incorrect. not real big deal, except when debugging. when debugging, since text in textbox wrong (i still typing it), debugger stop after each letter until correct, annoying validate each letter. how can tell debugger not break @ these custom exceptions? p.s. have tried filter debug -> exceptions (added in common language runtime exceptions ), did not work me. debugger still stops @ line library called. p.p.s. using visual studio 2010. answer: in end close ps. pretty silly mistake: had typo in namespace. pop catalin , madhur ahuja pointing out! there 'exceptions' window in visual studio ... try ctrl-alt-e when debugging , click on 'thrown' checkbox exception want stop on you looking reverse of this: visual studio: how break on handled exceptions?

c# - Can j# be used to provide jdbc functionality to an asp.net mvc application? -

i have service exposes jdbc interface ("yolus"/"ion arc" if familiar), , i'd able commincate .net. i'd rather not use odbc-jdbc bridge, it's real pain. is possible use j# , integrate or expose existing .net codebase (asp.net mvc 2). thanks j# no longer supported recommend stay away it. why .net application ever need jdbc functionailty when there's ado.net?

c++ - How to save/serialize compiled regular expression (std::regex) to a file? -

i'm using <regex> visal studio 2010. understand when create regex object it's compiled. there no compile method in other languages , libraries thinks that's how work, right? i need store large amount of compiled regexes in file chunk of memory block , compiled regex. i can't figure how this. found in pcre possible it's linux library. there windows [version 2 it's 3 years old , use more high-level approach (there isn't c++ wrapper in windows version). so possible use save std:regex or boost::regex (it's same right?) chunk of memory , reuse later? or there other simple library windows allows this? edit: great answers. i'll check if sufficient store regex string , if still slow i'll test , compare old pcre library. i don't think can done without modifying boost library support it. i don't know how boost regex library implemented, regex libraries compile things binary blob that's interpreted later ser