Posts

Showing posts from July, 2012

c# - Accessing method arguments in Spring.net AOP advice -

i attempting first implementation of iafterreturningadvice , wondering how access values of method or if possible? makes sense may have use around advice acheive since don't have access imethodinvocation. thanks in advance. just in case reads post later , needs answer. answer args[] array contains arguments passed intercepted method.

Can I draw a straight line in Google Maps? -

is there api can use draw straight line between 2 points in google map, , show line in different colors? example: draw straight line between nyc , los angeles green or red line? yes. have checked out google maps apis ? for example check out source code this example

php - Hiding URL key parameters with .htaccess -

i've been searching on web , haven't yet found solution issue. i'm hoping shed light on situation. i have index file set this: <header></header> <div id="main"> <?php if(isset($_get["p"])) $p = $_get["p"]; else $p = "home"; if(file_exists("pages/{$p}.php")) include("pages/{$p}.php"); ?> </div> which makes me load pages ?p=contact href. say display users profile. i'd create subfolder in "pages" folder, making relative path pages/users/profile.php , href ?p=users/profile&uid=5 . leaves ugly url (as seo rating). how rewrite url /users/profile/5 ? edit: i've tried following, resulting in http 500: rewriterule ^([^/]*)/([^/]*)$ /?p=$1&uid=$2 [l] edit: .htaccess file, located directly inside root folder: http://pastie.org/2268239 line 338 want achieve (currently comment). simplest answer both situations add in

python - How to display images using different color maps in different figures in matplotlib? -

i want display images using different color maps in different figures. following code displays image 2 different windows same color map import scipy.misc pylab import * = scipy.misc.imread('lena.jpg') figure(1) image = mean(a,axis=2) imshow(image) #if call show() here 1 window displayed gray() #change default colormap gray figure(2) imshow(image) show() i wondering if can please me. thanks lot. you can pass cmap argument imshow function. @ http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.imshow

php - Page Not Pulling From Correct Category? -

i need page below pull category. i'm not sure how it...in other words when page pulled pull posts 1 category , category only. not sure add or add it? category "for sale" http://ampmproperties.com/for-lease-orange-county <?php /** * template name: sale * * @package wordpress * @subpackage twenty_ten * @since twenty ten 1.0 */ get_header(); ?> <div id="container"> <div class="left_sirebar"> <?php get_sidebar(); ?> </div> <div id="content" role="main"> <?php $args = array( 'posts_per_page' => 3 ); $loop = new wp_query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); if ($count==1) { echo "<tr>"; } echo '<td><div

Google Visualization API -- Putting Y Axis on Right Side? -

using: http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html#loading there isn't options put y axis on right side of chart? reals?! :p anyone know how such 'radical' thing? charting api lets this, not visualization? thanks so. you can around via series option, , specifying dummy data series series[0]. so: <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['corechart']}); </script> <script type="text/javascript"> function drawvisualization() { var data = new google.visualization.datatable(); data.addcolumn('string', 'xaxis'); data.addcolumn('number', 'dummyseries'); data.addcolumn('number', 'realseries'); data.addrow(['x label

tomcat - How to load a page from a page without modifying the url in JSP? -

i have web application secured login. if user's session has expired how display error page when user attempts load secured page without causing url pathname change? reason why because don't want reveal extensions using. know specify index page directory i'm looking cleaner solution. avoid modifying standard error code pages (ex: 403/404). loads/redirects on page load nice. any appreciated. thanks! if don't want reveal extensions use .htaccess mod-rewrite. you 2 things make sure hide them. first if request comes page . character after first / redirect them same page . , after stripped off. secondly mod rewrite page request https://mydomain.com/mypage gets rewritten server side `https://mydomain.com/mypage.extension

jquery - Multiple $(document).ready functions -

this question has answer here: jquery - multiple $(document).ready …? 5 answers if have multiple $(document).ready(...) functions, overwrite each other? sake of argument, pretend proper coding thrown out door on one. say have $(document).ready(function() {...}); in site's script file. use third party plugin uses $(document).ready(function() {...}); . overwrite created function or jquery "queue" these functions run when document ready? no, not override each other. each function executed. you of course check yourself: http://jsfiddle.net/6jggt/ or understand jquery code itself: line 255 ready function jquery.bindready(); called among other things initialises readylist object on line 429 readylist = jquery._deferred(); and once it's deferred object function passed in appended readylist.done( fn ); , can see in done method on

javascript - How does "respond_with_navigational" work? -

i'm working devise , deviseinvitable manage authentication in app , i'm having trouble adding ajax support invitationscontroller#update. controller in deviseinvitable looks this: # invitations_controller.rb # put /resource/invitation def update self.resource = resource_class.accept_invitation!(params[resource_name]) if resource.errors.empty? set_flash_message :notice, :updated sign_in(resource_name, resource) respond_with resource, :location => after_accept_path_for(resource) else respond_with_navigational(resource){ render_with_scope :edit } end end this works when resource.errors.empty? == true , execute: respond_with resource, :location => after_accept_path_for(resource) (i.e. invitations/update.js.erb rendered , javascript calls made). problem when resource.errors.empty? == false , , execute: respond_with_navigational(resource){ ren

JAVA + create HashMap in place of function -

i write following 2 functions want implement functions hashmap ( in place of functions ) how that? static void somefunction(int count, int[] anarray) { ( int i=0;i<anarray[count];i = + 1) { system.out.print("#"); } system.out.println(""); } static void somefunctionb(int[] anarray , int count, string stringfinal, string sttr) { anarray[count]= stringfinal.replaceall("[^"+sttr+"]", "").length(); } somefunctionb(anarray , count, stringfinal, sttr ); somefunction(count, anarray); without using functions (apart public static void main(string[] args) ), like: map<integer, integer> mapthatpretendstobeanarray = new linkedhashmap<integer, integer>(); mapthatpretendstobeanarray.put(0, 17); mapthatpretendstobeanarray.put(1, 5); mapthatpretendstobeanarray.put(2, 1); mapthatpretendstobeanarray.put(3, 319); //somefunction() (int = 0; < mapthatpretendstobeanarray

php - Does anyone know if xcache functions are atomic? -

i'm wondering xcache functions atomic. know xcache_inc() , xcache_dec() both atomic. dont know if xcache_get() , xcache_unset() atomic. the feature list says xcache supports "atomic get/set/inc/dec". so get atomic, whatever means. (it means get never returns in-between value, more or less same thing atomic set .) also, since set atomic, see no reason why unset wouldn't atomic, too.

nomenclature - OOP theory question :: $this->someVariable = $someValue -

i wondering statement does: $this->nameinobject = $somevalue; so if you're inside class object has variable "nameinobject", assigning value of somevalue instance of nameinobject? intended last long session? on ride initial value of nameinobject? thanks it override previous value. it affect current instance of object.

sql - Superscript greater than three does not work. Only one two and three available -

i'm querying database , trying superscripts. first 3 work fine, others don't though. valid superscript characters on three? 1: nchar(185) 2:nchar(178) 3:nchar(179) 4: nchar(8308) 5:nchar(8309) 6:nchar(8310) 7:nchar(8311) 8:nchar(8312) 9:nchar(8313) simply search web characters named suerscript four, etc. you find pages such this, superscript 4: http://www.fileformat.info/info/unicode/char/2074/index.htm the characters have seem @ correct decimal codepoints; perhaps issue fonts. you'll have find fonts support these characters. also check character encoding of database utf-8 , not, say, latin-1.

Problem in Android Spinner inside the Tabbars -

i making application , facing problem. i using tab bars , in 1 of tab bar using spinner. it loads when click on it. gives me: android.view.windowmanager$badtokenexception: unable add window -- token android.app.localactivitymanager$localactivityrecord@44647ef8 not valid; activity running? this error. i using following code snippet arraylist<string> agelist; spinner age; age = (spinner) findviewbyid(r.id.country); agelist = new arraylist<string>(); agelist.add("10-20"); agelist.add("21-35"); agelist.add("36-60"); agelist.add("61-100"); arrayadapter<string> adapter2 = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, agelist); //array populating adapter2.setdropdownviewresource(android.r.layout.simple_dropdown_item_1line); age.setadapter(adapter2); age.setselection(0, true); t

Queuing HTTP requests in .NET with exponential backoff for Android C2DM - examples? 3rd party libraries? -

i'm writing android app making use of cloud-2-device messaging (c2dm) service provided google , expected, @ selected peak periods of day, sending many thousands of messages in short amount of time. google insists server should queue requests you're planning send server , use 'exponential backoff' failed / delayed requests. just wondering if there examples of kind of setup in .net / c# and/or 3rd party libraries handle queuing , backoff stuff. ok, ended spending time , writing own. i've decided give stackoverflow (which has given me long), here's solution download: http://wemakeapps.net/downloads/c2dm.sender.zip this .net4.0 solution build .exe can run periodically using scheduled task. note prepared add own code, it's commented , i've tried point out need run off own datastore retrieve ids of registered devices , decide need send them. a modified version of solution has been running high-traffic ecommerce site, pushing notification

php - Help me to select a NoSQL Package -

i'm new nosql [have read articles on nosql] , want develop simple application using it. please me select nosql system system should have these features sql select query (select col1, col2 tbl col1>10) sql insert query (it better if has auto increment feature) it should compatible use php look @ mongodb . simple use, fast, reliable , quite powerful. also, there's nice driver php. mongodb "nosql", schema-free , document-oriented. different terminology used, beginner can think has collections instead of tables, documents instead of rows , fields instead of columns. inserting , selecting quite simple: // select documents. $cursor = $db->my_collection->find(array( 'field1' => array('$gt' => 10), // field1 > 10 ), array( 'field1', 'field2', // fields fetch ))->sort(array( 'field3' => -1, // sort descending field3 )); while($document = $cursor->getnext()) { // ... }

android - How to dismiss alertDialog manually? -

i trying fetch data server.if gets failed in middle due reasons, displaying alert prompting user restart download once again. have done is, in alert dialog's ok button have called download method once again. makes alert dialog freeze , stops form hiding. when download completed alert dialog gets dismissed. can suggest idea here. in onclick event dismiss dialog first (dialog.cancel(); or dialog.dismiss() )and call the download function again . use code dialog showdialog(0); protected dialog oncreatedialog(int id) { alertdialog.builder builder = new alertdialog.builder(this); //builder create dialog switch(id) { case 0: if(game_started) { builder.settitle("failed"); builder.setmessage("xxxxx"); //the buttons set dialog box builder.setpositivebutton("yes", new dialoginterface.onclicklistener() { @override public void onclick(

objective c - In iPhone App ,How to add tab bar controller on some particular view controller Programmatically? -

in iphone app ,how add tab bar controller on particular view controller programmatically? here viewcontroller class uitableviewcontroller . right if adding tab bar appears in table view. want display on bottom of window , and tableview should scroll separately tabbarcontroller please , suggest thanks firstview *view1 = [[firstview alloc]init]; secondview *view2 = [[secondview alloc] init]; uinavigationcontroller *firstview = [[uinavigationcontroller alloc] initwithrootviewcontroller:view1]; uinavigationcontroller *secondview = [[uinavigationcontroller alloc] initwithrootviewcontroller:view2]; uitabbarcontroller* tabbar = [[uitabbarcontroller alloc] init]; [tabbar setviewcontrollers:[nsarray arraywithobjects:view1, view2, nil]]; [tabbar setdelegate:self]; uinavigationcontroller* navigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:tabbar]; [self.view addsubview:navigationcontroller.view]; try this.

objective c - Returns NULL value -

i null value when print log sourcedate. give null value. the code is: nsmutablestring * orignalstr = [[nsmutablestring alloc] init]; [orignalstr appendstring:date]; [orignalstr replaceoccurrencesofstring:@"t" withstring:@" " options:nscaseinsensitivesearch range:nsmakerange(0, 15)]; nslog(@"the orignalstring =%@ ",orignalstr); nsdateformatter* dateformatter=[[nsdateformatter alloc]init]; [dateformatter setdateformat:@"yyyy-mm-dd hh:mm:ss zzz "]; nsdate *sourcedate =[dateformatter datefromstring:orignalstr]; nslog(@"the sourcedate =%@ ",sourcedate); plz me... try using date format string : @"yyyy'-'mm'-'dd't'hh':'mm':'ss'z'" , without replacing occurences of @"t" . edit after comment you got string : "2011-07-19 gmt:10:00", format string should @

javascript - How to upload a file in just one click -

i have html page, gives option upload file server, there servlet action class @ server side & handles request , write file. here how works click browse file , select file click submit button. but want upload in 1 click on button, please take of code , suggest how using javascript/jquery fn. <html> <head> <script type = "text/javascript"> function test() { var uploadfile = document.getelementbyid("upload_id"); uploadfile.click(); // here can browse file without clicking on file brows button } </script> </head> <body> <input type="button" id="just_one_click" value ="click me" onclick="test();" /> <form action="upload.do" method="post" enctype="multipart/form-data"> <input type="file" id="upload_id" name = "fileupload" /> <input type = "submit"

android - How can i select whole listitems when clicking either on checkbox or anywhere in the line -

i have listview checkbox,now want check/uncheck listitems clicking anywhere on listitems eithe on checkbox or on image of listitems or anywhere in listitem lines. pease me out?? put onitemclicklistener. listview.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { checkbox cb = (checkbox) view.findviewbyid(r.id.listviewitemcb); cb.setchecked(true); // ... other stuff } });

c# - How to pass long list of parameters to method Or any other best way to achieve this -

i passing 20+ arguments of different types method. there should clean way pass this. can please me. i can pass array of object having these 20+ arguments in target method have put checks on type. way pass long list of arguments. code: sample code not full private datatable createdatatable(string[] args) { datatable dt = new datatable(); dt.clear(); foreach (var arg in args) { dt.columns.add(arg); } return dt; } i can pass array in method because arguments of same type. datatable dt = createdatatable(new string[] { "projectid", "parentprojectid", "projectname", "creationdate"); now here have more 20+ values of diff types following int projectid = 100; int? parentprojectid = somecondition ? 10 : null; string projectname = "good project" datetime createddate = datetime.now; . . . in method assign values columns. as

objective c - What's the easiest way to animate a line? -

i creating app involves animating lines within workspace on time. current approach use code in drawrect : cgcontextsetstrokecolor(context, black); cgcontextbeginpath(context); cgcontextmovetopoint(context, startpoint.x, startpoint.y); cgcontextaddlinetopoint(context, finalpoint.x, finalpoint.y); cgcontextstrokepath(context); ...and setting timer run every 0.05 seconds update finalpoint , call setneedsdisplay . i'm finding approach (when there's 5ish lines moving @ once) slows down app terribly, , such high refresh frequency, still appears jerky. there must better way perform simple line drawing in animated line - i.e. saying want line start @ x1, y1 , stretching x2, y2 on given length of time. options this? need make perform faster , love rid of clunky timer. thanks! use cashapelayers, , combination of catransactions , cabasicanimation. you can add given path shapelayer , let rendering. a cashapelayer object has 2 properties called strokestart , str

git push one branch back to original remote branch -

i pulled remote branch. made changes. want push local changes remote branch (not master) here's commands used pull git remote add my-desktop ssh://mydomiain.com/usr/local/me/myproject git fetch my-desktop git branch some-feature-mylaptop my-desktop/some-feature git checkout some-feature-mylaptop now edit, git commit, , want push changes some-feature-mylaptop my-desktop/some-feature. tried ' git push origin my-desktop ' didn't work. tried ' git push my-desktop some-feature-mylaptop '. made new branch on mydesktop call 'some-feature-mylaptop' git push my-desktop some-feature-mylaptop:some-feature with local-branch:remote-branch syntax saying git should push local-branch on top of remote remote-branch . read here

erlang records trouble -

i'am struggling records in 1 of modules. i defined on top of code record as: -record(user, {pid, name, nick}). in few words each user going represented process own pid , other fields. later on in module doing following: pid = userpid, getuser = fun(x) -> if x#user.pid =:= pid -> true; x#user.pid=/= pid -> false end end, user = lists:filter(getuser, users), io:format("user pid ~p~n",[user#user.pid]). running code get: ** exception error: {badrecord,user} but if do: io:format("user ~p~n",[user]). it prints user [{user,<0.33.0>,name1,nick1}] can point out missing? thanks emil's answer the lists:filter function correct. this how rewrite code, though: -module(com). -record(user, {pid, name, nick}). -export([lookup/1]). lookup(pid) -> users = users(), filte

ruby on rails - Two different databases -

is possible have 2 different databases development or production? 1 heroku , 1 local development? heroku uses postgresql prefer sqllite local development. yes, it's totally possible - can use heroku db:push push local sqlite database postgres running on heroku. but and personal experience, i've run situations sql i've written different between sqlite/postgres/mysql and gems i've used used findbysql weren't tested against postgres , has caught out when i've put on heroku. for few seconds takes install postgres locally recommend use db platform going deploy to.

How is Pythons glob.glob ordered? -

i have written following python code: #!/usr/bin/python # -*- coding: utf-8 -*- import os, glob path = '/home/my/path' infile in glob.glob( os.path.join(path, '*.png') ): print infile now this: /home/my/path/output0352.png /home/my/path/output0005.png /home/my/path/output0137.png /home/my/path/output0202.png /home/my/path/output0023.png /home/my/path/output0048.png /home/my/path/output0069.png /home/my/path/output0246.png /home/my/path/output0071.png /home/my/path/output0402.png /home/my/path/output0230.png /home/my/path/output0182.png /home/my/path/output0121.png /home/my/path/output0104.png /home/my/path/output0219.png /home/my/path/output0226.png /home/my/path/output0215.png /home/my/path/output0266.png /home/my/path/output0347.png /home/my/path/output0295.png /home/my/path/output0131.png /home/my/path/output0208.png /home/my/path/output0194.png in way ordered? it might ls -l output: -rw-r--r-- 1 moose moose 627669 2011-07-17 17:26 output0005.pn

java - PHP Security Flaws? -

our team developing web app in financial space using php. big question comes first security related. main security risks associated php or scripted languages in general verus more accepted (in space) java written app? programming languages not inherently secure or insecure (barring bugs/ exploits). code written them however. provided code securely written php fine.

MS SQL Server use old log file location after detach/copy/attach -

i create database "test" in folder "d:\test". database files "d:\test\test.mdf" , "d:\test\test_log.ldf". detach database ms sql server 2008 r2, copy files new folder ("d:\test_new"), delete log file ("d:\test_new\test_log.ldf"), , try attach database again new location. when use sql server management studio, , choose "d:\test_new\test.mdf" file, determines log file located in "d:\test\test_log.ldf" (old location). how can attach database rebuilding log in new location? imagine, cannot copy ldf file again new location, , still available there, sql server see anyway. want sql server - "please, forget log file, , create new log file here". it's better if me t-sql script, if steps in management studio - convert script myself. what had tried already: 1. create database [test] on ( filename = n'd:\test_new\test.mdf' ) attach_rebuild_log attaches log file old location (for a

GWT Generator not called with GIN Injection -

i have declared generator in gwt module descriptor , seems not called when class trigger generator instanciated via ginjector. public interface myginjector extends ginjector { mywidget getmywidget(); } public class myentrypoint implements entrypoint { public static final myginjector injector = gwt.create(myginjector.class); public void onmoduleload() { mywidget mywidget = injector.getmywidget(); // [1] mywidget mywidget = gwt.create(mywidget.class); // [2] rootpanel.add(mywidget); } } [1] generator not called. [2] generator called. does mean gin injector not instanciate object through gwt.create() method? thanks help. kind regards, afaik, gin (at least until 1.5) generate gwt.create() if class has public zero-arg constructor that not annotated @inject (otherwise it'll new on it)

tsql - SQL NOT IN possibly performance issues -

i attempting refactor several old pieces of code... have refactored current piece below , have highlighted not in statement causing performance issues. attempting rewrite not in section left outer join. can help, or suggest better way if possible? select left(unique_id,16) casino_id , right(unique_id,24) game_id ( select distinct o.casino_id + g.game_id unique_id game g inner join bet b on g.game_id = b.game_id inner join casinouser u on b.user_id = u.user_id inner join onewalletcasino o on u.casino_id = o.casino_id game_start between dateadd(mi, -180, getdate()) , dateadd(mi, -5, getdate()) , b.[status] <> 'p' ) t unique_id not in ( select casino_id + game_id casino_id thirdpartysettlecalled [status] = 'y') order casino_id

encoding - Why don't I see the hebrew characters, when I print text from an utf-8 file in Python? -

i'm trying read hebrew text file: def task1(): f = open('c:\\users\\royi\\desktop\\final project\\corpus-haaretz.txt', 'r',"utf-8") print 'success' return f = task1() when read it shows me this: '[\xee\xe0\xee\xf8 \xee\xf2\xf8\xeb\xfa \xf9\xec \xe4\xf0\xe9\xe5-\xe9\xe5\xf8\xf7 \xe8\xe9\xe9\xee\xf1: \xf2\xec \xe1\xe9\xfa \xe4\xee\xf9\xf4\xe8 \xec\xe1\xe8\xec \xe0\xfa \xe7\xe5\xf7 \xe4\xe7\xf8\xed, \xec\xe8\xe5\xe1\xfa \xe9\xf9\xf8\xe0\xec \xee\xe0\xfa \xf0\xe9\xe5 and many more. how read it? you print this: print task1().encode('your terminal encoding here') you must sure terminal able display hebrew characters. exemple, under full utf-8 linux distrib with hebrew locales installed: print task1().encode('utf-8') careful open : with python 2.7, have no encoding parameter. use codecs module. with python 3+, encoding parameter fourth one, not third do. may mean open(path, 'r',

objective c - spliting random strings in iphone -

i have string random numbers, like "12345678912234" i want split 4 parts, like, string1 = 123 string2 = 456 string3 = 7891 string4 = 2234 anybody has idea?? i've tried using nsrange cannot it. may i'm using wrong. i tried using substringtoindex failed too. please me guys -(nsstring *)splitstring:(nsstring *)string fromx:(int)x toy:(int)y { nsrange range = { x, y}; return [string substringwithrange:range]; } nslog([self splitstring:@"12345678912234" fromx:0 toy:3]); nslog([self splitstring:@"12345678912234" fromx:3 toy:3]); nslog([self splitstring:@"12345678912234" fromx:6 toy:4]); nslog([self splitstring:@"12345678912234" fromx:10 toy:4]); just tested :) works fine. (just clarify: have named function incorrectly not toy how many characters want take in x).

php - open a socket on a shared host -

i'm trying open socket on host using following code: $timeout = 10; $s = stream_socket_client('mywebsite.com:80', $errcode, $errstring, $timeout); $message = "get /index.php http/1.0\r\n\r\n"; fwrite($s, $message); while(!feof($s)){ echo fread($s, 1024); } nothing fancy, example found. problem every time run code different files. think because host shared one. is there way overcome problem, is, pull reliably proper file i'm trying get? thank you. in http request have specify host you're accessing. noted correctly multiple dns entries can point same ip address. $message = "get /index.php http/1.1\r\nhost: hostname.com\r\n\r\n";

database design - n:m with payload in Enitity Framework 4.x -

hi trying desperately create following relation in ef4.x "one material made of many materials amount , each material can used in materials" ideally convert material n:m material content payload, have translated to: "material 1:n materialusage" , "materialusage m:1 material" i have created 2 tables since have payload (certain amount) 'material' , 'materialusage' in material have defined relation 'ismadeof' links 'materialusage.isusedin' , relation 'isusedfor' links 'materialusage.ismadeof' in materialusage have aside of 2 above described filed 'content'. now problem: if delete material run error message saying within association 'materialmaterialusage', identifies relation "material.isusedfor <-> materialusage.ismadeof", relation in status 'deleted' , due multiplicity definition corresponding 'materialusage' record

python - Is there a way to add multiple conditions in a for loop? -

n=int(raw_input('enter number of mcnuggets want buy : ')) #total number of mcnuggets want yo buy in range(1,n) , b in range(1,n) , c in range(1,n) : if (6*a+9*b+20*c==n): print 'number of packs of 6 ',a print 'number of packs of 9 ',b print 'number of packs of 20 are',c i new programming , learning python.the code above gives errors. suggestion.?. you should use nested loops: for in range(1, n): b in range(1, n): c in range(1, n): if ... or better: import itertools a, b, c in itertools.product(range(1, n + 1), repeat=3): if ...

python - How to do simple value check with error message in Deform/Colander -

i'm implementing simple 'tick agree terms , conditions box' in deform/colander. so, want check box checked , have error message saying 'you must agree t&c'. i understand can use: colander.oneof([true]) to ensure box ticked. however, oneof not allow custom error message. correct way be? use custom validator: def t_and_c_validator(node, value): if not value: raise invalid(node, 'you must agree t&c') class myschema(colander.schema): t_and_c = colander.schemanode( colander.boolean(), description='terms , conditions', widget=deform.widget.checkboxwidget(), title='terms , conditions', validator=t_and_c_validator, )

matlab plot different colors -

i have set of points (matrix nx1) , groups points (matrix nx1) . want plot points (there no problem, this: plot(points, groups, 'o'); ), i'd set unique color each group. how can this? have 2 groups (1,2). use logical indexing select points want figure; hold all; % keep old plots , cycle through colors ind = (groups == 1); % select points groups 1 % can kind of logical selections here: % ind = (groups < 5) plot(points(ind), groups(ind), 'o');

c# - Hook on Windows Installer messages -

i wonder if there win32 api regarding user install software on machine ? is there event windows fire when user start install software ? i need write application listen event , cancel operation software. you don't need app disable installs based on msi setups. see disablemsi policy: https://msdn.microsoft.com/en-us/library/windows/desktop/aa369784(v=vs.85).aspx setups built other tools (that build non-msi setups) can't detected because they're applications things system, other application, there isn't way stop them.

c# - Creating a centralized exception logging system -

im planning create centralized log system application. application contains several separate applications work on different client machines. planning start using exception handling block enterprise library. looks create , need creating event logs exceptions. question create these logs 1 place. when client computers in same domain create logs domain controller event logs. have seen articles or have other ideas creating centralized log system? edit: im talking c# , windows os-s. if narrow os'es win7 , win 2008 r2 ... ;-) there built-in functionality of forwarding , collecting events (win7, win2008 r2 , probably: win 2008 r1, vista): http://www.sysadminlab.net/windows/forward-event-log-from-several-server-to-a-central-windows-2008-server there differences win 2008 r1 here (in community comment): http://technet.microsoft.com/en-us/library/cc748890.aspx btw. didn't try in in practice in general see huge improvements in windows 2008 r2 logging, diagnostics , like

javascript - How can I draw an image from the HTML5 File API on Canvas? -

i draw image opened html5 file api on canvas. in handlefiles(e) method, can access file e.target.files[0] can't draw image directly using drawimage . how draw image file api on html5 canvas? here code have used: <!doctype html> <html> <head> <meta charset="utf-8"/> <script> window.onload = function() { var input = document.getelementbyid('input'); input.addeventlistener('change', handlefiles); } function handlefiles(e) { var ctx = document.getelementbyid('canvas').getcontext('2d'); ctx.drawimage(e.target.files[0], 20,20); alert('the image drawn'); } </script> </head> <body> <h1>test</h1> <input type="file" id="input"/> <canvas width="400" height="300" id="canvas"/> </body> </html> you have file instance not image. to contents of file , use filereader . pass

asp.net - How do I load a type from another assembly when in a Web App? -

i have existing code: private function gettypefromname(byval fulltypename string, byval assemblyname string) type dim dirstr = new fileinfo(system.reflection.assembly.getexecutingassembly.location).directoryname dim asm = [assembly].loadfile(dirstr & "\" & assemblyname & ".dll") return asm.gettype(fulltypename) end function the result of call routine type instantiated , used within app. previous use , assumptions this code used in winforms app locate type based on data loaded config file , passed function. generally assembly sought referenced application, not case. as can see, code expects assembly name passed in without ".dll" suffix or path , further assumed resident in same folder executing assembly. these assumptions have been correct until now. everything changes now executing code within web app , seems folder of executing assembly is... c:\windows\microsoft.net\framework\v2.0.5

asp.net - Problem displaying PDF in IE8 via Silverlight application -

i have silverlight 4 application i'm attempting display pdf. approach has been upon button click in silverlight application, use htmlpage.window.navigate open new browser window. url new browser window navigates asp.net web forms page makes call sql reporting services via ssrs soap api. call returns byte array web form streams browser following code: byte[] report = ssrsrenderreport(reportpath, primaryid); response.clearcontent(); response.clearheaders(); response.addheader("cache-control", "must-revalidate"); response.addheader("content-length", report.length.tostring()); response.buffer = true; response.contenttype = "application/pdf"; this.response.addheader("content-disposition", "inline; filename=whatever.pdf"); response.binarywrite(report); response.flush(); response.end(); this works quite when running application ie9

c# - How DragMove works? (Which properties it changes?) -

i making simple window in wpf (like overwolf), in overwolf there circle in top-left of screen , when drag it, moving corner simple animation. tried make same effect using doubleanimation on leftproperty works once ( the first time drag working , the second stay dragged it ). my xaml: <window x:class="overwoof.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" name="main" width="200" height="200" allowstransparency="true" windowstyle='none' ishittestvisible="true" topmost="true" background="transparent" mouseleftbuttonup="ondragleave" windowstartuplocation="manual"> <grid ishittestvisible="true" name="maingrid" minheight="200" minwidth="200"

language agnostic - Machine learning of word structure -

i working on system can create made fanatsy words based on variety of user input, such syllable templates or modified backus naur form. 1 new mode, though, planned machine learning . here, user not explicitly define rules, paste text , system learns structure of given words , creates similar words. my current naïve approach create table of letter neighborhood probabilities (including special end-of-word "letter") , filling scanning input letter pairs (using whitespace , punctuation word boundaries). creating word mean probabilities every letter follow current letter , randomly choose 1 according probabilities, append, , reiterate until end-of-word encountered. but looking more sophisticated approaches (probably?) provide better results. not know machine learning, pointers topics, techniques or algorithms appreciated. i think independent words (an names), simple markov chain system (which seem describe when talking using letter pairs) can perform well. feed

jQuery toggle doesn't work -

i toggle .toggle-item-(number here) .link(number here) . @ beginning .toggle-item s closed. 1 toggle item should shown @ same time. every time new toggle item opens other open toggle item should close. link code here: http://jsfiddle.net/rauqb/ why jquery code not work? updated marc's code closes others when clicking. $(document).ready(function() { $('[class^=toggle-item]').hide(); $('[class^=link]').click(function() { var $this = $(this); var x = $this.attr("class"); var classname = '.toggle-item-' + x.replace('link', ''); $(classname ).toggle(); $('[class^=toggle-item]:not('+classname +')').hide(); return false; }); });

ASP.NET MVC 3 Razor : Initialize a JavaScript array -

what prefered way initialize js array in asp.net mvc 3 razor value have in model/view model ? for example initialize array of strings representing dates : <script type="text/javascript"> var activedates = ["7-21-2011", "7-22-2011"]; </script> with public class myviewmodel { public datetime[] activedates { get; set; } } i don't quite understand relation between js , asp.net mvc 3 razor. javascript runs on client side no matter technology has been used on server generate page. on javascript array array. there couple of possibilities define arrays of objects in javascript var activedates = [ '7-21-2011', '7-22-2011' ]; or: var activedates = new array(); activearrays.push('7-21-2011'); activearrays.push('7-22-2011'); or yet: var activedates = new array(); activearrays[0] = '7-21-2011'; activearrays[1] = '7-22-2011'; at th end represent same array. array

c# - visual studio setup project caching compilation symbols -

i'm have c# visual studio 2010 project uses [conditional("debug")] above of logging code don't want used in release build. when build release configuration in project , step through code, missed expected. my setup project uses output exe file though , when rebuilt msi, debugging code still being printed out. occurred till deleted exe output setup project re-added it. contrary expected wandering if other people have experienced this? try this: #if debug ... #endif

EF 4.1: Error after upgrade when mapping one entity to multiple tables -

after upgrading working project ef 4.0 4.1, receiving following error @ run-time: map called more once type 'everybody' , @ least 1 of calls didn't specify target table name. the code is: public everybodyconfiguration() { map(e => e.properties(p => new { p.everybodyid, p.firstname, p.lastname, p.initials, p.capsid, p.datemodified })).totable("everybody"); map(e => e.properties(p => new { p.everybodyid, p.status })).totable("everybodystatus"); map(e => e.properties(p => new { p.everybodyid, p.email, p.bouncedflag, p.donotcontactflag })).totable("everybodyemail"); } the error message confusing, because indicates table name hasn't been specified somewhere, can see in code has. the tables have same primary key column name. any suggestions? the totable call mapping whole entity (chained behind map , method of entitytypeconfiguration ).

android - SurfaceView horizontal scrolling -

i'm writing application create graph , draw on surfaceview. graph needs able update live want surfaceview scrollable horizontally user can see data. possible? you need place custom view inside horizontal scroll view separeate class. when create instace of custom graph view tell size according width of graph overriding onmeasure method: @override protected void onmeasure(int widthmeasurespec, int heightmeasurespec) { super.onmeasure(widthmeasurespec, heightmeasurespec); this.setmeasureddimension(graphwidth, graphheight); } graphwidth = barlenghtinpixels * barcount + extraspaceinpixels; you can place customview in xml layout using custom tag <com.myapplication.graphview...> or use myscrollview.addview(mycustomview) , add horizontalscrollview , before call setcontentview(mylayout) .

jquery - highlight menu items based on associated content -

i using jquery display content on website based upon menu item selection. each menu item has number attached matches content div container. $(".main-cat").hover(function() { $(this).parent().find("div.arrow-right").remove(); $(this).after('<div class="arrow-down"></div>'); $(this).addclass('selected'); $(this).css('cursor', 'pointer'); }, function() { $(this).removeclass('selected'); $(this).parent().find("div.arrow-down").remove(); }); $("#sidebar div").click(function() { $("#real_0").hide(); $(".content_sub").hide(); var menuclass = $(this).attr('class'); menuclassp = menuclass.split(" "); $("#real_" + menuclassp[1]).fadein('slow'); }); i trying add function highlight menu item corresponds currently * active * content. what's best way write this? , can current

Is it possible to disable the 'shift+space' shortcut in SQL Server Management Studio 2008? -

when editting data in "edit top 200 rows" tab, press 'shift+space' entering capitalized data, kicks me out of edit mode. extremely annoying, , reduces typing speed around ~10% of normal. there way disable shortcut in sql server management studio 2008? nope. bug closed "won't fix" 2 years ago (not enough people cared, guess - 1 person voted aside me): http://connect.microsoft.com/sql/feedback/viewfeedback.aspx?feedbackid=473303 of course suggestion use update statements rather quirky edit top n grid, has several other problems in addition one.

Powershell try/catch/finally -

i wrote powershell script works great - however, i'd upgrade script , add error checking / handling - i've been stumped @ first hurdle seems. why won't following code work? try { remove-item "c:\somenonexistentfolder\file.txt" -erroraction stop } catch [system.management.automation.itemnotfoundexception] { "item not found" } catch { "any other undefined errors" $error[0] } { "finished" } the error caught in second catch block - can see output $error[0] . catch in first block - missing? thanks -erroraction stop changing things you. try adding , see get: catch [system.management.automation.actionpreferencestopexception] { "caught stopexecution exception" $error[0] }

php - AJAX post not working -

i'm using jquery , codeigniter update database via ajax. following code not seem or send controller when button clicked... jquery: $("#button_submit1").click(function(e) { $.ajax({ type: "post", url: window.location.href, datatype: "json", data: $('#writereview_form').serialize() + '&ajax=true', cache: false, success: function(data) { alert("yay"); //$("#writereview_box").fadeout(1000); } }); return false; }); html: <form action="http://mysite.com/places/writereview/2107" id="writereview_form" method="post" accept-charset="utf-8"> ... ... <input type="submit" name="submit" value="submit review" class="button_submit" id="button_submit1"> any ideas why ajax data not being sent?

c# - Windows Phone ControlTemplate & Converter : problem loading BitmapImage from Image Resource in assembly -

this follow previous question. i've managed make work templates, however, want make bit generic, don't have go around repeating code on place the working version (hardcoded) : <usercontrol.resources> <controltemplate x:key="treblecheckboximagetemplate" targettype="checkbox"> <image x:name="imgtreble" minwidth="100" source="images/treble_checked.png"> <visualstatemanager.visualstategroups> <visualstategroup x:name="checkstates"> <visualstate x:name="checked"> <storyboard> <objectanimationusingkeyframes begintime="00:00:00" storyboard.targetname="imgtreble" storyboard.targetproperty="(image.source)"> <discreteobjectkeyframe keytime="