Posts

Showing posts from April, 2015

python - Data insertion error: invalid literal for int() with base 10 -

i'm using django-nonrel on google app engine. i'm trying add row database error when trying use save(): invalid literal int() base 10 here's code: views.py from django import forms django.contrib.auth.decorators import login_required django.contrib.auth.forms import usercreationform django.http import httpresponseredirect django.shortcuts import render_to_response forms import sayform models import saying, category import datetime def say_something(request): if request.method == 'post': form = sayform(request.post) if form.is_valid(): cd = form.cleaned_data content = cd['content'] category_temp = "uncategorized" category = category.objects.get(name = category_temp) added_date = datetime.datetime.now() added_user = request.user saying = saying(content, category, added_date, added_user) saying.save() return httpresponseredirect('/contribute/success...

sql - zend retriving tag list -

i have problem zend. here is. i'm going make kind of articles db, containt info. every article marked 1 or more tags (like wordpress). i have controller (let index) , action (also index). need articles , tags, associated it, when user goes site/index/index. i have 3 tables: articles(idarticles, title..) tags(idtags, title) taglist(idarticles, idtags). how can read tags, associated article? zend's mvc doesn't include model, however, quickstart guide outlines creating model . the simplest way (not best way), setup connection in application.ini , or setup adapter (see zend_db_adapter docs): $db = new zend_db_adapter_pdo_mysql(array( 'host' => '127.0.0.1', 'username' => 'webuser', 'password' => 'xxxxxxxx', 'dbname' => 'test' )); then use sql select data. //all articles $articles = $db->query('select * articles'); //a article's tags $tags = $db-...

c++ - std::wstring length -

what result of std::wstring.length() function, length in wchar_t(s) or length in symbols? , why? tchar r2[3]; r2[0] = 0xd834; // d834, dd1e - musical g clef r2[1] = 0xdd1e; // r2[2] = 0x0000; // '/0' std::wstring r = r2; std::cout << "capacity: " << r.capacity() << std::endl; std::cout << "length: " << r.length() << std::endl; std::cout << "size: " << r.size() << std::endl; std::cout << "max_size: " << r.max_size() << std::endl; output> capacity: 351 length: 2 size: 2 max_size: 2147483646 std::wstring::size() returns number of wide-char elements in string. not same number of characters (as correctly noticed). unfortunately, std::basic_string template (and instantiations, such std::string , std::wstring ) encoding-agnostic. in sense, template string of bytes , not string of characters.

WPF data binding -

consider following xaml code: <stackpanel> <listbox x:name="lbcolor"> <listboxitem content="blue"/> <listboxitem content="green"/> <listboxitem content="yellow"/> </listbox> <textblock> <textblock.text> <binding elementname="lbcolor" path="selecteditem.content"/> </textblock.text> <textblock.background> <binding elementname="lbcolor" path="selecteditem.content"/> </textblock.background> </textblock> </stackpanel> i understand how text property binding works. internally converted like: textblock.text = lbcolor.selecteditem.content; but how background bound same source? code: textblock.background = lbcolor.selecteditem.content; is incorrect. how can...

c++ - How Can I execute my code on MessageBox Ok click -

this might simple new mfc. i have messagebox: messagebox("do want save configuration changes","nds",1); which have ok , cancel option. want write code on click of ok if(messagebox("blah", "nds", 1) == idok) { // hit okay } http://msdn.microsoft.com/en-us/library/ms645505(vs.85).aspx

asp.net - Youtube video double click -

i have embedded tube video project.the problem i'm facing when double click on video opens in new tab.what want when click video should open in full screen. thanks open in full screen behavior of player when used on youtube. open new tab behavior when player embedded in anther webpage. it seems modify behavior violation of youtube terms of service 4(f) 4. general use of service—permissions , restrictions f. if use embeddable player on website, may not modify, build upon, or block portion or functionality of embeddable player, including not limited links youtube website. http://www.youtube.com/t/terms

Winforms databinding and validation, why is datasource updated when validation fails? -

the code below illustrates unexpected (for me!) behaviour when combining data binding , validation in winforms. can tell me how can prevent datasource being updated when validation fails? many thanks. using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace validationbug { /// <summary> /// illustrates unexpected behaviour winforms validation , binding /// /// reproduce: run program, enter value textbox, click x close form. /// /// expected behaviour: validation of textbox fails data source not updated. /// /// observed behaviour: data source updated. /// </summary> public class form1 : form { private class data { private string _field; public string field { { return _field; } set { ...

How to use Flex and Java to download files from a server? -

i'm building flex web application there option export data table csv format (theoreitcally, far, haha). since it's web application, assumed best way go send request server generate file, , either send file (or link it) flex application, , use filereference download file. correct way go this? could give me pointers on how this, however? there exisitng remote objects in place call java functions on server, thought i'd try along lines? i did bunch of research, , stumbled across things httpresponses , httpservletresponses in java, have no idea how bridge gap between client-side , server-side use effectively. haha. thanks! what have done have flex open new tab/window , navigate servlet. navigatetourl(new urlrequest(url),'_blank'); then use httpservletresponse write file out client, displayed in browser. pdf, though. in order use httpservletresponse you'll need write httpservlet , configure in web.xml . here basic tutorial. google has lot ...

Can't find image in GD (PHP) -

i'm trying put watermark on images, script can't find watermark image. i'm doing dynamically, each user there watermark in watermarks folder. when trying use code: session_start(); $username = $_session['_user_login']; // set path image watermark $input_image = $targetpath.$newname; // read in text watermark image $watermark = imagecreatefrompng("../watermarks/$username.png"); nothing happens. tried printing user name variable , works fine. tried print image , works also. when using imagecreatefrompng, watermark image never found. looking in log see following error: warning: imagecreatefrompng(../watermarks/.png) [function.imagecreatefrompng]: failed open stream: no such file or directory i don't it. doing wrong? thanks. you need use: $watermark = imagecreatefrompng(dirname(dirname(__file__)) . "/watermarks/" . $username . ".png"); (you can print dirname(__file__) check directory structure b...

Combine Rails 3 scope into class method -

i have 4 rails 3 scopes simplify: scope :age_0, lambda { where("available_at null or available_at < ?", date.today + 30.days) } scope :age_30, lambda { where("available_at >= ? , available_at < ?", date.today + 30.days, date.today + 60.days) } scope :age_60, lambda { where("available_at >= ? , available_at < ?", date.today + 60.days, date.today + 90.days) } scope :age_90, lambda { where("available_at >= ?", date.today + 90.days) } i thought class method: def self.aging(days) joins(:profile).where("available_at null or available_at < ?", date.today + 30.days) if days==0 joins(:profile).where("available_at >= ? , available_at < ?", date.today + 30.days, date.today + 60.days) if days==30 joins(:profile).where("available_at >= ? , available_at < ?", date.today + 60.days, date.today + 90.days) if days==60 joins(:profile).where("availa...

CSS :last-child selector in javascript? -

i looking select last td in each row , using css selector right .table td:last-child doesnt work in ie there way can select through javascript (without framework) ie? apply css styles. var rows = document.getelementbyid('tester').rows; for(var = 0, len = rows.length; < len; i++) { rows[ ].lastchild.style.background = 'orange'; } example: http://jsfiddle.net/jsyyr/ edit: if you'll running in browsers, may safer this: var rows = document.getelementbyid('tester').rows; for(var = 0, len = rows.length; < len; i++) { rows[ ].cells[ rows[ ].cells.length - 1 ].style.background = 'orange'; } example: http://jsfiddle.net/jsyyr/2/ this because browsers insert text node if there's space between last </td> , closing </tr> . such, lastchild wouldn't work.

Which ORM tool to use for .NET C# for performance and feature set -

possible duplicate: best performing orm .net hey, i realise there similar questions , posts etc on asking different. my requirements: multi database capable little or no modification needed, mssql , mysql must. lightweight, can't use ton of memory return single field db. fast, on enterprise standards. no point haing orm has customers waiting. mature , last. don't want adopt orm expires after. i had @ ormbattle.net and, once noticed creators of dataobjects behind it, ruled being biased. i have been using subsonic time , , find easy work in opinion easiest solution not best solution. rob connery agreed not fleshy nhibernate in comparrision. which brings me on next point, nhibernate seems, haven't tested yet myself, flegged orm tool mature, not subsonic isn't, , rounded. see plenty of people saying yay or neigh no 1 says why. yes, realise quite "heavy" , has learning curve, new tool, don't want replace sunsonic going slow pr...

JQuery unbinding a specific handler -

given code below, how can unbind('click', h) work? it doesn't work. make h global variable don't know how "set up" given msg variable set within function. ?? function x(open) { var msg = "blah"; var h = function (e) { e.preventdefault(); showdialog(msg); }; if (open === true) { but.unbind('click'); link.unbind('click'); } else { but.click(h); link.click(h); } } msg = "blah" h = function(e) { e.preventdefault(); showdialog(msg); }; function x(open) { msg = "whatever"; if (open === true) { but.unbind('click', h); link.unbind('click', h); } else { but.click(h); link.click(h); } } *i think

tsql - T-SQL reflection on parameters -

is possible use kind of reflection on parameters in t-sql module (function,procedure)? procedure x(@foo nvarchar(max),@bar nvarchar(max)) ... set @foo = isnull(@foo,0); set @bar = isnull(@bar,0); would possible iterate on parameters , set values in loop? or need use sqlclr this? if you've many parameters need programatically enumerate them have many parameters! maybe switching alternative data structure such table valued parameter or xml document give cleaner way such complex data procedures/functions? however, if have special need take @ sys.parameters (assuming you're using sql server 2005 or later).

c# - mef - how to make recomposition work automatically? -

i've been trying recomposition work no luck... tried many times , many approches - no luck... can point out mistake? expect after drop new .dll plugins directory senders collection automatically repopulated new stuff... //exported classes [export(typeof(isender))] public class smtp : isender { public string name { { return "smtp plugin"; } } public void send(string msg) { } } [export(typeof(isender))] public class exchange : isender { public string name { { return "exchange plugin"; } } public void send(string msg) { // .. blah } } /--------------------------------------------------------------------- /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : window { private const string str_pugins = ".\\plugins"; [importmany(typeof(isender), allowrecomposition = true)] private list<isender> se...

Supporting Multiple Screens for some devices in Android -

i read official document supporting multiple screens http://developer.android.com/guide/practices/screens_support.html according document, should create different directories different resolultion. now question. how support devices normal screen , high density or low density? i ask because, there 2 posibilities (wvga800 (480x800) , wvga854 (480x854)) , (wqvga400 (240x400) , wqvga432 (240x432)) , don't know store background images them. i take drawable-normal-hdpi or drawable-normal-ldpi, how make difference between 480x800 , 480x854 or between 240x400 , 240x432?! thank in advance, mur this documentation on how specify alternate resources. so drawable-normal-hdpi medium screens high dpi.

Keyboard shortcuts in WPF MVVM? -

i have wpf application follow mvvm pattern. need implement keyboard shortcuts. these shortcut have contol webbrowser control behaviour. defined first custom command , added view's inputbindings. there more commands , have invoke scripts on browser: mainwindow.xaml.cs: ... commandbinding cb = new commandbinding(remotecontrolcommands.testcommand, mycommandexecuted, mycommandcanexecute); this.commandbindings.add(cb); keygesture kg = new keygesture(key.q, modifierkeys.control); inputbinding ib = new inputbinding(remotecontrolcommands.testcommand, kg); this.inputbindings.add(ib); } private void mycommandexecuted(object sender, executedroutedeventargs e) { webbrowser.invokescript("foo", "hello world!"); } private void mycommandcanexecute(object sender, canexecuteroutedeventargs e) { e.canexecute = true; } my question how fit mvvm patern? mvvm new concept me un...

Lua code golf problem -

i've been playing around code golf problem: https://www.spoj.pl/shorten/problems/kamil/ i've got solution down 55 characters: l in io.lines()do print(2^#l:gsub("[^tdlf]",""))end now, shortest submitted solution in lua 47 characters long. can't figure out how further reduce mine , it's been driving me crazy. have hint me? i've tried working on io.read("*a") rid of loop didn't help. lua (54 chars) repeat print(2^#io.read():gsub('[^tdlf]',''))until nil errors on completion, maybe not ok otherwise spent while experimenting second return of gsub; seem gain 1 character return selecting.

Workarounds For Phpunit's Incorrect File Sorting? -

anyone know of workaround phpunit's illogical file sorting? i've got tests in subfolder names "addmin001.php", "...002.php", etc. , phpunit insists on running 002, 003, 004, 001. my attempts use phpunit.xml produce: "uncaught exception 'phpunit_framework_exception' message 'could not load "[redacted]phpunit.xml".' in /usr/share/php/phpunit/util/xml.php:212". creating alltests.php classes seems lot of work , maintenance, if necessary i'll go route. phpunit not sort tests @ all, run in whatever order filesystem returning them. creation date, else, depends on filesystem (and os) in use. in case, can not rely on order, because factors outside tests can change it. there few tricks, use - example test dependencies .

tomcat6 - Stop Apache Tomcat when web application stops -

scenario: apache tomcat 6.0 started service on windows server 2008 r2 using wrapper ( org.tanukisoftware.wrapper.wrapperstartstop ) uses org.apache.catalina.startup.bootstrap . in course of tomcat startup 1 web application started. web application needs connect remote database , check connection. retries connect couple of times if database not available , shutsdown after x tries. problem: i need stop apache tomcat after webapp exits when database connection not available. possible solutions: stop apache tomcat within web application (already tried shutdown port did not work because connection refused - standalone java application worked) call external java application within web application configure apache tomcat shutdown if web application shuts down - not find way that any ideas? maybe different approach? regards alexander system.exit(0) within webapp shut down tomcat instance if there no security manager configured. works standalone server, not s...

testing - What would you ask, if you were hiring a software tester? -

i going coach student career software tester or software test manager. have suggestions, interview questions should prepared? thank in advance. i'd ask - "how test 'this'?", 'this' relevant work - or @ least know lot about. example, ask "how test web browser?". you'd want see if had nice battery of functional test ideas, idea of big picture or (as stated above), non-functional areas such performance, reliability, security, etc. i'd ask them questions communication - e.g. "give me example of how resolved conflict co-worker". testers "bearers of bad news", interpersonal skills, ability communicate peers critical. can examples of using data make decisions, or influence without authority valuable. finally, ask "how learn?" - testing learning activity, ability - , demonstrated experience in quick learning sign of successful.

python - is there a simple class/library which uses pyQT/webkit to scrape websites with javascript support? -

i'm looking @ using pyqt scrape websites javascript support, after dabbling static html alternatives (beautifulsoup, mechanize etc.) clearly pyqt more generic tool , such not optimised needs. is there classes/libraries give me simple functions using pyqt relatively simple scraping duties? i have found few classes/scripts searching google, hopefull better suited needs! i need submit forms, maintain sessions, , return html processing lxml. thanks :) you might want take @ spynner --it's programmatic browser module based on qtwebkit. might meet needs.

javascript - Why doesn't JsArrayString implement iterable? -

quick question here -- used jsarraystring first time, , surprised didn't work: jsarraystring object = ...; (string s : object) so wrote c-style loop: jsarraystring object = ...; (int i=0; i<object.length(); i++) { s = object.get(i) ... not big deal, seems have been simple gwt team have jsarraystring implement iterable, wanted check , make sure wasn't missing something... i suspect it's matter of code bloat , matter code size. if make jsarray implement iterable , might open door other additions wouldn't useful. jsarray s meant absolutely simple , barebones possible. additionally, write own jsiterable class if want behavior, said should pretty trivial implement. the lightweight collections design doc addresses of issues around using jre collections , related concepts , discusses features left unsupported ensure absolute minimum code size, including: until gwt compiler can optimize (which cannot date), new collections not suppor...

python - recursive dircmp (compare two directories to ensure they have the same files and subdirectories) -

from observe filecmp.dircmp recursive, inadequate needs , @ least in py2. want compare 2 directories , contained files. exist, or need build (using os.walk , example). prefer pre-built, else has done unit-testing :) the actual 'comparison' can sloppy (ignore permissions, example), if helps. i boolean, , report_full_closure printed report. goes down common subdirs. afiac, if have in left or right dir only different dirs. build using os.walk instead. here's alternative implementation of comparison function filecmp module. uses recursion instead of os.walk , little simpler. however, not recurse using common_dirs , subdirs attributes since in case implicitly using default "shallow" implementation of files comparison, not want. in implementation below, when comparing files same name, we're comparing contents. import filecmp import os.path def are_dir_trees_equal(dir1, dir2): """ compare 2 directories recursiv...

c++ - Const method accessing static variables -

i apologize if has been asked before. search results did not turn similar question. this conceptual question. according msdn , others well: a constant member function cannot modify data members or call member functions aren't constant why allowed access static member variables const method? the c++ standard says const member functions: if member function declared const , type of const x* , [...] in const member function, object function called accessed through const access path; therefore, const member function shall not modify object , non-static data members. so see non-static data members part of 'constness' of member function. however, think more importantly indicates way understand what's going on const member functions makes implicit this pointer pointer const . since static members don't need accessed via this pointer (implicitly or explicitly), access them isn't const qualified.

Filename extraction with regex -

i need able extract filename (info.txt) line like: 07/01/2010 07:25p 953 info.txt i've tried using this: /d+\s+\d+\s+\d+\s+(?.?) /, doesn't seem work ... \d\d:\d\d\w\s+\d+\s+(.*?)$ $1 file name the problem original regex forgets special characters : , / , , (?.?) means nothing...

Splitting data from MySQL using PHP & Javascript works in IE but not in FF -

i have following javascript function on page: function setfields(){ var menu = document.getelementbyid('editlocation'); var itemdataarray = menu[menu.selectedindex].value.split('|'); form.locationshortname.value = itemdataarray[0]; form.locationlongname.value = itemdataarray[1]; form.phone.value = itemdataarray[2]; form.address1.value = itemdataarray[3]; form.citystatezip.value = itemdataarray[4]; form.maplink.value = itemdataarray[5]; } down on form, have following: <select class="input2" name="editlocation" id="editlocation" onchange = "setfields();"> <option value="-add new-"<?php if($editlocation=='-add new-'){echo(' selected="selected"');} ?>>-add new-</option> <?php require_once('connection.php'); $connection = mysql_connect($hostname,$username,$password) or die (mysql_errno().": ".mysql_...

testing - Exception order when multiple are possible -

if function has 2 arguments , both produce exceptions, order have them raised in , define it? this came when writing test function take directory on disk , compress file. instance: void compress(string dirpath, string filepath); i haven't written function yet , i'm putting tests in place. the thing is, if directory path doesn't exist i'd have exception missing directory thrown , if file had write permissions in way i'd have exception thrown show that. however, if both paths cause exceptions? throw first, second, third one, or unknown state? we'd considered having single exception "something broke", message different in each case doesn't help. i've thought of few ways around such throwing based upon left right processing of arguments, or stating "if dirpath invalid x thrown else if filepath invalid y thrown" , placing interface definition whoever implements should (hopefully) follow specification. just wondering approac...

sql server - Installing SQL Management Studio -

i have installed sql server microsoft visual studio , need use sql server management studio , there no such application in start menu. has import , export data , sql server configuration manager. do next? when tried install sql server 2008 given link mrkow gives following error title: sql server setup failure. sql server setup has encountered following error: invoke or begininvoke cannot called on control until window handle has been created.. buttons: ok so next ?? it different download , not part of visual studio. it part of sql server , can found on install media (cd/dvd) - can download express edition free, ssms 2005 here , ssms 2008 here .

django- how to check validity of single input field inside multi input form -

i have form multiple input fields, want use 1 input form. proper way check field validity , cleaned data 1 field? thanks ! the proper way add it's own form ;) but... can this: form = someform(request.post) field = form.fields['your_field'] data = field.widget.value_from_datadict(form.data, form.files, form.add_prefix('your_field')) cleaned_data = field.clean(data)

ruby on rails - Unknown column error with has_one association and join in named scope -

i have product , payment_notification model following association class product < activerecord::base has_one :payment_notification end class paymentnotification < activerecord::base belongs_to :product end i'm setting named scope should fetch products associated payment_notification has status completed. i under impression should work in product model: scope :completed, joins(:payment_notification).where(:payment_notification => { :status => 'completed' }) but results in following error: error: mysql::error: unknown column 'payment_notification.status' in 'where clause': select `products`.* `items` inner join `payment_notifications` on `payment_notifications`.`product_id` = `productss`.`id` (`payment_notification`.`status` = 'completed') can help? try this: scope :completed, joins(:payment_notification).where(:payment_notifications => { :status => 'completed...

android - Trying to use Ortho for drawing 2D -

i'm having trouble setting ortho view drawing 2d ontop of 3d scene. i set view this: public void onsurfacechanged( gl10 gl, int width, int height ) { gl.glviewport( 0, 0, width, height ); gl.glmatrixmode( gl10.gl_projection ); gl.glloadidentity(); glu.gluperspective( gl, 45.0f, ( ( float )width / ( float )height ), 0.1f, 100.0f ); gl.glmatrixmode( gl10.gl_modelview ); gl.glloadidentity(); } and set ortho view this: public void onsurfaceortho( gl10 gl ) { gl.glorthof( 0.0f, 100.0f, 100.0f, 0.0f, -0.1f, 0.1f ); gl.glmatrixmode( gl10.gl_projection ); gl.glloadidentity(); } then draw frame this: public void ondrawframe( gl10 gl ) { gl.glclear( gl10.gl_color_buffer_bit | gl10.gl_depth_buffer_bit ); gl.glloadidentity(); scene.ondrawframe( gl ); gl.glpushmatrix(); onsurfaceortho( gl ); screen.ondrawframe( gl ); gl.glpopmatrix(); } the scene , screen objects drawing objects 3d , 2d. screen object doesn't...

TableLayoutPanel change scrollbars (C# WinForms) -

i have tablelayoutpanel autoscroll=true. works fine: there chance change style of scrollbars. i'd have smaller scrollbars. any ideas - regards hw the default controls going use default window style scroll bars. have derive custom class, render on own change.

machine learning - Neural network weighting -

recently i've studied backpropagation network , have done manual exercise. after that, came question( maybe doesn't make sense): there thing important in following 2 different replacement methods: 1. incremental training: weights updated once delta wij's known , before presenting next training vector. 2. batch training: delta wij's computed , stored each exemplar training vector. however, delta wij's not used update weights. weight updating done @ end of training epoch. i've googled while haven't found results. so referring 2 modes perform gradient descent learning. in batch mode, changes weight matrix accumulated on entire presentation of training data set (one 'epoch'); online training updates weight after presentation of each vector comprising training set. i believe consensus online training superior because converges faster (most studies report no apparent differences in accuracy). (see e.g., randall wilson & tony martine...

.net - XmlSerializerNamespaces is ambiguous in the namespace System.Xml.Serialization? -

anyone ever seen error? it's happening seemingly out of in .net 3.5 web app project instantiates namespaces object use in xml serialization. have cleaned , tried rebuild solution, checked , reset references system.xml. in code has not been touched in on year. project upgraded .net 3.5 has been through @ least 2 build cycles since upgrade without issue. ideas? here guidance ms provides some code: dim serializernamespaces new system.xml.serialization.xmlserializernamespaces() serializernamespaces.add("xsi", "http://www.w3.org/2001/xmlschema-instance") this issue came again , thought i'd document here future reference. cause svcutil.exe used generate proxy wcf service call, , in doing created partial class in same .net namespace being used in class. in case partial class not being used commented out generated class , issue solved. namespace system.xml.serialization <system.diagnostics.debuggerstepthroughattribute(), _ s...

performance - Mysql Find command has become very slow -

each of web requests involved couple of 'select' queries. table in question went 75,000 rows ~90,000 , select command slowed taking ~100ms ~1.2s what best way find reason of sudden performance drop? imagine key can not stored in memory , causing drop. how check that? please advise. it sounds mysql shifting internal table memory disk. classic "tipping-point" mysql performance drops off cliff once reaches size. when realize default mysql configuration extremely conservative (even so-called "huge" config) , several server settings can increased @ least order of magnitude. the first avenue of exploration use explain on query , indications putting temporary table information on disk. more information available in mysql docs here , here

CSS: exceeding width when nospace? -

#profilewall{ margin: auto; width: 1200px; } and inside it, if have without no space @ all: sdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasadsadsadsadsadssdfasads it exceeds width , continues. if theres spaces in it cuts , goes new line when reach width should. how can fix this? overflow:hidden or css3 word-wrap: break-word css3 @mistabell

SQL Server 2005: Select One Column If Another Column Is Null or Contains a Word -

i trying create report using bids. want 1 of columns provide email address. have 2 tables containing email addresses. 1 contains original email address customer provided when started doing business us. other table contains possibly updated (alternate) email address submitted on website. sometimes original email address uses our company domain because company use create emails clients did not have address. i need construct query evaluate original email address. needs 2 things: if original email address blank, needs include alternate email address. if original email address contains our domain (customer@mydomain.com), needs include alternate email address. if 2 items above not case, needs spit out original email address. the query need spit out evaluation single column called email. can done? should towards bids instead? if so, direction? thanks in advance help. easy peasy using case. like: select whatever1, whatever2, case when originalemail null alternate...

clojure - How to design an api to a persistent collection in C#? -

i thinking creating persistent collection (lists or other) in c#, can't figure out api. i use ' persistent ' in clojure sense : persistent list list behaves if has value semantics instead of reference semantics, not incur overhead of copying large value types. persistent collections use copy-on-write share internal structure. pseudocode: l1 = persistentlist() l1.add("foo") l1.add("bar") l2 = l1 l1.add("baz") print(l1) # ==> ["foo", "bar", "baz"] print(l2) # ==> ["foo", "bar"] # l1 , l2 share common structure of ["foo", "bar"] save memory clojure uses such datastructures, additionally in clojure data structures immutable. there overhead in doing copy-on-write stuff clojure provides workaround in form of transient datastructures can use if sure you're not sharing datastructure else. if have reference datastructure, why not mutate directly instead of going ...

sql server - SQL 'float' data type, when output as XML, causes undesired float result -

you can try simply: table1: has column1 of type 'float' instead of select column1 table1; gives values seen in table. say returns 15.1 however, if try select column1 table1 xml path('table1'), root('someroot'), type returns: 1.510000000000000e+001 has seen this, , how fixed? in advance :) this when work floating point numbers. can try though: select convert(varchar(100), cast(column1 decimal(38,2))) you need adjust precision on decimal fit needs.

c# - ()=>getItem("123") is Func(bool) or Func(string,bool) -

for lambda expresssion ()=>getitem("123") , func(bool) or func(string,bool), suppose getitem return bool. it's func<bool> . the clue in () => part: means function has no input parameters.

tkinter - Ttk on python 2.7 -

i installed python 2.7 python website, , surprised find ttk wasn't included. did make mistake installing, or ttk not included in standard release? anyway, can copy of ttk install in python instalation. note: heard activestate release has ttk. should unistall , use instead? i think mean "ttk" not "tkk" the following should solve problems if case: from tkinter import * ttk import * for more ttk , tkinter in python2.7, reference: http://docs.python.org/library/ttk.html

objective c - Cocoa / Interface Builder: What do I need to subclass to replicate this window? -

Image
i'm guessing using custom nswindow, nstextfield, nssecuretextfield, nsbutton ? don't want replicate it, know involved in customizing app's ui level. the window hud-style panel, can in ib without subclassing anything. looks there's bit of custom background it, unless it's faintly showing behind it; if custom background, custom view content view job. the separator image view or custom view. the static text fields can done without subclassing. change text color. the editable text fields, both regular 1 , secure one, need subclass. have no idea how that. the follow-link button mix of custom drawing , standard image. start nsimagenamefollowlinkfreestandingtemplate image; draw that, fill empty path white using source-in blend mode. the other 2 buttons customized, using custom cells in order override background without overriding text drawing.

java - import os to j2me -

i trying write code j2me. has idea how this? thanks! import os if os.path.isfile("c:\\python\\myfolder\\test.txt"): understand line does. can start docs python's os module: http://docs.python.org/library/os.path.html read j2me docs find similar function call.

postgresql - Export database tables to .xlsx file -

i want export database tables excel 2007 spreadsheet using servlets. can me on this? use postgres sql end. you may looking api write ms office files . since note servlets, assume coding in java.

iphone - Problem UIview size after re-orientation -

first,i sorry poor english... so, have problem view added on other one. setting size of uiview in ib 200px/200px set center of view center of parent view. working great @ point. can see view in center of parent view want. then set - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation , that's working to. but when rotate iphone, size of view change full size, view don't want stay in center , go on top left of screen , resize fullscreen... can me problem ? have set frame , center after rotate ? can't automatic ? thank you! in ib, under "autosizing" section, remove "arrow" indicates auto width/height of component.

How's flexible array implemented in c? -

.. char arkey[1]; } bucket; the above said flexible array ,how? often last member of struct given size of 0 or 1 (despite 0 being against standard pre-c99, it's allowed in compilers has great value marker). 1 not create array of size 0 or 1 , indicates fellow coders field used start of variably sized array, extending final member available memory. you may find member of struct defining exact length of flexible array, find member contains total size in bytes of struct. links http://gcc.gnu.org/onlinedocs/gcc/zero-length.html is using flexible array members in c bad practice? http://msdn.microsoft.com/en-us/library/6zxfydcs(vs.71).aspx http://blogs.msdn.com/b/oldnewthing/archive/2004/08/26/220873.aspx example typedef struct { size_t len; char arr[]; } mystring; size_t mystring_len(mystring const *ms) { return ms->len; } mystring *mystring_new(char const *init) { size_t len = strlen(init); mystring *rv = malloc(sizeof(mystring) + ...

php - Is there a way to securely know the originating server hosting an AJAX call? -

lets imagine site embeds javascript file using standard script tag pointing server b. next site makes jsonp or ajax request resource on server b. there anyway server b definitively know specific jsonp request originated user on site a, , not user on site spoofing http referrer. the reason think there realm of possibility because site started communication it's embedding of server b's javascript. in way, couldn't original communication act security handshake, allowing subsequent calls pass through securely. because handshake made through insecure means doesn't prevent acting security handshake. any ideas of how task can accomplished? every solution can think broken notion every element of ajax call can faked. i read http://www.codinghorror.com/blog/2008/10/preventing-csrf-and-xsrf-attacks.html , detecting ajax in php , making sure request own website far tell focused on ensuring veracity of user , not veracity of referrer. ajax on https if wanted con...

python - "unknown column X.id" error in django using existing DB -

i trying create model existsing db. using output of manage.py inspectdb , models.py file looks this: from django.db import models ...some more stuff here... class scripts(models.model): run_site = models.foreignkey(sites, db_column='run_site') script_name = models.charfield(max_length=120) module_name = models.charfield(unique=true, max_length=120) type = models.charfield(max_length=24) cat_name = models.charfield(max_length=90) owner = models.foreignkey(qapeople, db_column='owner') only_server = models.charfield(max_length=120, blank=true) guest = models.integerfield() registered = models.integerfield() super = models.integerfield() admin = models.integerfield() run_timing = models.charfield(max_length=27) manual_owner = models.foreignkey(qapeople, db_column='manual_owner') script_id = models.integerfield(unique=true,) version = models.integerfield() comment = models.foreignkey('script...

java me - Changing font size in j2me -

can change siz,style,etc of font (javax.microedition.lcdui.font) in j2me @org.life.java true there isn't set size method..... being said there isn't "setsubstring" method either. strings fonts in j2me immutable http://en.wikipedia.org/wiki/immutable_object create new font desired properties.... http://download.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/index.html so instead of myfon.setsize(font.size_small) do myfont = font.getfont(myfont.getfontface(), myfont.getfontstyle(), font.size_medium) that work.

c# - When to use [MTAThread]? -

possible duplicate: could explain sta , mta? in c# windows forms application. have seen [stathread] in program.cs above main function. so want know when use sta or mta thread ? how, affects application ? a thread creates windows should always create single-threaded apartment. sta provides threading guarantees com object isn't thread-safe. few are. com infrastructure ensures methods of such object called right thread, marshaling call if necessary. quite similar control.begin/invoke() done automatically without coding. a number of windows facilities rely on guarantee. notably clipboard, drag + drop , shell dialogs (like openfiledialog) won't work without it. , lots of activex controls, webbrowser being common 1 you'll use in winforms project. making ui thread mta thread causes hard diagnose failure, deadlock being common one. or quick exception when .net wrapper component double-checks created on sta.

php - Best way to set charset for Zend_Db (or at least better than what I'm currently doing) -

i'm using zend_db , trying change charset utf8, here code: config.ini : [development] db.host = "localhost" db.username = "root" db.password = "toor" db.dbname = "db_whoopdiedo" db.charset = "utf8" bootstrap.php : class bootstrap extends zend_application_bootstrap_bootstrap { public function _initautoload() { zend_registry::set( 'config', new zend_config_ini(application_path.'/configs/config.ini', 'development') ); zend_registry::set( 'db', zend_db::factory('pdo_mysql', zend_registry::get('config')->db) ); zend_registry::get('db')->setfetchmode(zend_db::fetch_obj); zend_registry::get('db')->query("set names 'utf8'"); zend_registry::get('db')->query("set character set 'utf8'"); } } i t...

Enable access to registry in WinForms application of C# .Net -

by default : registry has been disabled "registry editing has been disabled administrator" in application want let users access registry when app runs , deny when app stops. looking forward advice on this. to allow users edit registry settings not accessible, need use impersonation. i.e. need have application run different user, 1 more priviledges. the easiest way achieve write .net windows service runs higher priviledges. service can still control registry settings allowed change. users start winforms app communicates service actual changes in registry. this require user (or operations) install service on machine admin rights.

c# - What's the correct way to not update an out variable -

i've implemented tryparse function class minmax this: public static bool tryparse(string s, out minmax result) { var parts = s.split(' '); if (parts.length != 2) { return false; } float min; float max; if (!float.tryparse(parts[0].trim(), out min) || !float.tryparse(parts[1].trim(), out max)) { return false; } result = new minmax(min, max); return true; } however doesn't compile since apparently out parameter needs written. what's correct way fix this? able use function if parsing fails, parameter passed remains unchanged. guess 1 way add like: result = result; but line issues warning. assuming minmax reference type, assign null it. other tryparse method work. check out code: string s = "12dfsq3"; int = 444; int.tryparse(s, out i); console.writeline(i); i set 0 instead of remaining @ 444. ...

makefile - Tips/resources for structuring C code? -

does have tips/resources how to, in best way, structure c code projects? (different folders etc.) , how know when it's split code separate files? , example of makefile? my project not big, wanna start structure code @ stage.. structuring code needs experience common sense. for splitting code, go readability: conceptually coherent functions/datatypes should go in same file. can take c standard library example. better keep data structure definitions , function declarations in separate headers. allows use data structures part of compilation unit if have not defined functions. files provide similar functionality should go in same directory. avoid deep directory structure (1 level deep best) complicates building project unnecessarily. i think makefiles ok small projects, become unwieldy bigger ones. serious work (if want distribute code, create installer etc) may want @ cmake, scons, etc. have @ gnu coding standards: http://www.gnu.org/prep/standards/standards.htm...

event handling - Static_cast compiler error in C++ sdi application -

i have small sdi application trying add tracking of menu usage, ie. how many times menu items selected user. some menu items handled view component (demoview.cpp) , others main app (demoapp.cpp). since tracking structure defined in main app, believe have notify view's parent special message when menu item (handled view) selected. if correct, problem cannot create proper on_message command. looks : on_message(wm_increase_freq, &cdemoapp::onincreasefreq) where onincreasefreq() defined : lresult cdemoapp::onincreasefreq(wparam, lparam) however error : error c2440: 'static_cast' : cannot convert 'lresult (__thiscall cdemoapp::* )(wparam,lparam)' 'lresult (__thiscall cwnd::* )(wparam,lparam)' i appreciate this according error, callback function must member function of class derives cwnd. make cdemoapp derive cwnd , code should compile , work.

approximately, how many web sites are developed in asp.net till-to-date? -

note: of course, know can't exact number; atleast need approximate answer. can help? 17345892039219 websites developed in asp.net till date , still going on. please dont ask source of data.

creating an algorithm to find repeating values of an array -

i made pseudo code algorithm find repeating values of array includes float numbers: mergesort(a); int <- 0 i<- a.lenght-1 if arr[i] == a[i+1] return a[i] while a[i] = a[i+1] i++ else i++ i want change above algorithm find repeating values , number of times repeat. have created following algorithm: mergesort(a); hashmap hashmap; int result <-0 int <- 0 i<- a.lenght-1 int j <- 0 if a[i] == a[i+1] j <- j+1 result <- a[i] while a[i] == a[i+1] <- i+1 j<- j+1 hashmap.insert(result , j) else i++ return hashmap is efficient algorithm? way use hashmap? you can use hashmap , this: hashmap hash; (int = 0; < a.lenght; i++){ value = hash.get(a[i]); if (value == null) // first time find a[i] hash.put(a[i], 1); else // a[i] duplicate hash.put(a[i], value + 1); } avarage case = o(...

css sprites: which html element using for background-position? -

i wondering using css sprites tag html best? i mean can use < img src="trasparent.png" style="background-position:ecc"> or ? i saw google using < span> "o" of g"o o o o o"gle thanks you can use element like. one thing note though elements <span> , <a> inline elements. if try , add dimensions them match size of background sprite, these dimensions ignored. fix can use things line-heights or padding set dimensions, or change element block level element using css: display:block . another rule allow dimensions added display:inline-block , can cause few issues in ie6 , earlier browsers.

python - Django WGSI paths -

i having problems setting wgsi django. i'm following http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/ . yet still confused put .wsgi file , if need set sys.path. have tried both directly outside , inside web root , can't work expected. # /home/ben/public_html/django_test/testproject/apache/django.wsgi: import os import sys os.environ['django_settings_module'] = 'testproject.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler() relivant apache conf: documentroot "/home/ben/public_html/django_test/testproject/" wsgiscriptalias / "/home/ben/public_html/django_test/testproject/apache/django.wsgi" apache logs error (standard apache 500 page): importerror: not import settings 'testproject.settings' (is on sys.path? ... i can @ django @ least throw error of it's own using this: import os import sys path = '/home/ben/public_html/django_test/testproject...