Posts

Showing posts from June, 2010

is there hash code / Heap address for primitive types in Java? -

i trying find approximization address on heap , , guys gave me function system.identityhashcode(object) . the problem - function doesn't fit primitive types. i'll explain why. i'm given input java compiled program - class file. goal plot graphs contain information variable access between time. have no idea of how code looks in advance , , tactic instrumentation of own bytecode every load , store instruction. i'm using asm java bytecode instrumentation. therefore, can't like: identityhashcode(integer.valueof(...)) because have no indication whether type int, double, long, etc. i want able determine between different instances of same class: for example : class foo { int a; } foo b; foo c; b.a++; c.a++; but when comes bytecode , there no relation between name "b" / "c" , attribute a. "see" is incremented. both regarded ! if object a have used system.identityhashcode() distinguish between them. can't. to make ...

asp.net mvc - How to strongly type a view with 2 classes? -

is possible type view 2 tables? mean if want display view contains data coming 2 tables , how stongly type view data comes 2 tables? you can't directly can create viewmodel class 2 properties on hold references table. type view against viewmodel class. viewmodel: public class viewmodeltables { public mytable customer {get; set;} public myothertable myothertable {get; set;} } view: <%@ control language="c#" inherits="system.web.mvc.viewusercontrol<viewmodeltables>" %> <% foreach(var tab1item in model.customer) { %> // render here ever want render <%: html.textboxfor(name => tab1item.name) %> <% } %> <% foreach(var tab2item in model.myothertable) { %> // render here ever want render <% } %> controller: public actionresult mydoubletables() { var my2tab = new viewmodeltables(); var tab1 = gettable1(); // whatever need var tab2 = gettable2(); // whatever need ...

php - How to Post facebook wall automatically with Facebook API (only with userid) -

using fconnect user have authenticated , have saved userid database. when try publish wall redirecting facebook login page . if user haven't logged in. $status = $facebook->api('/my_user_id/feed', 'post', array('message' => 'this post came app.')); help me web app posting status wall without havn't logged facebook. please me fix it:) below code helps permissions user , access user's information: $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=". $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=publish_stream,user_about_me,read_friendlists,offline_access,publish_actions,friends_photos,,user_photos". "&state=" . $_session['state']; echo("<script> window.location.href='" . $dialog_url . "'</script>");

mysql - SQL syntax for ORDER BY random sublevel? -

i need dumbest of questions. want make query ordered 1 field, named 'client_level'. table has 400 rows, , client_level possible values null, 1,2,3,4 , 5. those client levels. want order clients client_level. clients leveled 5 should go before clients level 4 , on.. easy. select * client order client_level desc; the problem is.... want randomize each sub-group of clients make order inside client level different each time, , therefore, equilibrated on time , query not work think should. select * client order client_level, rand() desc; i sure there must way, thank answers. kind regards, i think misplaced desc. try: select * client order client_level desc, rand();

android - RemoteViews id in loops? -

i've pretty given on dynamic remoteviews, still have 20 remoteviews 3-4 method calls on each in onupdate method. problem is, can have iterator on remoteviews subview id loop? edit ok, here's code, tried using bookmarkcounter iterator since r class generates r.id. widget * * incrementing number (by one). doesn't work. @override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { cursor cursor; string sort_by_column = constants.sort_by_column; string sort_order = constants.sort_order; int bookmarkidcounter = r.id.widget_bookmark_1; bitmap bitmap; hashmap<integer, string> urls = new hashmap<integer, string>(); componentname thiswidget = new componentname(context, widgetprovider.class); remoteviews updateviews = new remoteviews( context.getpackagename(), r.layout.widget_main); remoteviews bookmarks = new remoteviews( context.getpackagename()...

zend framework - Customize zend_form Captcha output? -

i'm using captcha in zend_form. $captcha_element = new zend_form_element_captcha( 'captcha', array('label' => 'write chars field', 'captcha' => array( 'captcha' => 'image', 'wordlen' => 6, 'timeout' => 300, 'font' => doc_root . '/data/fonts/vera.ttf', 'imgdir' => $imagedir, 'imgurl' => $umageurl ) ) ); this generates: <dt id="captcha-input-label"> <label for="captcha-input" class="required">write chars field</label> </dt> <dd id="captcha-element"> <img width="200" height="50" alt="" src="http://sitename.com/captcha/09dd951939c6cdf7fa28f2b7d322ea95.png"> <input type="hidden" name="captcha[id]" value="09...

c# - A TableRow referenced trought a DataRelation always returns null -

Image
using dataset designer in visual studio 2010, i've added tables mysql db. vs10 automatically picks , adds relations between tables, e.g., relation "fk_organisatie_adres" between tables "organisatie" , "adres": in c# code, property automatically generated "resolves" relationship: row of organisatie has property .adresrow (i assume through detected relation "fk_organisatie_adres") problem: when running code, "theaddress" (hence .adresrow property) null! also "theorganisationrow.getchildrows("fk_organisatie_adres")" return null. , "organisationdt.childrelations" empty. what doing wrong? need before can use automatically generate .adresrow property?

detach .exe from perl main script -

i stuck here..:( trying execute temp.exe file perl script. i tried using following: 1) $pid= open( cmd, "| exp.exe > c:\exp_out.txt" ); print cmd "arg1\n"; print cmd "arg2\n"; print cmd "arg3\n"; now exp.exe keeps running in background without problem. if want close , start again starts exp.exe not provide input arguments exp.exe closing: system("taskkill /f /t /pid $pid");` now part of 2 sub routines open , close... i tried open2;win32::process; open2 stuck @ exp.exe , win32::process dont know how pass multiple arguments. try passing arguments in command line. printing cmd typing text after open pipe. if want, program exp.exe needs expect input stdin $pid = open(cmd, "| exp.exe arg1 arg2 arg3 > file.txt"); #do work here close(cmd)

how to redirect the browser during an ajax call (made using jQuery) in php -

i facing problem of redirecting site while in ajax call.. here wanna : make ajax call server. it goes process, if error occurs, should send error page, else resume. now problem when in server side, if use : header('location: error.php'); it doesnt redirect page, infact brings data of page (the whole html) javascript success function. the problem have made generic library both on javascript side (to call ajax) , on server side. i need redirect page through server side. tried adding js code for window.location='error.php'; but didnt success why not return error ajax query can understand instead? if ($error) { header("http/1.1 500 internal server error"); echo "a database error has occurred. etc.etc."; die(); } this trigger ajax request's error callback (if in jquery). echoed text in response body. you can more fitting status code depending on situation.

javascript - Jquery returns a list using id selector -

i'm having trouble jquery , selectors using following code: <div id="test"></div> console.log($('#test')); this returns list [<div id=​"test">​</div>​] instead of single element. this results on having write $('#test')[0] every operations instead of $('#test') . idea on why? regards jquery not return htmlelement, returns jquery object. a jquery object contains collection of document object model (dom) elements have been created html string or selected document. since jquery methods use css selectors match elements document, set of elements in jquery object called set of "matched elements" or "selected elements" the jquery object behaves array; has length property , elements in object can accessed numeric indices [0] [length-1]. note jquery object not javascript array object, not have methods of true array object such join(). h...

unix - "find command -mtime 0" not getting the file i expect -

i trying find file 0 days old. below steps performed test this $ ls $ ls -ltr total 0 $ touch tmp.txt $ ls -ltr total 0 -rw-r----- 1 tstuser tstuser 0 feb 28 20:02 tmp.txt $ find * -mtime 0 $ $ find * -mtime -1 tmp.txt $ why '-mtime 0' not getting me file? what exact difference between '-mtime 0' , '-mtime -1'? im sure there must other ways find files 0 days old in unix, im curious in understanding how '-mtime' works. -mtime n file's data last modified n*24 hours ago. see comments -atime understand how rounding affects interpretation of file modification times. so, -mtime 0 equal to: "file's data last modified 0 hours ago. while -mtime 1 be: "file's data last modified 24 hours ago" edit: numeric arguments can specified +n greater n, -n less n, n n. so guess -1 modified within last 24 hours, while 1 1 day.

Regex to validate password strength -

my password strength criteria below : 8 characters length 2 letters in upper case 1 special character (!@#$&*) 2 numerals (0-9) 3 letters in lower case can please give me regex same. conditions must met password . you can these checks using positive ahead assertions: ^(?=.*[a-z].*[a-z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$ rubular link explanation: ^ start anchor (?=.*[a-z].*[a-z]) ensure string has 2 uppercase letters. (?=.*[!@#$&*]) ensure string has 1 special case letter. (?=.*[0-9].*[0-9]) ensure string has 2 digits. (?=.*[a-z].*[a-z].*[a-z]) ensure string has 3 lowercase letters. .{8} ensure string of length 8. $ end anchor.

silverlight 4.0 - How to navigate from one ViewModel to another in Caliburn.Micro? -

i want navigate login screen dashboard in silverlight oob app. i started using caliburn.micro i'm having doubts seeing can use conductor . or missing something? note : changed constructor conductor intended. not proofreading questions. there several ways display login screen, nicest initiate shellviewmodel . so, shellviewmodel have dependency on loginviewmodel , inject abstraction ( iloginviewmodel ), or better still use abstract factory instead, , inject shellviewmodel constructor. either way, once have instance of loginviewmodel in shellviewmodel , can display either modal dialog box (in case use caliburn.micro windowmanager.showdialog method - inject dependency iwindowmanager abstraction), or display login view part of shell views main content area, in case shellviewmodel conductor, , activate instance of loginviewmodel activateitem method. once have received input loginviewmodel , either modal dialog or conducted view, can display dashboardviewmo...

iphone - Automated checking of non-dealloc'd properties in Objective-C -

is there automated way check properties defined in class not deallocated in dealloc method can built unit tests? hoping automate memory management testing, seems biggest fault when coding in objective-c iphone. i'm not sure if you've tried or not there 'build , analyze' option in build menu pretty job of this. use @property's everywhere , seemed pick of mine correctly. i encountered option accidental click , found valuable!

ruby on rails - Replacing :id from routes without breaking the convention -

i replaced :id on resource routes in rails 3 hash generated. i'm annoyed fact i'm writing less conventional code (e.g. link_to edit_user_path(@user) written link_to '/users/#{@user.user_hash}'). i'm wondering, therea smarter way this? class user < activerecord::base def to_param user_hash end end and edit_user_path(@user) work you

implode explode in php -

this code- $row=mysql_fetch_array($sql1); echo $days= $row['attending_days']; echo $days1 = explode($days','); echo count($days1); it show me 1 value use this while($row=mysql_fetch_array($sql1)){ $days= $row['attending_days']; $days1 = explode(',' , trim($days)); echo count($days1); } why using echo lines?

.net - Error while using AjaxToolkit in visual studio 2005 -

now below error while building , running website uses calender control provided in ajax-toolkit microsoft. microsoft jscript runtime error: asp.net ajax client-side framework failed load. i created website in vs 2005, .net2.0. <asp:toolkitscriptmanager id="toolkitscriptmanager1" runat="server"> </asp:toolkitscriptmanager> <asp:calendarextender id="calendarextender1" runat="server" targetcontrolid="textbox1"> </asp:calendarextender> <asp:textbox id="textbox1" runat="server"></asp:textbox> now tried using older versions of ajax toolkitv1.0.61025. requires have system.web.extentions ddl v 1.0.61025, server has v3.5. have tried replacing dll old one(i might wrong in doing this) said loaded ajaxtoolkit not have contols. so i'm kinda stuck here. ideas? try download , install asp.net 2.0 ajax extensions visual studio 2005: download details: asp.net ajax ...

semantics - HTML/jQuery: Semantically tagging glossary-enabled terms in body copy -

all, i'm working on adding glossary existing site. i'm planning set individual .html fragments individual definitions, use jquery tooltip plugin attached individual terms in copy pull .html fragment , render it. this avoids having pre-load many definitions each page's html (i don't have server-side dynamic language @ disposal - long story - best way i've thought of this). my initial thought use <dt> tags around terms have definitions, , have jquery attach tooltip each term. markup remain clean , simple: <p>lorem ipsum dolor <dt>amet</dt></p> this nice because not using dt/dl/dd tags anywhere else on site, nor plan to. is reasonable solution? or incorrect use <dt> when not inside <dl> ? that acceptable solution, although not technically valid html have, said, dt inside dl. if need valid html, use dfn tag.

django - a good step by step example on how to save images -

can provide step step example on how save images in django? goes in models.py, views.py, forms.py, template etc.? thank you! these 2 should help: dynamic upload of paths in django - lets client specify upload image how upload images in django

How to create a SQLite Database in Android using the API -

i unable create new database using api sqlitedatabase.openorcreate(string path,cursorfactory factory); when using api, it's throwing exception unable open database file please me how fix exception. suppose want create table "settings" table , "mydb.db". use class create db , tables public class mydbconnector extends sqliteopenhelper { private static final string tag = "mydbconnector"; public mydbconnector(context context) { super(context, "mydb.db", null, 3); } @override public void oncreate(sqlitedatabase db) { db.execsql("create table " + constants.table_settings + " (" + constants.table_settings_field_key + " text primary key, " + constants.table_settings_field_value + " text);" ); } } and read/write in db use, sqlitedatabase db = new mydbconnector(this).getreadabledatabase(); //to read tabl...

c# - sql server creation of logins and users by another user -

i using sql server express 2005. have single database mydb i have created login l-1 user u-1 on databas mydb. to connect database mydb found 3 ways: -1(a)-after creating l-1 login default database = mydb , have create user u-1 , , when connected sql server , connected. i used query: create login l-1 password='passl1' , default_database = mydb use mydb create user u-1 login l-1 means, creating user inside login , gives user connect permission implicitly. right ? -1(b)-i didn't create user u-1, executed : use mydb sp_grantdbaccess l-1 this made me connect , reason being that, sql added user named l-1 implicitly in mydb database. right? -1(c)-this time also, didn't create user u-1,but executed this: sp_changedbowner l-1 this made me connect , reason being that, sql added user named l-1 implicitly in mydb database. right? now, want give user u-1 created in 1(a) following permissions: create logins l-2,l-3 create users u2,u3 can co...

html - Image in list item effects position of other text in other list items -

i have unnumbered list trying format menu. <ul> <li><img src="greatimage.png"></li> <li>item 2</li> <li>item 3</li> </ul> i trying have list items content vertically centered each other. when add image first list item looks though other list items position pushed bottom border of ul block? image effecting rest of list items position. one thing set line-height of li equal of image's height example: http://jsfiddle.net/felcom/vdptj/

c# - Canceling a task -

i have task need cancel if wait time over. instance var t = task.factory.startnew(() => { thread.sleep(5000) // long running task "do something" }); task.waitall(new[] {t}, 1000); but seems task still keeps working. tried using cancellationtokensource didnt seem work well. i confirmed using following snippet static void main(string[] args) { var cancellationtokensource = new cancellationtokensource(); var t = task.factory.startnew(() => { thread.sleep(5000); console.writeline("still working"); }, cancellationtokensource.token); task.waitall(new[] {t}, 1000); cancellationtokensource.cancel(); console.readline(); } console displays "still working". thought task have been cancelled. i sure missing something. missing? thanks. cancellation tokens don't magically cancel anything. allow check cancella...

visual studio 2005 - What could be causing this memory access error (C++)? Might be undefined behavior? -

i have relatively large class i'm working , it's worked fine far (note: didn't write class, i'm adding functionality). however, after declaring 1 more string in header file, crashes (i memory access error). if erase string , rebuild, works fine. i'm not doing string....just act of declaring causing weird memory error. i can't explain in more detail this, since waste try explain every function. kind of things should here find problem? might cause weird behavior? the error is: unhandled exception @ 0x65fd17fd (msvcp80d.dll) in myfile.exe: 0xc0000005: access violation writing location 0xcdcdcdcd. basically changed in .h file was: stringtype string1; turned into: stringtype string1; stringtype string2; stringtype extension of basic_string you've allocated memory on heap , failed initialize it. 0xcd fill pattern used debug heap: before dynamically allocated memory given program, filled pattern find uninitialized var...

c++ - How to change QGLFormat for an existing QGLWidget at runtime? -

in application, user may change properties of opengl format (i.e. double buffering, multisampling, depth of various buffers, ...). for now, there 1 qglwidget in application, , if user changes anything, destroy , recreate widget. now, have more 1 widget. if format change, need destroy/recreate widgets. widget can assume various configurations, destroying/recreating them difficult. there way change format of qglwidget @ runtime? alternatively, there way replace widget one? (i.e. destroy widget , place new 1 use stand) this may work: qglformat newformat; newformat.setdoublebuffer(true); // ... theglwidget->context().setformat(newformat); edit: can call qglwidget::setformat directly, it's obsolete , may not work . think it's safer recreate widget. here's how: put gl widget in sublayout (any kind - e.g. qvboxlayout) contains nothing gl widget. when want replace new gl widget, delete old one, , insert new widget in sublayout.

cakephp - PHP unique array function for nested array -

is there way use array_unique function working nested array below? want rid of date duplicates , 2 dates out array... array ( [0] => array ( [value] => 1311044688 [name] => 19th jul 2011 ) [1] => array ( [value] => 1311044919 [name] => 19th jul 2011 ) [2] => array ( [value] => 1311045076 [name] => 19th jul 2011 ) [3] => array ( [value] => 1311164873 [name] => 20th jul 2011 ) [4] => array ( [value] => 1311165000 [name] => 20th jul 2011 ) ) i'd write array array using date keys, , "values" value. that's fastest way achieve you're looking for. something like: $uniqueary = array() foreach ($ary $item) { $uniqueary[$item['name']] = $item['value']; } you'd want ...

java - Struts2 regex validation issue with negative numbers -

all, i'm attempting write should simple validation struts2 action. have field must contain 0 or positive integer, i'm attempting use struts2 built in regex validator accomplish this. regex i'm using '^\d*$', , i've tested outside of struts2 , believe should meet needs. (e.g. matches against '23', not 'abc' or '-5'). however, when use regex pattern in struts2, fails give me validation error negative numbers. here's struts2 validation xml snippet: <field name="editvo.capability.operationalqty"> <field-validator type="regex"> <param name="expression"><![cdata[^\d*$]]></param> <message key="errors.number"/> </field-validator> </field> here of results i'm seeing when unit testing validation: input validation passes? expected result? 23 yes yes abc no ...

asp classic - How Many Bytes Sent From SQL Server To Client -

we troubleshooting ancient application written in classic asp accesses sql server 2005 database. intranet application only. the asp page set paginate through 200,000+ records, 10/20 or 30 records @ time. we're planning move app more current language, etc. in mean time, we've been asked determine how many bytes have been transfered client. the sql query such: db_server = "<server name>" db_name = "<database name>" db_username = "<user name>" db_userpassword = "<password>" connectstr = "driver={sql server};server=" & db_server & ";database=" & db_name & ";uid=" & db_username & ";pwd=" & db_userpassword objcn .cursorlocation = aduseclient .connectiontimeout = 15 .commandtimeout = 30 .connectionstring = connectstr .open end objrs .activeconnection = objcn .cursorlocation = aduseclient .cursortype = adop...

Strange asp.net mvc error -

using asp.net mvc3 rtm, iis7. i'm getting flooded errors one: system.web.httpexception public action method 'application' not found on controller 'interreg.web.controllers.applicationscontroller'. system.web.httpexception (0x80004005): public action method 'application' not found on controller 'interreg.web.controllers.applicationscontroller'. @ system.web.mvc.controller.handleunknownaction(string actionname) @ system.web.mvc.controller.executecore() @ system.web.mvc.controllerbase.execute(requestcontext requestcontext) @ system.web.mvc.controllerbase.system.web.mvc.icontroller.execute(requestcontext requestcontext) @ system.web.mvc.mvchandler.<>c_ displayclass6.<>c _displayclassb.b_ 5() @ system.web.mvc.async.asyncresultwrapper.<>c _displayclass1.b_ 0() @ system.web.mvc.async.asyncresultwrapper> c _displayclass8'1.beginsynchronous>b__7(iasyncresult ) @ sys...

c# - Check All checkbox in datagrid-row when a checkbox is checked within same row -

i developing webpage changing rights(add/view/delete/edit/all) subadministrator modules in project.say, there 5 modules. have loaded current rights in datagrid each module(in datagrid there 5 rows(modules) , module 5 columns of rights in checkbox). need functionality like, when check 'all' checkbox, (module), other checkbox add,view,edit,delete should checked , when uncheck 'all' checkbox, other checkbox should unchecked. solution accepted javascript or event. tried checkedchanged event, checkes/unchecks checkboxes of entire datagrid instead module(row). in checkedchanged event wrote code.. foreach (datagriditem dgitem in dg_rights.items) { checkbox chkall = (checkbox)dgitem.findcontrol("chk_all"); checkbox chkadd = (checkbox)dgitem.findcontrol("chk_add"); checkbox chkedit = (checkbox)dgitem.findcontrol("chk_edit"); checkbox chkview = (checkbox)dgitem.findcont...

Python String replace based on chars NOT in RegEx -

is possible create reqex finds characters not specific set? rather blacklisting bunch of characters , replacing them, easier me allow set , replace characters not in set. my set looks this: [.a-za-z0-9] i this: clean_filename = re.sub(r'([.a-za-z0-9])', "_", filename) obviously code replace characters want keep, there way replace characters not in set? yes, use ^ negation "modifier": r'[^.a-za-z0-9]'

c# - EF4 and MVC3 mapping ViewModels to Entities -

i have ef4 entity workgroup. below meta-data model reference. [metadatatype(typeof(workgroupmetadata))] public partial class workgroup { public contact manager { get; set; } } [bind(exclude = "id")] public class workgroupmetadata { [scaffoldcolumn(false)] public int id { get; set; } [displayname("org. number")] [required(errormessage = "org. number required.")] public string org_number { get; set; } [displayname("workgroup name")] [required(errormessage = "workgroup name required.")] public string name { get; set; } [displayname("customer contact")] public int customer_contact_id { get; set; } [displayname("manager")] public int manager_id { get; set; } [displayname("tech. lead")] public int lead_id { get; set; } [displayname("time approver")] public int time_approver { get; set; } [displayname("descript...

facebook - What are the benefits of using FBJS vs. an iFrame with jQuery -

i looking turning javascript app (using jquery) facebook widget, , wondering benefit of using fbjs on iframe app's current javascript code & libraries... can facebook app developers out there comment on this? facebook moving away fbml/fbjs , encouraging developers use iframes pages , applications: https://developers.facebook.com/blog/post/402/ https://developers.facebook.com/blog/post/462/

c++ - Using log4cxx with Visual Studio 2010. Application initialization error -

i have succeeded build log4cxx library both in debug , release mode , created log4cxxd.lib , log4cxx.lib files. when try use them static linking in visual c++ 2010 project the application failed initialize (0xc0150002). in debug mode. in release mode works fine. debug configuration, i've added log4cxxd.lib additional dependency , release configuration i've added log4cxx.lib . think should work in debug mode, not. any ideas? use dependency walker on application determine library missing.

apache - How do I redirect a URL that isn't found without sending a 404 header? -

my website needs .htaccess file redirect user index.php when page not found. however, not want apache send 404 header document. i asked question earlier: apache .htaccess 404 error redirect the command "errordocument /index.php" produces exact effect want, except sends 404 header page. can do? should overwrite 404 header php? add .htaccess file: rewriteengine on rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] rewriterule ^.*$ index.php [nc,l] enable rewrite check if requested file exists regualar file size (not empty) check if requested file link check if requested file directory if 1 of previous 3 statements true show file otherwise go index.php if redirect index.php happens u can requested uri using $_server["request_uri"] inside index.php '-d' (is directory) treats teststring pathname , tests if exists , directory. ...

Mixed Mode on Windows CE / Compact Framework -

is there way create mixed mode application/dll windows ce (version 6.0), installed compact framework (version >2.0)? source code written in c++. succeded in building pure .net applications based on c#. when using visual studio (2005) , adding /clr command line receive warning "cl : command line warning d9002 : ignoring unknown option '/clr'" thanks every hint in advance no, there isn't. major problem compiler compact framework supports c# , vb.net. compiling other language can result in il contains opcodes compact framework doesn't support . there a bug in cf regarding strong name validation prevents working. if you'd read else's efforts @ getting mixed mode working, sqlite, take at thread .

Adding the "button down" effect on keydown with JQuery? -

how can add "button down" effect when button selected , key pressed? behaviour of actual press works, it's no effect ever shown. to more specific: have set of buttons can traversed through using left , right arrow keys. , when enter pressed, selected button carry-out it's onclick behaviour. thanks! here fiddle example: http://jsfiddle.net/maniator/dblem/ var index = 0; var buttons = $('button'); var max = buttons.length - 1; var buttonon = buttons.eq(index).addclass('on'); $(document).keydown(function(e) { switch (e.keycode) { case 39: { index++; if (index > max) { index = 0; } break; } case 37: { index--; if (index < 0) { index = max; } break; } case 13: { buttonon.trigger('click'); } } buttonon = buttons.eq...

javascript - retaining combo box selected values..? -

how retain combo box value, mean ever value have selected should retain value after refresh or submit.. you can try passing value through parameter , re loading through that, or if you're looking permanent way use cookies save value

actionscript 3 - removeChild in Flash AS3 -

i want clear xml object loaded on stage when click tuebutton monbutton.addeventlistener(mouseevent.click, monhandler); function monhandler(evt:mouseevent):void { trace(evt.type); // set "y" location on stage first box live var yplacement:int = 110; // set "x" location on stage boxes line vertically var xplacement:int = 30; // set distance each box should apart here var distance:int = 25; // initialize xml, place xml file name, initialize urlrequest // put urlrequest new urlloader, , add event listener on // myloader listening when xml loading complete var myxml:xml = new xml(); var xml_url:string = "menu.xml"; var myxmlurl:urlrequest = new urlrequest(xml_url); var myloader:urlloader = new urlloader(myxmlurl); myloader.addeventlistener("complete", xmlloaded); // create xmlloaded function function xmlloaded(event:event):void { // place xml data myxml object ...

Coldfusion Beta 2 CFC Mapping -

i working new cfbuilder 2 beta, , notice there new feature supposed able check cfc's , give me "intellisense" on them keep receiving , error says unresolved component. i have mappings set in cf administrator , added server in cfbuilder , able see dsn's in rds dataview, not appear if pulling in mappings example. var dates = createobject("component","com.utils.datefunctions"); the com mapped c:\inetpub\com in admin mappings, again warning when createobject. is there perhaps step missed inside of cfbuilder work? i thinking should pulling in mappings already... try link coldfusion builder team, explaining cfbuilder , finding cfcs. http://blogs.adobe.com/cfbuilder/2011/03/where-coldfusion-builder-finds-my-cfcs.html

Dynamic insert into variable table statement SQL Server -

i have variable table: declare @a_table table(id int, att1 varchar(100), att2 nvarchar(200)) i want make dynamic sql, insert table data (all inside loop): while (@i <= 100) begin select @other_att = name @other_table id = @i; set @sql = 'insert ' + @a_table+ '(id,att1,att2) select '+cast(@i varchar)+' , '''+ @other_att+''', sum('+ @other_att') '+ @even_other_table; exec (@sql); end sql every time like: insert @a_table select 1 , 'subject', sum(subject) insert @a_table select 2 , 'age', sum(age) insert @a_table select 3 , 'sex', sum(sex).... and after executing : get: @a_table: id att1 att2 1 subject 4.3 2 age 4.5 3 sex 4.1 but error: msg 137, level 16, state 1, line 48 must declare scalar variable "@a_table". so syntax insert dynamically variable table? ok have understood it. you have table variable, not variable ...

python - numpy structured arrays: help understanding output -

i trying learn how use numpy's structured arrays. specifically, trying add information more 1 field @ time. tried: import numpy np numrec = np.zeros(8, dtype=[('col0', 'int16'), ('col1', 'int16'), ('col2', 'int16'), ('col3', 'int16')]) numrec[['col1','col2']][0:2] = [(3,5), (1,8)] print numrec the above not work. values not added columns specified. surprising do not error when run it. can please explain happening? thanks. you setting values on temporary. numrec[["col1", "col2"]] returns copy of array. can see owndata flag. >>> numrec[["col1", "col2"]].flags["owndata"] true when index numpy array list, numpy returns copy of data. has copy, because, in general, list may not resolve regular, ordered view of underlying data. (this holds numpy array, not structured arrays.) compare >...

iphone - How to implement two separate UIScrollViews with nested UIImageViews...only one is zooming -

ok, have been working on solving problem day, , getting close. trying have create way view more 1 scrollview/imageview nested pair allows zooming on image. when view loads, there 1 scrollview takes whole screen, when button pressed, cut width of first scrollview in half, , unhide (which has nested imageview in well) right next it. there split view effect, , ideally user able pinch , zoom each image separately. so have working except separate pinch , zoom part. no matter pinch on screen, first scrollview zooms. though touching scrollview, still affecting first. i have them setup in ib, , setup in viewdidload way: [scrollview setbackgroundcolor:[uicolor blackcolor]]; [scrollview setcancancelcontenttouches:no]; scrollview.clipstobounds = yes; // default no, want restrict drawing within our scrollview scrollview.indicatorstyle = uiscrollviewindicatorstylewhite; scrollview.minimumzoomscale = 1; scrollview.maximumzoomscale = 5; scrollview.delegate = self; [scrollview setscrol...

asp.net mvc 2 with dynamically generated views -

i trying build asp.net mvc 2 app data entry. want generate views on forms dynamically using htmlhelpers . flexible option datasource ? when change database dont have change code @ all(so guess ef not option)? no model/controller changes etc. or don't have choice changing models in code? well change database, assume mean change dbms, sql server oracle example. i doubt you'll find solution without code changes @ all, can make things lot simpler using interfaces services. for example public interface idatarepository { ... } public class sqlserverdatarepository : idatarepository { ... } and testing public class mockrepository : idatarepository { ... } and later if swith databases public class oraclerepository : idatarepository { ... } this used simple referring interfaces public class myservice { public myservice(irepository repo) { //ctor { } and ideally injecting objects inversion of cont...

Rails - How to Convert HTML to TEXT -

i'm looking way convert html text. tried using sanatize strip out html tags fails html has tags like: <pre>adasdadadad</pre> which text output sanatize removes tag , text lost. ideas? i think looking strip_tags . that links says deprecated this says works rails 3. or paul correctly points out might try updated api .

Android onClick event fails -

i'm having problem here android + java + cloud. onclick event working 1 time the event work again when go last screen , enter again in screen made searchs in cloud... i think allowed call setcontentview() once. since doing in click listener might why failing after first time. edit: when fails? force close? nothing? unexpected?

multithreading - iphone ios thread issue: delegate object not responding when using dispatch_async -

here's code: maindelegate.m - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { fetchmanager *fetchmanager = [fetchmanager sharedinstance]; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_high,0), ^{ [fetchmanager fetchdata]; }); //regular code continues } fetchdata.m(this singleton class) - (id)getinstance { ... } - (void)fetchdata { nsurl *url = [nsurl urlwithstring:@"http://www.data.xml"]; nsurlrequest *request = [nsurlrequest requestwithurl:url cachepolicy:nsurlrequestreloadignoringcachedata timeoutinterval:30]; if (connectioninprogress) { [connectioninprogress cancel]; [connectioninprogress release]; } [xmldata release]; xmldata = [[nsmutabledata alloc] init]; connectioninprogress = [[nsurlconnection alloc] initwithrequest:request delegate:self startimmediately:yes]; } /*and necessary nsxmlparserdelegate protocol methods imple...

c++ - Registering a COM object with only an IDL file -

i have third-party idl file which, when compiled, generates header , _i.c file. 3 of these files part of visual studio 2010 project. (so far project empty other attempted com initialization stuff.) i can project compile calling coinitialize(null); cocreateinstance(stuff); at runtime cocreateinstance() returns "class not registered" error. everything can find on internet says register com object running regsvr32 on dll file or exe file. have idl file. tried registering exe file generated project, got error saying module "loaded entry-point dllregisterserver not found." i'm not sure else try. idl files define interfaces, not implementations. if literally have of third-party component idl file have nothing register. it's possible idl file describes interfaces you're implement third-party code calls into; in case wouldn't cocreateinstance them, might cocreateinstance you. given amount of information, i'm leaning towards you...

iphone - ios safari won't display font-face embedded fonts in svg files. any fix? -

so have svg file, contains text elements. example: <text transform="matrix(1 0 0 1 195.248 207.165)" fill="#999999" font-family="'leaguegothic'" font-size="24">europe</text> when specify font-family included in ios (like helvetica or futura), works fine. however, once specify font included through @font-face, doesn't work on ios, while on desktop safari, chrome, firefox opera. otherwise @font-face fonts work ok throughout page, except svg parts. tried including svg file <embed> , <object> , <img> , didn't help. interestingly, when try inline svg (i.e. svg code directly within html), fonts ok, doesn't draw else form svg file. i on ios 4.2. tried svg 1.1, 1.1 tiny, 1.2, etc. same. is bug or missing something, please? thanks. sample svg file here: http://pastie.org/1637291 your svg sample has no @font-face rule, nor references external stylesheets. maybe solution include s...

How do I apply webform validation in drupal 7? -

i have webforms in drupal 7 website. want validate webform fields. webform contains phone field should accept numeric field , should contain 10 numbers only. there module or have code this. use hook_form_alter() apply custom validation in drupal create module e.g. mymodule file mymodule.module function mymodule_form_alter(&$form, &$form_state, $form_id) { print $form_id; if($form_id=='webform_client_form_1') //change webform id according webformid { $form['#validate'][]='mymodule_form_validate'; return $form; } } function mymodule_form_validate($form,&$form_state) { //where "phone" field name of webform phone field $phoneval = $form_state['values']['submitted']['phone']; if($phoneval=='') { form_set_error('phone','please fill form field'); } // use regular expression validate it. // in above example hav...

javascript - jQuery each function to show a different pop up on each click -

hi trying show separate box each 1 , can't figure out how each loop work right...this code showing every 1 @ same time instead of individual boxes...thanks help. <style type="text/css"> .div_actionslist { border:1px solid #ccc; min-width:100px; max-width:200px; position:relative; top:5px; } .div_actionsclick { cursor:pointer; font-size:14px; } .div_actionslist ul { line-height:18px; } .div_actionslist ul li{ line-height:18px; font-size:14px; padding:3px 8px; } .div_actionslist ul li:hover { background:#0cf; cursor:pointer; color:#fff; } </style> <script type="text/javascript"> $(function() { $('.div_actionslist').hide(); $('.div_actionsclick').each(function(){ $(this).click(function(){ $('.div_actionslist').toggle(); }); }); }); </script> <div class="div_actions"> <div class="div_a...

asp.net - How to determine which control in window.onbeforeunload in javascript caused the event -

i have set in javascript: var onbeforeunloadfired = false; window.onbeforeunload = function (sender, args) { if(window.event){ if(!onbeforeunloadfired) { onbeforeunloadfired = true; window.event.returnvalue = 'you lose unsaved changes!'; //ie } } else { return 'you lose unsaved changes!'; //fx } windows.settimeout("resetonbeforeunloadfired()", 1000); } function resetonbeforeunloadfired() { //need variable prevent ie firing twice. onbeforeunloadfired = false; } i'm trying achieve edit screen user warned before navigating away. works fine except pop normal post backs of button clicks. i'm hoping avoid i'm figuring if determine button pressed work. does know how determine button pressed in windows.onbeforeunload? alternatively know better approach i'm trying achieve? solved putting update panel edit items textboxes etc. now windows.onbeforeunload fires component...

How to change the default menu icon of component in joomla? currently it's using the box icon -

hey guys here know how change default menu icon of component in joomla? it's using box icon it depends on developer, 'icons' decalred in xml file during installation. this; menu img="../media/foo/foo.png" view="">control panel</menu> they typically stored in media folder, under components name. if have installed component, go in swap icon. easy.

apache - Log4j - log file -

does knows how apache log4j handling streams ? if open , close log file each line or if let open stream , flushing ? it doesn't open , close log file each line (this cause overhead). output can buffered (check documentation ). create custom appender opens file appending every line though, trying accomplish?

elisp - Lisp match keywords and find values -

say have list keywords: '(("element1" :keyword1 "a" :keyword2 "b") ("element2" :keyword3 "c" :keyword4 "d") ("element3" :keyword2 "e" :keyword4 "f")) which functions can use find list elements contain :keyword2 , find value in each list? i'm trying in emacs lisp think cl package possibly adapt common lisp solution? i've tried use find function illustrated here no avail (of course, after changing few syntax elements adapt examples emacs lisp). (require 'cl) (defvar *data* '(("element1" :keyword1 "a" :keyword2 "b") ("element2" :keyword3 "c" :keyword4 "d") ("element3" :keyword2 "e" :keyword4 "f"))) (find :keyword2 *data* :test #'find) ;;=> ("element1" :keyword1 "a" :keyword2 "b") (getf (cdr (...

osx - Python includes files on Lion? -

where have been includes files of python in lion ? located @ "/system/library/frameworks/python.framework/versions/2.6/include/python2.6" there 1 files in there : "pyconfig.h" is same on system ? thanks. on os x 10.7, include files apple-supplied pythons linked locations within /system/library/frameworks when install xcode 4 . find find them in /developer/sdks included xcode , example: /developer/sdks/macosx10.7.sdk/system/library/frameworks/python.framework/versions/2.7/include/python2.7 by way, canonical way find location of python's include files use python-config command associated python instance using: $ /usr/bin/python2.7-config --include -i/system/library/frameworks/python.framework/versions/2.7/include/python2.7 -i/system/library/frameworks/python.framework/versions/2.7/include/python2.7 update: answered include files found in sdk location. remembered that, due nasty bug, had had reinstall 10.7 lion on same partition , ...

Android : Configuring Appwidget size at create time -

according documentation should possible configure size of app widget using configuration activity http://developer.android.com/guide/topics/appwidgets/index.html#configuring if user configure settings when or adds new app widget, can create app widget configuration activity. activity automatically launched app widget host , allows user configure available settings app widget @ create-time, such app widget color, size, update period or other functionality settings. i can't find examples on how this, has got ideas? thanks! ash i think may not possible @ moment want. i think solution create separate providers different sizes (4x1, 3x1, 4x2, etc.), content displayed developer. after selecting widget (size) configuration activity can shown user can select content wants. how add multiple widgets in 1 app? for example of working manifest file multiple providers see: http://code.google.com/p/transdroid/source/browse/trunk/androidmanifest.xml

r - It is possible to create inset graphs? -

i know when use par( fig=c( ... ), new=t ) , can create inset graphs. however, wondering if possible use ggplot2 library create 'inset' graphs. update 1: tried using par() ggplot2, not work. update 2: found working solution @ ggplot2 googlegroups using grid::viewport() . section 8.4 of the book explains how this. trick use grid package's viewport s. #any old plot a_plot <- ggplot(cars, aes(speed, dist)) + geom_line() #a viewport taking fraction of plot area vp <- viewport(width = 0.4, height = 0.4, x = 0.8, y = 0.2) #just draw plot twice png("test.png") print(a_plot) print(a_plot, vp = vp) dev.off()

perl - DBI::ProxyServer: Problem with writing a log-file -

when starting proxyserver (dbi::proxyserver) with dbiproxy --logfile c:\windows\temp\dbiproxy.log --debug 1 --localport 2000 or with dbiproxy --configfile dbiproxy.config everything works, except writing of logfile. dbiproxy config file: { 'logfile' => 'c:\windows\temp\dbiproxy.log', 'localport' => '2000', 'debug' => 1, } i pass filename, net::daemon::log needs filehandle. code not ok or have missed something? # net/daemon.pm sub readconfigfile { my($self, $file, $options, $args) = @_; # ... $copts = $file; # ... # override current configuration config file options. while (my($var, $val) = each %$copts) { $self->{$var} = $val; } } sub new ($$;$) { my($class, $attr, $args) = @_; my($self) = $attr ? \%$attr : {}; bless($self, (ref($class) || $class)); $options = ($self->{'options'} ||= {}); # ... # ... $file = $options->{...

patch - How to apply two patches against the same git revision? -

this imaginary problem, i'm having real problems patches. let's have project following git history: a - b - c now if receive 2 patches, c1 , c2 , meant applied on c , how should handle them? if apply patch c1 first, not able apply patch c2 because repository has become: a - b - c - c1 is possible apply them both, or have reply person sending c2 telling him/her update patch? now suppose go offline , work , commit repository becomes: a - b - c - d - e then check email , receive patch c . again, possible apply patch, or have ask update patch? the classic way to: apply received first patch, refuse patch isn't fast-forward , ask sender rebase his/her repo first, re-check patch, , resend it. the general idea isn't solve merge conflicts: creator of patch has necessary knowledge solve conflict current source code. as linus torvalds (creator of git) said in his 2007 google talk : so happens is, remember, distribution means nobody speci...

javascript - Any existing solutions for dynamic forms in Django? -

i'm looking existing solutions building dynamic forms django. want form looks table, when of cells clicked, textbox dynamically displayed instead of text , user can edit value. i know that's quite abstract description i'd appreciate related: if library/framework reload absolutely table switch read-only editable, that's fine. i'm implementing proof of concept web application, i'd avoid spending time implementing scratch. the description unclear, believe. here is: there's list of users instance. simple table. administrator clicks 1 of these users , profile displayed: login: jsmith real name: john smith group: users then administrator double-clicks "john smith" , text box loaded instead of text: login: jsmith real name: [ john smith ] group: users [save] [cancel] administrator can modify jsmith's real name. if save clicked, data sent server. if cancel clicked, data reverted , profile on p.1 ...

php - Custom block (layout?) containing other blocks in Concrete5 -

i make number of websites clients are... less tech savvy... , need easy means of editing website after i've made them. purpose have been coding lot of sites in concrete5. recently received project translate http://www.windowfashionsonwheels.com concrete5. quick glance @ source-code reveals it's nothing tables inside of tables... it's pretty hideous. i've been steadily working rebuild exact appearance , structure using minimal html , css, ran 1 small bump. on main page if scroll down there light-grey box along left side of main body containing 4 different blocks of content. section has different background color, rounded corners, , gradient borders make job little bit harder. i can emulate appearance of box creating single content block in concrete5 , applying custom design (background color, css3 rounded corners, , css3 image borders). since relies heavily on css3 doesn't display in older browsers or internet explorer, plus allows me single content block ...