Posts

Showing posts from August, 2013

python - Please suggest how to write a text from webpage text box to clipboard -

i have text box in webpage, text in text box need sent clipboard of ubuntu how do that? i'm using python cgi, please suggest me link or idea proceed. thank :) python , cgi run on server, want copy text webpage client viewing client's clipboard. hence have solution client-side javascript or javascript library jquery. used do-able using jquery clipboard , though security problem rogue flash apps arbitrarily alter users clipboard (causing people paste wrong url, etc). so, flash fixed security hole allowed client scripts alter clipboard whenever script wanted, date versions of flash can't alter clipboard unless user initiating action click inside flash movie. however, http://code.google.com/p/zeroclipboard/ still works (requiring click button before can modify clipboard), can use that. have test pages , wiki of instructions getting text ubuntu (assuming gnome desktop environment) clipboard python script can done with import pygtk import gtk clipbo

android - How can I send fake sms to myself without mobile network usage? -

i want show information sms in application. smsmanager , broadcastreciever can not create sms , notify on phone itself. how can send fake sms myself programmatically? ideas, workarounds or class research... ? thanks. proof of concept call sms list intent intent = new intent("android.intent.action.main"); intent.setcomponent( new componentname("com.android.mms","com.android.mms.ui.conversationlist")); startactivity(intent); read sms cursor c= getcontentresolver().query(uri, null, null ,null,null); startmanagingcursor(c); c.movetofirst(); string body = c.getstring(c.getcolumnindexorthrow("body")).tostring(); string number = c.getstring(c.getcolumnindexorthrow("address")).tostring(); c.close(); toast.maketext(getapplicationcontext(), number, toast.length_long).show(); write sms contentvalues values = new contentvalues();

android - User settings saved in SharedPreferences removed or lost between reloads of app -

my app stores simple settings in sharedpreferences works fine. 1 person who's downloaded app having problems. settings in sharedpreferences getting lost between closing , reloading app. could have permissions problem somewhere on phone that's preventing data being saved between sessions? has experienced or know of reason why happening? i'm having pretty hard time debugging it, don't know start. // i'm using sharedpreferences so: prefs = getsharedpreferences(this.getstring(r.string.prefs_name), 0); sharedpreferences.editor editor = prefs.edit(); editor.putstring("accounts", accounts); editor.commit(); //retrieving stored information like: sharedpreferences prefs = getsharedpreferences(this.getstring(r.string.prefs_name), 0); string accounts = prefs.getstring("accounts","[]"); we experienced same problems our android apps. our userbase pretty big (several million users) , our statistics subjected problems occured 0,2

makefile - What is the preferred way to structure and build OCaml projects? -

it unclear newcomers ecosystem canonically preferred way structure , manage building small medium sized ocaml projects. understand basics of ocamlc , &c.--they mirror conventional unix c compilers enough seem straightforward. but, above level of one-off compilation of individual files, unclear how best manage compilation , cleanly. issue not searching potential tools, seeing 1 or few right (enough) ways--as validated experience of community--for structuring , building standard ocaml projects. my model use case modest nontrivial project, of pure ocaml or ocaml plus c dependency. such project: contains number of source files links number of standard libraries links 1 or more 3rd party libraries optionally includes c library , ocaml wrapper subproject (though managed separately , included 3rd party library, in (3)) several alternative tools stand out: custom makefiles seem common standard in open source ocaml packages, appear frustratingly verbose , complex--even mor

`svn merge` produces different results than `svn diff` -

so used think halfway decent svn, particular problem thwarting me... i've got topic branch i've added files , made 1 minor modification. merged changes trunk occurred time topic branch cut until head via: svn merge ^/trunk@revn ^/trunk@head branch working copy. i commit changes branch , different between branch , trunk looks kind of this: > svn diff ^/trunk ^/branches/kulrice-5050 --summarize d https://test.kuali.org/svn/rice/trunk/impl/src/main/groovy/org/kuali/rice/kim/impl/attribute/kimattributedatabo.groovy m https://test.kuali.org/svn/rice/trunk/kim/kim-impl/src/test/groovy/org/kuali/rice/kim/impl/role/rolepermissionbotest.groovy https://test.kuali.org/svn/rice/trunk/kim/kim-impl/src/test/groovy/org/kuali/rice/kim/impl/role/roleresponsibilityactionbotest.groovy https://test.kuali.org/svn/rice/trunk/kim/kim-impl/src/test/groovy/org/kuali/rice/kim/impl/role/rolebotest.groovy ... in other words, nothing didn't expect. these file

asp.net mvc 3 - Using DropCreateDatabaseIfModelChanges in a production environment -

i've started learning .net mvc may silly question, i've yet find answer. i'm following code first approach using entity framework build database me. i've included following in application_start() method in order allow me edit database making changes model objects. database.setinitializer<contactmanagerdb>(new dropcreatedatabaseifmodelchanges<contactmanagerdb>()); i wondering happen if pushed application production environment , made few changes models , updated application? drop , recreate database in production environment? what's best practice pushing changes production env. using code first approach? dropcreatedatabaseifmodelchanges should use on in development, never on production machine. if pushed production machine , made schema changes, you'd loose data.

php - Access array elements from API -

for life of me can not figure out how access values of array. every example stdclass object has type of value. if try example $obj->0->0->city; error. can show me example how access [city] => toronto or [date_created] => 2011-05-03 14:33:58 ? i tried no luck. $object = $buy[1]; $title = $object->title[0]; echo "$title"; thanks this api gives me. stdclass object ( [id] => 1 [name] => toronto [date_modified] => 2011-03-08 13:07:10 [tax_rate_provincial] => ) <br/> array ( [0] => stdclass object ( [0] => stdclass object ( [id] => 28131844 [full_date] => 20110506 [end_date] => 20110511 [city] => toronto [saved] => 1651 [discount_percentage] => 52 [deal_option] => array (

ruby on rails - Optimal Way to Browse Gem Source Code -

i find browsing source code of open source libraries being used in projects invaluable. unfortunately, find difficult when developing ruby on rails. accustomed working inside ide's allow me jump definitions of symbols, regardless of whether part of external library. i use aptana studio 3 on mac os x develop, willing change ides feature. i have explored https://github.com/fnando/gem-open option, have yet find editor integrate with. can recommend one? else have method browsing sources of gems? aptana studio 3 has command line launcher: studio3. add following ~/.bash_profile : export path="/applications/aptana studio 3:$path" export gem_editor="studio3" reload existing shell environment: . ~/.bash_profile , can use gem-open preferred editor: gem open rails

python - Why I can't convert a list of str to a list of floats? -

i'm starting write code, fails @ beginning. this code: import csv reader = csv.reader(open("qstartrefseqhg19.head"), dialect='excel-tab' ) row in reader: c = row[1].split(",")[1:] c1 = [float(i) in c] print c1 and error log says: traceback (most recent call last): file "/home/geparada/workspace/sjtag/src/taggen.py", line 8, in <module> c1 = [float(i) in c] valueerror: empty string float() i've tried import csv reader = csv.reader(open("qstartrefseqhg19.head"), dialect='excel-tab' ) row in reader: c = row[1].split(",")[1:] c1 = map(float, c) print c1 my input file looks this: nm_032291 0,227,291,316,388,445,500,676,688,700,725,777,863,956,1031,1532,1660,1787,1847,1959,2115,2248,2451,2516,2681, tttctctcagcatcttcttggtagcctgcctgtaggtgaagaagcaccagcagcatccatggcctgtcttttggcttaacacttatctcctttggctttgacagcggacggaatagacctcagcagcggcgtggtgaggactta

Why does the following string to number conversion fail in Matlab? -

i'm trying break date , add single number day, month , year date = input('please enter date (dd/mm/yyyy):','s') tokens = regexp(sprintf(date),'/','split') daymonthyear = str2num(tokens) test = daymonthyear + 1 as error message indicates, str2num expects strings, not cell array of strings. there 2 ways solve issue. either, can use str2double , or cellfun combined str2num . solution 1 daymonthyear = str2double(tokens) solution 2 daymonthyear = cellfun(@str2num,tokens)

C++ creating a change console colors function -

cout << "picks colors..." << endl << "0 = black\t 1 = blue\t 2 = pea green\t 3 = teal\t 4 = red" << endl; cout << "5 = purple\t 6 = green/brown\t 7 = light grey\t 8 = gark grey" << endl; cout << "9 = lisghter brighter blue\t = lime green\t b = light blue/aqua-ish\t c = red/orange" << endl; cout << "d = pink/rose\t e = yellow" << endl; char bg; char fg; cout << "pick foreground:\t"; cin >> fg; cout << "pick background:\t"; cin >> bg; string colors; colors = "0x",bg,fg; setconsoletextattribute( hstdout, colors ); this function allow user input change console colors. know fact works windows, i'm not sure on linux machine. unfortunately don't know how compose string colors including characters in string goes console attribute function. using method error... error: cannot convert 'std::string' 'wor

logging - Show git logs for range of commits on remote server? -

i looking way query git server logs given range of commits. being svn user, i'm in wrong mindset im hoping git experts can help. i'm looking similar to: svn log -r 5:20 --xml svn.myserver.com but git server. in other words, show me logs 5th commit through 20th commit. help. first, since there no simple revision number git, specify revision mentioned in rev-parse command . but command queries directly remote repo (without cloning or fetching data) git ls-remote , and: it display sha1, not log message. it works on ref patterns (head, tags, branches, ...), not revs. since log can show diffstats , full diffs, cannot ask logs without @ least fetching remote in local repo.

How to call file dialog box in access form application -

i using access 2000 write form application. i need open file dialog box select file , extract file path. the solution should compatible version of access 97 , above, , should not require module pre-installed in user's computer. no third party library, native call windows api. p.s. need detail steps shows me add code. for these kind of access faqs, should try access web starting point searching (though search interface sucks -- it's easier search site google). site official faq site number of non-ms access newsgroups. doesn't updated often, code still quite useful, precisely because answers questions asked frequently. the code need in 1 of api modules, helpfully titled call standard windows file open/save dialog box

C++ stl vector for classes with private copy constructor? -

there class in our code, class c . want create vector of objects of class c . however, both copy constructor , assignment operator purposely declared private . don't want (and perhaps not allowed) change that. is there other clean way use/define vector<c> ? you use vector<c*> or vector<shared_ptr<c>> instead.

private field setter in scala -

what best way have class field in scala read-only outside of class? realize can this: private var myvalx = 0 // default val def myval = myvalx def myval_=(x: int) { myvalx = x } but find extremely ugly due _= operator , fact need define separate var name different methods. alternatives welcome. thank you! i don't think it's practice have private fields , public ones share same name. example, wrote private var myvalx = 0 // default val def myval = myvalx def myval_=(x: int) { myvalx = x } which doesn't make myval read-only @ all! meant like private def myval_=(x: int) { myvalx = x } which read-only. perfect example of why it's bad idea--you asking confusion between public interface , private implementation details. other problems can arise users not realizing value might change out under them, subclasses redefining public getter without realizing private setter not available, , on. if don't try share name, it's clearer there 2 thin

Twitter Search Trouble -

hi guys i'm trying use http://search.twitter.com/search.json pull feeds of users. seems work can't seem pull justinbieber's twitter feed keep getting empty results i can pull wilw no prob http://twitter.com/#!/wilw http://search.twitter.com/search.json?q=from:wilw {"results":[{"from_user_id_str":"20300","profile_image_url":"http://a0.twimg.com/profile_images/421184034/qc_avatar_flip_normal.png","created_at":"wed, 11 may 2011 03:23:19 +0000","from_user":"wilw","id_str":"68154189968191488","metadata":{"result_type":"recent"},"to_user_id":null,"text":"that joke isn't funny anymore #valleysmiths (thank indulgence, , apologies. here endeth flood.)","id":68154189968191488,"from_user_id":20300,"geo":null,"iso_language_code":"en","to_user_id_str&q

MySQL data in javascript using PHP's foreach loop (Googlel Maps API) -

i'm trying use google maps v3 api create markers on google map. have coordinates of markers in mysql database, , in php array in .php file. how use foreach() loop (or suitable method) loop through elements in php array , create new google map marker each iteration of loop? ps: php decent, not javscript knowledge. tutorial i'm following on creating markers @ http://www.svennerberg.com/2009/07/google-maps-api-3-markers/ code i'm using codeigniter framework, controller+model file retrieved necessary data(name, lng, lat...) array $map. can loop array using usual method: foreach($map $row) { $lng = $row[lng] // not necessary, show in array $lat = $row[lat] // how use loop create new marker code in javascript? } the js code creating google map marker has created once per foreach loop iteration like: var map = new google.maps.map(document.getelementbyid('map'), { zoom: 7, center: new google.maps.latlng($lng, $lat), // how pass php vari

functional programming - Multiple arguments to mapcar -

i'm sure beginner question in lisp, learning language. i have function in clisp called count. counts number of times given atom appears in list. i'd able call count multiple times different parameters, same list search. for example, i'd count number of 'a , 'b , , 'c in list, hypothetically. hoping this: (mapcar 'count '(a b c) mylist) i've figured out doesn't work because each of elements in '(a b c) being paired 1 of elements in mylist. appropriate idiomatic way apply function additional input parameter each item in list? to further clarify, i'd able take '(a b c) , '(a b c c c) input , produce (2 1 3) . to call function count repeatedly each item list (a b c) , every time counting matching items same sequence mylist : (mapcar (lambda (x) (count x mylist)) '(a b c))

Cursor error with postgresql, pgpool and php -

hey, struggling bit determine exact cause of error has been popping in our release environment. there not seem dealing particular error on google. this error message getting: sqlstate[34000]: invalid cursor name: 7 error: portal "" not exist the error pops when using pdo prepared statements. this setup our release environment: pgpool 3.0.1 (the postgresql backend in streaming replication mode!) php 5.3.5 postgresql 9.0 edit: architecture 64bit. the same error not manifest in our test environment (edit: forgot mention, standard test environment uses postgresql 9.0 without pgpool). thus, led suspect pgpool @ least partly suspect. does know probable causes error are? edit: ok, here example of kind of code causes error. $sql = 'select * '; $sql .= 'from "mytable" "mystuff" '; $sql .= 'where "mytable"."status" = 1 '; $sql .= 'and "mytable"."mytableid" = :table

c++ - CDatabase Leak even after calling Close -

my application leaks while executing following code piece. memory not released after calling close() on cdatabase . how can correct leak without destroying cdatabase object? cdatabase db; int count = 2000; (int i=0; <count; ++i) { bool bres = db.openex("dsn=icedbserver;uid=sa;pwd=iceconnect200"); db.close(); } the call stack of leak location given below + 133154 ( 133154 - 0) 2001 allocs backtrace477 + 2001 ( 2001 - 0) backtrace477 allocations ntdll!rtlallocateheap+00001292 ntdll!ldrpcopyunicodestring+000000b1 ntdll!ldrpresolvedllname+000002ce ntdll!ldrpmapdll+000002c1 ntdll!ldrploaddll+00000251 ntdll!ldrloaddll+000001c8 kernel32!loadlibraryexw+0000024d odbc32!loaddriver+00000235 odbc32!sqldriverconnectw+00000c11 odbc32!sqldriverconnect+000001bb mfc90!cdatabase::connect+0000009e (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dbcore.cpp, 745) mfc90!cdatabase::openex+00000089 (f:\dd\v

array algorithms - calcuating the sum of nodes in a single verticle line of a binary tree -

for binary tree want sum of nodes fall in single verticle line.i want sum of nodes in each verticle node / \ b c / \ / \ d e f g / \ h if @ above tee line 0 e f sum = a+e+f line -1 b sum = b +i line 1 c sum = c line 2 g sum = g i implemented following algorithm map<integer,integere> mp = new hashmap<integer,integer>() calculate(root,0); void calculate(node node, int pos){ if(node==null) return ; if(mp.containskey(pos) ){ int val = mp.get(pos) + node.data; mp.put(pos,val); } else{ mp.put(pos,node.data); } calculate(node.left,pos-1); calculate(node.right,pos+1); } i think above algo fine.can 1 confirm? also how can without using hashmap,arraylist or such collection datatype of java.one method 2 two arrays 1 storing negative indexes(mapped positive) , 1 positive indexs(right side of root

actionscript 3 - Does FlashPlayer 10 support MP4 and AAC audio codecs in addition to MP3? -

i developing audio player application in adobe air flex sdk 3.2. wanted know if can play songs in other audio formats? i think flash player can play aac not aac+. radio stations using aac+ because updated aac. let me know if correct

c++ - Why the CString(LPCTSTR lpsz) constrcutor check the high two bytes of lpsz? -

i reading source code of cstring in mfc . curious implementation way of constructor cstring::cstring(lpctstr lpsz) . in understanding, before copying string indicated lpsz , needs check whether lpsz null no need combine checking if hiword(lpsz) null . is mfc guy passing here , willing give explanations? cstring::cstring(lpctstr lpsz) { init(); if (lpsz != null && hiword(lpsz) == null) { uint nid = loword((dword)lpsz); if (!loadstring(nid)) trace1("warning: implicit loadstring(%u) failed\n", nid); } else { int nlen = safestrlen(lpsz); if (nlen != 0) { allocbuffer(nlen); memcpy(m_pchdata, lpsz, nlen*sizeof(tchar)); } } } it checks whether passed actual pointer or integer resource identifier makeintresource . in latter case loads string resources.

Rails: Keeping a partial DRY when using locals -

i have partial being reused couple controllers. right have partial set accept 2 objects don't want do. -if @article .main-inner .article-header .article-title =@article.title -if !@article.byline.blank? %span#byline =@article.byline %span#timestamp =@article.publish_date.strftime("%a, %b %d, %y %i:%m %z") .article-content =truncate(@article.content, :length => 600).html_safe -else .main-inner .article-header .article-title =article.title -if !article.byline.blank? %span#byline =article.byline %span#timestamp =article.publish_date.strftime("%a, %b %d, %y %i:%m %z") .article-content =truncate(article.content, :length => 600).html_safe when @article def show @article = article.find_by_permalink(params[:permalink]) end when through locals $("#article").html("<%= escape_javascript render(:par

iis - configuring HTTPS enabled WCF with SSL that has a CN of *.domain.com -

i'm trying configure ssl enabled wcf web service thats deployed in iis 6. the cn of ssl *.domain.com , setting in web.config throws exception cannot locate cn of this. <servercertificate findvalue="cn = *.domain.com"/> any idea how fix this?

github - How to clean up obsolete rewritten commits in git after a git-filter-branch -

i needed remove couple of obsolete files git history, followed approach of using "git filter-branch ..." suggested in various questions , in git manual. after running command, see rewritten commits in "git log", instead of original 10 commits, have around 30 commits (after removing 3 files). i tried suggestions provided in various answers remove ".git/refs/originals" , "git reflog expire..." , "git gc --aggressive --prune" etc. still have 30 commits. tried suggestion of cloning repository new one, , new 1 has 30 commits well. pushed github , has 30 commits. is there missing rid of overwritten commits (without doing rebase operation). goal rid of "duplicate" commits, not squash commits. thanks! exactly commands did run? it's best make fresh clone of repo , try again. there guide on help.github might help.

c# - How do i limit the number of characters a user can type in a textbox? -

i want limit number of characters user can type in textbox (say no more 100 characters). how can achieve that? you can use maxlength property. this results in html this: <input type="text" name="name" maxlength="100" /> however, it's worth mentioning validated on client-side , easy bypass. should validate on server-side, checking length of textbox.text property.

jquery - downloading thru ajax and iframe? -

i have small piece if code: $.post('exporttoexcel.php', function(data) { var iframe = document.createelement("iframe"); iframe.src = ""+data; iframe.style.display = "none"; document.body.appendchild(iframe); }); but nothing happens, i'm trying download file seamless server thru jquery's ajax. anyone got fix? if trying direct user file, download should use regular link or use location.href = 'my_url'; send browser there directly. alternatively, if want 'seamless' way, don't use ajax post. link directly exporttoexcel.php in iframe . if exporttoexcel.php requires use of post, make iframe visible , when exporttoexcel.php called via get , provide 'download' button same size iframe and, when clicked, submits regular html form same url via post.

jquery - Incrementing a VTL variable in javascript function -

<script> var count_security = 0; #set($count_security = 0) function increment() { count_security++; #set($count_security = $count_security + 1) alert(count_security); alert($count_security); } </script> <html> <input type="button" onclick="increment" /> </html> when call above function on click of button " $count_security " variable incrementing once.its not incrementing further. please if doing wrong. raghav this because of have 2 contexts consider the rendering context (velocity/vtl) the execution context (browser/client) so when renders have 1 execution in velocity engine execute velocity logic increments $count_security. rendered literal value output. the var count_security javascript client variable can altered , updated client. your velocity #set() code not rendered output "set". #set vtl function , not alter out

iphone - Set Title for ABPeoplePickerNavigationController -

i wondering if knows way change title of navigation bar abpeoplepickernavigationcontroller. not want use uilabel in customizing title in navigationbar abpeoplepickernavigationcontroller just want know if there legal way guarantees app not being rejected. in viewdidload put line: [picker.topviewcontroller settitle:@"contacts"]; where picker type (abpeoplepickernavigationcontroller *)

How do I gracefully quit out the Sass interactive shell (on Windows) -

i launched sass interactive shell, described @ http://sass-lang.com/docs/yardoc/file.sass_reference.html#interactive_shell i can't (gracefully) quit. i've tried: quit exit ^c ^. ^d ^q anyone know how this? ^d should it. os using?

How can I compress ALL my JavaScript files server-side with Apache? -

hey guys, after running google page speed, compression results red. google page speed said files — js, css, etc. — should compressed gzip. i added following line .htaccess file. <ifmodule mod_deflate.c> addoutputfilterbytype deflate text/html text/css text/plain text/javascript text/xml application/xhtml+xml application/x-httpd-php </ifmodule> now compression results slighly better - yellow! page speed keeps saying should compress all javascript libs , plugins. reduce them 65% gzip. shouldn't js files compressed when have text/javascript set deflate ? apache uses mime type application/x-javascript, this howto explains how set it. basically says need use: <location /> addoutputfilterbytype deflate application/x-javascript </location> on side note, might consider using minifier/compressor yui compressor or specific compressor integrates software.

java - Is it a good idea to place JS, CSS and images resources in a JAR for a JSF application? -

i ask question, related another question asked times ago (without answer unfortunately :( ) imagine project divided several web-apps. have many shared resources (js, css, images). idea avoid duplications in each web-app, forced synchronize changes among web-applications. so seems better have these resources on single place. if have on richfaces project, resources managed jsf. example, <rich:calendar> component displays little icon. if html code image, see src attribute refers jsf link, not .png directly: <img src="/richfaces-demo/a4j/g/3_3_3.finalorg.richfaces.renderkit.html.iconimages.calendaricon/datb/eah7cw0fw6znaa8xba4_.jsf" style="vertical-align: middle" id="j_id354:j_id355popupbutton" class="rich-calendar-button " alt=""> i see following advantages of such approach: include resources in classical library (i.e. in jar), eases deployment on eclipse; allow generate dynamic file (i.e. css or js c

c - Writing to file descriptor -

in following snippet redirecting output of ls command input of wc -l works .now want redirect output of ls command file named "beejoutput.txt" using following code not working. need help. #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { int pfds[2]; pipe(pfds); if (!fork()) { dup2(pfds[1],1); close(pfds[0]); execlp("ls", "ls",null); } else { file *outputo=fopen ("beejoutput.txt", "w"); //opening file writing dup2(pfds[0],0); dup2(fileno(outputo),pfds[0]); close(pfds[1]); execlp("wc", "wc","-l", null); } return 0; } the dup function duplicates file descriptor, is, both old , new file descriptors refer same open file afterwards. different having single file descriptor refer 2 different files @ same time. if want send same data 2 different destinations, need spawn both commands in separate p

Question on Memory Issues in Android -

will there memory issue if use lot of frame frame animation in android that depends entirely upon how implement it, , details such how large frames , kind of color-depth choose use. in general, however, should able come rendering algorithm doesn't hold references more handful of frames @ 1 point in time. ideally should need reference previous frame , working buffer current frame. assuming that's case, , assuming you're using 8-bit rgba pixel encoding, can work out how approximately memory animation consume when running. it's: frame.width * frame.height * 4 * 2 bytes and can make reasonable estimate of whether or not device can meet memory requirements. general rule, long frames not larger device resolution should okay.

Java Picture Processing Framework -

1) load picture byte array. 2) verify it's current picture size. 3) resize picture according needs. is there out of box java framework can me it? thanks in advance. actually, java's default packages should enough: to load image use javax.imageio. imageio .read(...) to it's size use getwidth() , getheight() of returned bufferedimage object to resize image, can: create new image (bufferedimage), acquire it's grahpics objects, set transformation, , draw original image. refer java working images tutorial

c# - How to find all controls in Gridview? -

i have gridview contains controls checkbox dropdownlist textbox etc.. these controls in templatefield , in updatepanel in gridview. there edittemplatefield has controls , button . when grid in edit mode, have find controls in edittemplatefield in button click event . know can done using foreach loop don't know how? you can use grid editindex find row contains controls in edit mode. there can control using control id. textbox txtitem = (textbox)grid1.rows[grid1.editindex].findcontrol("txtitem"); to find controls try this: foreach(control c in grid1.rows[grid1.editindex].controls) { // stuff in here. } if have container controls in row, , need find things inside of them, need do recurse down controls. i don't understand though why need loop though controls, controls in edit template fixed, , know accessing them directly findcontrol way go.

c# - Whats the best practice for returning a Boolean and string value -

i've created method performs validations against xml hierarchy dynamically generated class in javascript text during run time. my method returns either true or false, helpful using class i'd return more informative information since there may several reasons can throw false message. at first thought change return type bool generic collection type having string key , boolean value don't know if best approach. what best practice in case? make class public class validationresponse { public bool successful { get; set; } public string information { get; set; } } and return object of validationresponse

iphone - Slideshow of Images -

i developing application of simple slideshow. description : in application i've 5 images stored in array.currently i'm displaying images scroll view want show slideshow of images stored in array. how can ? tutorials ? regards i'd suggest using nstimer, here's basic code. "page" number has calculated somewhere, according how you'd handle edge cases, example: last image in slide show. have @ apple's example app pagecontrol , shows nice way how handle memory efficiently in paging scrollview. self.slidetimer = [nstimer scheduledtimerwithtimeinterval:3.0 target:self selector:@selector(slide) userinfo:nil repeats:yes]; ... - (void)slide { cgrect frame = scrollview.frame; frame.origin.x = frame.size.width * nextimagepagenumber;

ruby on rails 3 - Log In - if Admin direct to Admin Index 1st -

i have 'user' log-ins set , working. change when admin or moderator logs in - directed /admin/index page 1st can preview new posts? would add 'home' link 'users' sit neatly beside 'sign in' , 'sign up' links, not sure how in code block? any code solutions appreciated... views/layouts/application.html.erb <div id="user_nav"> <% if user_signed_in? %> signed in <%= current_user.email %>. not you? <%= link_to "sign out", destroy_user_session_path %> <% else %> <%= link_to "sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %> <% end %> </div> you can add home link before or after if/else/end block: <div id="user_nav"> <%= link_to "home", root_path %> <% if user_signed_in? %> signed in <%= current_user

ruby on rails - single table inheritance with embeds_one mogoid -

i have model class post include mongoid::document include mongoid::timestamps embeds_one :comment end and have comment class class comment include mongoid::document include mongoid::timestamps embedded_in :post field :title field :description end and have class inherited comment class recentcomment < comment # methods end now want able create recentcomment through post if post.last.build_comment(:_type => "recentcomment") new comment not of _type:"recentcomment" , , if post.last.build_recent_comment , gives me error saying sth undefined method build_recent_comment post class . if post had references_many :comments should have done post.last.build_comments({}, recentcomment) without problems. don't know how build object recentcomment class in case. if that'd gr8! note: using gem 'mongoid', '~> 2.0.1' maybe try class post include mongoid::document include mongoid::timestamps

.net - Delphi send null string to webservice -

i'm using webservice delphi application, but, in webservice, parameter's value null. here web service code in .net [webmethod] int execsql(string asql) { } in delphi use : delphi method using web service have used i don't know wrong ? delphi application or .net webservice ? add service unit: invregistry.registerinvokeoptions(typeinfo(xxx), iodocument); read here: https://www.bobswart.nl/weblog/blog.aspx?rootid=5:798

Which objects are atomic in Mathematica? -

i looking full list of atomic objects in mathematica (for atomq yields true ). i know about symbol string integer real rational complex sparsearray booleanfunction graph are there others? ref: http://reference.wolfram.com/mathematica/tutorial/basicobjects.html edit: continually adding new symbols answers list above. it appears list needs 1 more object complete: in[520]:= f = booleanfunction[30, 3]; in[521]:= atomq[f] out[521]= true

ARM v7 BKPT instruction doesn't work correctly on Linux 2.6.35 -

i have problem connected bkpt instruction on arm v7 on linux 2.6.35. main reason address of fault instruction (bkpt) not correct , not correspond arm v7 manual. here steps reproducing: redefine os sigbus handler sigbus handler: void initsigbushandler() { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_flags = sa_siginfo; sigfillset(&sa.sa_mask); sa.sa_sigaction = sigbushandler; sigaction(sigbus, &sa, null); } use inline _asm , put "bkpt" instruction code in main() function: int main(int argc, char **argv) { initsigbushandler(); __asm ( "bkpt\n\t" ); return 0; } here sigbus handler: void sigbushandler( int signum, siginfo_t *pact, void *poldact ) { write(2, (const char *)msg_sigbus_in_handler, strlen((const char *)msg_sigbus_in_handler) ); uint32_t faultaddr = (ui

c# - Facebook allow access url and redirect for login -

hi, how can programatically login facebook. have application - need url optaing facebook login page. after have getresponse()? why? have in order obtain token , have correct allow in order login? you should use existing library facebook c# sdk (preferred) or official facebook developer toolkit . official toolkit isn't updated should use c# sdk more active. don't try code scratch. asking tons of problems if do. edit since wasn't totally clear, i'll these frameworks handle handshakes, tokens, building api requests , listening response automatically. don't try handle yourself. else did hard work.

ASP.NET menu control -

i want expand menu names end of blue border, on pict. http://img.villagephotos.com/p/2005-10/1086302/menu.jpg , should in css ? try positioning , width. css div.menu ul li a, div.menu ul li a:visited { background-color: #465c71; border: 1px #4e667d solid; color: #dde4ec; display:table; line-height: 1.35em; padding: 4px 20px; text-decoration: none; white-space: nowrap; width: 80%; position: relative; } < asp:menu id="navigationmenu" font-bold="true" runat="server" cssclass="menu" enableviewstate="false" includestyleblock="false" orientation="horizontal"> < items> < asp:menuitem navigateurl="~/default.aspx" text="home"/> < asp:menuitem text="projects" value="projects" navigateurl="~/projects.aspx"> < asp:menuitem text="seed" val

silverlight textbox with equal space between leters -

Image
i'm developing application bank, , need textbox entering money, my idea create textbox has background image of grid, , set text size such there character in each box. writing iiiii(5 characters) long wwww (4 characters). can set font or character spacing such hat ensure characters writen in textbox appear in separate boxes. ps: there other similar boxes name, don't inpu digits. you use monospace (fixed width) font, courier example. or create custom control textbox each character, in case have implement big chunk of custom logic.

flex - Navigation within ItemRenderer -

how can navigate within itemrenderer? for example, in views use view.navigator (viewnavigator) push , pop views, there no such feature in itemrenderer. navigation within view (easy) <s:view> <s:hgroup > <s:button label="questionnaire" click="navigator.pushview(view.questionnairecategory1view)"/> </s:hgroup> navigation within item renderer (impossible?) <?xml version="1.0" encoding="utf-8"?> <s:itemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" autodrawbackground="true" height="56"> <s:hgroup> <s:button text="button" click="?????????"/> </s:hgroup> </s:itemrenderer> you want use bubbling events catch when user interacts item renderer. <s:itemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009"

symfony1 - Symfony form widget custom rendering -

i looking way automate form output json format instead of html. using jquery dform http://plugins.jquery.com/project/dform create dynamic forms. sample output: { "type" : "p", "html" : "you must login" }, { "name" : "username", "id" : "txt-username", "caption" : "username", "type" : "text", "placeholder" : "e.g. user@example.com" }, { "name" : "password", "caption" : "password", "type" : "password" }, { "type" : "submit", "value" : "login" } please help create renderjson method , attach basef

java - Regx to delete a given pattern in string -

in xml have tags <string1 : string2> and many more this. i need write regular expression delete string end ":" , i.e. here string1 , ":" also. , should inside < > e.g. input = <string1 : string2> output = <string2> this how in php: <?php $str = "<string1 : string2>"; $s = preg_replace('~(</?)[^>:]*:\s*~', "$1", $str); var_dump($s); ?> edit in java string str = "<ns2:senderid xmlns=\"netapp.com/fsocanonical\">netapp</ns2:senderid>"; system.out.println(str.replaceall("(</?)[^>:]*:\\s*", "$1")); output <senderid xmlns="netapp.com/fsocanonical">netapp</senderid>

methods - Global PHP functions chaining through a Class -

is possible chain php functions through object/class? i have on mind , imagine this: $c = new chainer(); $c->strtolower('stackoverflow')->ucwords(/* value first function argument */)->str_replace('st', 'b', /* value first function argument */); this should produce: backoverflow thanks. do mean str_replace('st', 'b', ucwords(strtolower('stackoverflow'))) ? the methods calling above functions, not methods tied class. chainer have implement these methods. if want (perhaps different purpose , example) implementation of chainer might this: class chainer { private $string; public function strtolower($string) { $this->string = strtolower($string); return $this; } public function ucwords() { $this->string = ucwords($this->string); return $this; } public function str_replace($from, $to) { $this->string = str_replace($from, $to, $this->string);

scala lift json: pattern match on unknown data? -

i have strange json cannot change, , wish parse using jsonparsen in lift. a typical json like: {"name":"xxx", "data":{ "data_123456":{"id":"hello"}, "data_789901":{"id":"hello"}, "data_987654":{"id":"hello"}, }} the issue keys data unknown (data_xxxxx, xx:s not known). bad json, have live it. how supposed setup case-classes in scala able build proper structure when keys here unknown, structure known? you can use map, , every value can jvalue too, representing unparsed json. example: case class id(id: string) case class data(name: jvalue, data: map[string, id]) and then: json.extract[data] res0: data(jstring(xxx),map(data_123456 -> id(hello), data_789901 -> id(hello), data_987654 -> id(hello)))

asp.net mvc - Populating Iframe with PDF - Using MVC [IE Issue] -

currently, have issue populating iframe have pdf document, issue occurs in ie. basic layout: i have screen contains list of items (attachments), can images, text or pdf. when user clicks on 1 of these items - make call controller action [viewattachment] return requested item , display in iframe. this works data types exception of pdfs in ie. (firefox, chrome etc. display pdf in iframe without issue.) i using adobe reader 9, , upgraded 10 in hopes of solving issue. i'll attach code see if has suggestions how possibly resolve this. code populate iframe: (moved 2 lines readability) $(".viewattachment").live('click',function () { $("iframe#test").attr("src","<%=url.action("viewattachment","images") %>? attachment=" + $(this).next().val()); }); viewattachment controller action: public actionresult viewattachment(string attachmentguid) { attachment attachment= imageagent.getattach

javascript - using html() to get changed content -

i have div need grab html contents of (so naturally use html())... however, text fields. whenever grab contents of div (that contains text fields), grabs initial html , not data changed end user... here js bin version..change input field, run function , see take initial value of field... any way around this? http://jsbin.com/oleni3/edit http://jsbin.com/oleni3/5/edit try out ^ the code: $(document).ready(function() { $('div#top input').change(function() { $(this).attr('value', $(this).val()); }); $('#click').click(function() { var _curhtml = $("div#top").html(); $("div#bottom").html(_curhtml); }); });

javascript - setting the height of the parent according to the highest child element, jquery -

i have layout, contains a <div class="line" id="#"> <div class="summary"> text </div> <div class="summary"> </div> <div class="summary"> long text </div> </div> i want, using jquery, expand height of <div class="line"> according highest child element, tried fiddling with: $(".line").attr("id", function() while ($(this).next().length > 0) { ac = $(this).children(".summary").outerheight(); = $(this).children(".summary").next().outerheight(); if (a > ac) { = ac; } } $(this).css("height", + "px"); }); and no success, selectors need use, , how go achieving this? if indeed summary divs columns in 3 column layout applying float:left on them, wrap container nicely around 3 adding div , style clear:both so html this: <div class="line" id="#"> <div class="

Java.util.Date: try to undestand UTC and ET more -

i live in north carolina,btw, on east side. compile , run code , print out same thing. documentation java.util.date try reflect utc time. date utctime = new date(); date esttime = new date(utctime.gettime() + timezone.gettimezone("et").getrawoffset()); dateformat format = new simpledateformat("dd/mm/yy h:mm a"); system.out.println("utc: " + format.format(utctime)); system.out.println("et: " + format.format(esttime)); and get utc: 11/05/11 11:14 et: 11/05/11 11:14 but if go website try reflect different time, utc , et different. did wrong here that's because getrawoffset() returning 0 - me "et" well, , in fact timezone.gettimezone("et") returns gmt. suspect that's not meant. the best olson time zone name north carolina "america/new_york", believe. note shouldn't add raw offset of time zone utc time - should set time zone of formatter instead. date value doesn't know time

facebook - Alternate way to popup FB login in iPhone? -

is there other way check username , password of fb iphone out using fbdialog? using webservice (to send username , password fb server , auth_token , session_key) sri for security/phishing reasons, collecting user's password directly violation of facebook terms of service. required use facebook's dialogs this.

testing - How to test efficiently the acidity of transactions (Java/Spring/EJB or others) -

just wonder. in applications, atomicity , consistency reallly important guess should tested... as i'm java developer i'll talk know. using spring or ejb3 transaction management annotations. when doing refactoring in business layer of application, have rework transation propagation amon other things, , can introduce regressions. i wonder if there easy ways test transaction management of our application. exemple, imagine work @ paypal. want sure customer paypal account credited, , customer charged on bank account. exception should not permit credit paypal account without charging client. are there tools test such things? have done such thing? or how do? i guess done "home made" using bit of aop , designing methods easier test... it's possible inject exceptions in tests bytecode tools byteman: http://java.dzone.com/articles/fault-injection-unit-tests once raise exception can check if db state has been inconsistently updated or been rollb