Posts

Showing posts from March, 2010

html - Chrome is ignoring the rounded corners of my menu on hover -

i'm having issue chrome ignoring rounded corners of menu on hover. works in firefox round corners (in chrome) before hover, on hover corners square up. missing something? html consists of standard ul. #nav > ul > li:first-child a:hover { -moz-border-radius-bottomleft: 4px; -webkit-border-radius-bottomleft: 4px !important; -border-bottom-left-radius: 4px !important; -moz-border-radius-topleft: 4px; -webkit-border-radius-topleft: 4px !important; -border-top-left-radius: 4px !important; background: url(../images/menu-back-hover.png) repeat-x; } the selector webkit browsers (i.e. chrome) should be: -webkit-border-top-left-radius: 4px; -webkit-border-bottom-left-radius: 4px;

java - Help me change TextView color dynamically? -

i know how change color of textview dynamically. seems there stuff out there quite i'm looking for.. i'm doing here iterating array , if "+" want text greem if "-" want text red, problem i'm getting null pointer error @ ct.settextcolor(.....) have idea why? here xml: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listpreferreditemheight" android:padding="6dip"> <imageview android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginright="6dip" android:src="@drawable/icon" /> <linearlayout android:orientation="vertical" android:layout_width=...

WPF custom textbox takes two tabs to get to text? -

i have custom textbox control displays name when there no text inside of it, curious reason have hit tab twice previous element control's text field. on first tab highlight's textbox's border. went through of levels of generic.xaml file properties window open , searching 'tab' 1 find on textbox tabstopping. how make control take 1 tab generic.xaml: <resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:supertb"> <style targettype="{x:type local:supertextb}"> <setter property="template"> <setter.value> <controltemplate targettype="{x:type local:supertextb}"> <border background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" borde...

Javascript error when creating form elements -

error: uncaught exception: [exception... "component returned failure code: 0x80004003 (ns_error_invalid_pointer) [nsidomhtmlselectelement.appendchild]" nsresult: "0x80004003 (ns_error_invalid_pointer)" location: "js frame :: http://localhost/midas/index.php/submit/displayform :: :: line 104" data: no] the code meant create: textboxt - textbox - textbox - pulldown - textbox here code below <script type="text/javascript"> <!-- var ta=new array(); var n=15; window.onload=function() { inp=document.getelementsbytagname('input'); for(c=0;c<inp.length;c++) { if(inp[c].value=='add') { inp[c].onclick=function() { var ta = []; var n = 15; ta[n]=document.createelement('input'); ta[n].setattribute('rows',1); ta[n].setattribute('cols',20); ta[n].nam...

oop - Access instance variable inside a function in javascript? -

how can in easiest way access instance variable inside function? function myobject(){ //instance variables this.handler; //methods this.enablehandler = function(){ var button = document.getelementbyid('button'); button.onclick = function(){ this.handler();//is not working } } } var myobject = new myobject(); myobject.handler = function(){ alert('hello world!'); } myobject.enablehandler(); note can set button.onclick = this.handler; . example. main question how can access this.handler inside function? i can define new variable var handler = this.handler to access this.handler . if change handler will this.handler changes? function myobject(){ //instance variables this.handler; var = this; //notice change //methods this.enablehandler = function(){ var button = document.getelementbyid('button'); button.onclick = function(){ ...

Ruby script to check how many lines of code are in an application -

how write ruby script such get_lines.rb file_name.rb returns total number/lines of code in application recursive through folder > folder > foler such app/modes, app/controllers etc... files! generally wouldn't - i'd use shell utility. seriously. also, want include comments? etc. etc. there's answer this, not using ruby here: how count lines of code in directory recursively? if approaching intent of doing i'd this: dir['**/*.*'].each |fname| puts "#{fname} #{linecount(fname)}" end linecount def linecount(fname) file.open(fname, "r") |f| return f.readlines.length end end this nasty hack way, because reads whole file memory see how long array is, might want each line , count them read through. you rid of blanks or lines comments incrementing counter. something like lines = f.readlines lines.delete_if { |l| l =~ /^[[:space:]]*#|^$/ } return lines.length i haven't tested regexp way. as exer...

c# - WPF: How to find space available for Canvas? -

i'm using wpf shapes create hexagons (for game map) on canvas. after playing around scrollviewer, i've decided implement scrolling , zoom of map myself rather using wpf functionality, using wpf events mouse wheel, arrow keys etc. i'm placing (hex map) canvas last child inside dock panel available remaining space. dock panel set content of main window. want find out how big canvas can before put children on canvas can centre screen on hex want , add shapes (hexs) can seen. when zoomed out, long way remove polygons altogether , use method of rendering , when zoomed in long way add more details. is there neat way of getting available space? way can think of work current dimensions of windows , subtract dimensions of outer elements of dock panel, feels rather messy. you may use actualwidth , actualheight properties of canvas determine size available it. sure horizontalalignment , verticalalignment set stretch .

flashbuilder4 - Code Templates in Flash Builder 4.5 don't work? -

i customize way fb generates new classes, interfaces, code snippets... nothing major, white space, indentation, things that, match coding style. follow instructions on page: http://www.adobe.com/devnet/flash-builder/articles/flashbuilder45-coding-enhancements.html but nothing changes... insights? hm. reason, editing templates in preferences>flash builder>editors>code templates>actionscript doesn't seem change much, @ least in flash builder workflow (create new classes via new>actionscript class, create getters/setters via source>generate getter/setter, etc). however, editing templates in preferences>flash builder>editors>code templates>flash builder does work. stumbled across here . yay complexity , building on top of eclipse! oy.

oop - Business rules that are valid for specific time span – how to manage in an orderly manner -

i started working government agency , have come across interesting problem: business rules depend on legislature , such have respect exact time periods legislature has been active. to give example, if subject has applied subsidy on date, has evaluated according criteria vas valid on given date. same subsidy, applied on later date has different criteria. wondering if there known pattern deal these time-dependent rules in orderly fashion. @ moment, code sprinkled expressions akin to: if application.date >”july 17th, 2008” what best way manage problem? this looks case chain of responsibility . have handlers each legislature. pass application recent handler first. if old, passes down handler previous legislature.

geometry - google maps v3: clearing a circle made from polylines off the map -

i trying figure out how clear circles off map allows users draw radius around point. clearmap function doesn't seem work. see code below <!doctype html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 0px; padding: 0px } #map_canvas { height: 100% } </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script> </script> <script type= "text/javascript"> var geocoder; var map; var count=0; //store points in array var points = []; function initialize() { geocoder = new google.maps.geocoder(); var latlng = new google.maps.latlng(-34.397, 150.644); var myoptions = { zoom: 3, center: latlng, maptypeid: google.ma...

jquery - Trouble getting value from form element -

i'm building visually appealing version of option-select element. i'm making ul have .selected class applied whatever item clicked. <ul id="videolist" class="tilelist"> <li id="video-'. $video-id .'"> <img src="assetspath/etc/'. $video-thumb .'" /> <h4>'. $video-title .'</h4> <p class="hidden vid-id">'. $video-id .'</p> </li> ';} ?> </ul> <input id="videoid" class="hidden" value="<?php echo $current->video ?>" /> and jquery: $(function(){ $('#videolist li').click( function() { $('#videolist li').removeclass('selected'); $(this).addclass('selected'); var vidid =...

html - Can you count clicks on a certain frame in an animation in javascript? -

i'm looking build simple whack mole-esque game in javascript. right know how else except scoring. current animation code follows <script language="javascript" type="text/javascript"> var urls; function animate(pos) { pos %= urls.length; document.images["animation"].src=urls[pos]; window.settimeout("animate(" + (pos + 1) + ");", 500); } window.onload = function() { urls = new array( "frame1.jpg","frame2.jpg" ); animate(0); } </script> so far works, first frame hole , second groundhog/mole out of hole. need count clicks on second frame can't figure out how incorporate counter. help? (sorry if code doesn't show correctly, first time using site) here example counts clicks on flashing animation: http://jsfiddle.net/maniator/tqqj8/ js: function animate(pos) { pos %= urls.length; var animation = document.getelementbyid('animation'); ...

css - How can I remove a font dowloaded with @font-face from the browser cache? -

some time ago asked question , none of answers solved problem. clients complaining i'm gonna try once again: i published new release of webapp using @font-face limited version of "droid sans" (no latin characters). font files hosted on server. week later changed font full version because of customers use spanish language. new customers new full font no problem, customers accessed first time limited font published don't special characters more. i guess old font cached somewhere in browser, haven't been able remove it. i've tried change font name , css definition browser download again... nothing working. knows how fix this? this css definition: @font-face { font-family: 'droid'; src: url(/files/droidsans.eot); src: url(/files/droidsans.eot?iefix) format('eot'), url(/files/droidsans.woff) format('woff'), url(/files/droidsans.ttf) format('truetype'), url(/files/droidsans.svg#webfontw7zqo19g) format(...

jquery - how to open images in a listview in a dialog -

i have asp.net listview shows images , when user clicks on images opens in jquery dialog. here list view: <div id="images"> > no data returned. </td> </insertitemtemplate> <itemtemplate> <td id="td4" runat="server" style=""> <a href='<%# eval("img") %>' class="photoshref"> <img id="photoalbumphotos" src='<%# eval("img") %>' alt="image...

flags - Why is ZooKeeper changing the name of my znode? -

i learning how use zookeeper (version 3.3.3) , have running cygwin (version 1.7.9). in order create znode, following: $ zkserver.sh start $ zkcli.sh [zk: localhost:2181(connected) 0] create /zoo-1 "hello world!" null created /zoo-1 this appears work fine: [zk: localhost:2181(connected) 1] ls / [zoo-1, zookeeper] however, if try use -s flag happens: [zk: localhost:2181(connected) 2] create -s /zoo-2 "hello world!" null created /zoo-20000000007 [zk: localhost:2181(connected) 3] ls / [zoo-20000000007, zoo-1, zookeeper] removing flag, though, keeps name same: [zk: localhost:2181(connected) 4] create -s /zoo-2 "hello world!" null created /zoo-2 [zk: localhost:2181(connected) 5] ls / [zoo-2, zoo-20000000007, zoo-1, zookeeper] why using -s flag, makes znode persistent, change name of znode? following along following tutorial http://java.dzone.com/articles/zookeeper-primer , , example same thing not happen him. thank time! the...

Strange Error when using FancyBox and jQuery -

i'm getting error when trying use fancybox firebug tells me jquery not defined f.length;a;)this.addeventlistener(f[--...s.unbind("mousewheel",a)}})})(jquery); i'm positive paths script , style files correct. <script type="text/javascript" src="/javascript/jquery.mousewheel-3.0.4.pack.js"> </script> <script type="text/javascript" src="/javascript/jquery-1.4.3.min.js"></script> <script type="text/javascript" src="/javascript/jquery.fancybox-1.3.4.pack.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#enlarge").fancybox({ 'titleshow' : false, 'transitionin' : 'elastic', 'transitionout' : 'elastic', 'easingin' : 'easeoutback', 'easingout' : 'easeinback' });}); </script> the jquery li...

How do I configure maven to access maven central if nexus server is down? -

i setup build such automatically attempts download artifact maven central iff our nexus server unreachable. have following in settings.xml , i'm not sure how change (if possible). <profiles> <profile> <id>nexus</id> <!--enable snapshots built in central repo direct --> <!--all requests nexus via mirror --> <repositories> <repository> <id>central</id> <url>http://mynexus</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginrepositories> <pluginrepository> <id>central</id> <url>http://mynexus</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginrepository> </pluginr...

linux - Extract arguments from stdout and pipe -

i trying execute script n times different file argument each time using this: ls /user/local/*.log | xargs script.pl (script.pl accepts file name argument) but script executed once. how resolve ? not doing correctly ? ls /user/local/*.log | xargs -rn1 script.pl i guess script expects 1 parameter, need tell xargs that. passing -r helps if input list empty note following is, in general, better: find /user/local/ -maxdepth 1 -type f -name '*.log' -print0 | xargs -0rn1 script.pl it handle quoting , directories safer. to see xargs executes use -t flag.

Looping through dyamically generated jQuery tabs and adding classes -

ok, have tabbed interface adds tabs dynamically once link clicked , fills newly generated tabs using ajax. portion works fine, need extend functionality allow dynamically-created tabs have class assigned them during same click. current code follows: $(document).ready(function() { var tabs = $("#tabs").tabs(); $(".tabbutton").live("click", function(){ var gettopicid = $('.topicid',$(this).parent()).val(); tabs.tabs('add', 'ajax.php?section=summary&id=' + gettopicid, 'summary'); tabs.tabs('add', 'ajax.php?section=read&id=' + gettopicid, 'read topic'); }); }); this code works absolutely fine add tabs. however, i'm not sure how go adding class. i've tried placing following directly after second tabs.tabs line, no avail: $(this).addclass('testclass'); the main problem generated tabs given id of #ui-tabs-* * automatically incremented va...

vb.net - ignore mouse event on label inside panel -

i making custom menu. applying colors on panels on mouse enter , mouse leave. i have labels on these panels, , mouse enter , leave events work snappy, hover on label (on/inside) panel, mouse leave event fired. know can same thing label mouse enter event, doing other visual stuff, , need have label mouse events totally disregarded. ideas? thanks in advance. i used menu control, , styled accordingly. job better code...

java - CURSOR and REF CURSOR as a JDBC data type -

many rdbms support "cursor" types of sort. types useful when returned stored procedures. example in oracle: type t_cursor_type ref cursor; create procedure p (c out t_cursor_type); when calling procedure using jdbc, oracletypes.cursor = -10 "jdbc" type should used. type not part of standard , not going part of jdbc 4.1 in java 7. does know whether jsr guys consider adding type standard time in future? or if other rdbms have similar "vendor-specific type"? support ref cursors added in java 8/jdbc 4.2. use type types.ref_cursor cursor return types. can iterated through resultset interface. example: callablestatement cstmt = conn.preparecall("{callmysproc(?)}"); cstmt.registeroutparameter(1, types.ref_cursor); cstmt.executequery(); resultset cursor = cstmt.getobject(1, resultset.class); while(cursor.next()) { system.out.println("name = " + cursor.getstring(1)); }

objective c - use applicationDidBecomeActive to call viewDidLoad -

i want make sure initializations views , stuff handled every time application starts, when called after being sent background, such multitasking. what's best way this? should use applicationdidbecomeactive call viewdidload on viewcontroller directly? i'm guessing not wise. want make sure stuff gets done on load every time user calls app, no matter state in @ time. i have several apps published - call viewdidload on 1 or several uiviewcontrollers applicationdidbecomeactive . it works fine. apple doesn't object either. however , aware if have allocations in viewdidload need either check allocated instances or release instances allocate in viewdidload when app suspends. same goes db connections need closed, notification listeners, , on. as long watch these elements , handle them correctly, approach valid , usable.

javascript - How to display error (text/html) response to an AJAX/getJSON request? -

my situation is, i'm developing little web app server provides dynamic json responses. server built on cherrypy. sometimes, there bug in code creating json data, throws, , cherrypy catches , serves 500-error full html page detailing exception. (that is, response has everything: <!doctype..><html><head>...</head><body>...</body></html> ) because request ajax, doesn't displayed. i can intercept error enough, , @ in dev tools; i'd (to ease debugging) open new page (as if user had followed link) , display response in browser. tried window.open('', '_self'); $(document).html(jqxhr.responsetext); but blank page. suppose store error text , serve in second request server, there cleaner way? to follow up, final code worked this: .error(function(jqxhr, textstatus, errorthrown) { $(window).bind('unload', function() { document.write(jqxhr.responsetext); } ); var win = window.open('', ...

sed/awk to double space file -

i have file blank lines , need double space lines in file. meaning need blank line between 2 lines text in it. can show me easy way awk and/or sed try this sed '/^$/d' filename | sed g

Passing PHP variables to non-native JavaScript -

basically, problem this: <?php $test="foobar"; ?> if within html document call <script type="text/javascript">alert("<?php echo $test; ?>")</script> , fine. however, if same thing in external js document included <script type="text/javascript" src="foo.js"></script> it not work. is there way this? in first case pass value php script, <?php echo $test; ?> parsed php parser , replaced value of $test php variable. in second case include ' <?php echo $test; ?> ' string js file , not parsed. my suggestion is: pass value way passing now, reference external js file. example can invoke function defined in js file, passing parameter php file. there ugly way of doing that, such making server treat js files php files, not recommending it. some example: if include in php file: <script type="text/javascript" src="foo.js"><...

c# - Multiple VPN Connections over single IP (multithreaded)? -

is there way make each thread in c# connect single vpn? if yes, how? vpns not thread based or process based. they're low level drivers emulate network connections. theoretically can initiate multiple vpns @ once must configured allow local network , each route appropriate addresses. in practice, vpn profiles prohibit local network access (and other vpn access) due security ramifications. also, vpn software conflicts other vpn software.

iphone - Objc_msgSend and app crash -

when trying launch app on simulator (3.1.3 , xcode 3.1.4), shows me objc_msgsend , application not launch. happens when alloc nsmutable array code part, in viewdidload, -(void)viewdidload{ locationarray = [[nsmutablearray alloc] initwithobjects:@"new delhi", @"faridabad",@"meerut"]; str1=[locationarray objectatindex:0]; str2=[locationarray objectatindex:1]; [super viewdidload]; } then want use locationarray objects in following method; -(cllocationcoordinate2d) addresslocation1{ double latitude = 0.0; double longitude = 0.0; nsstring *str= [locationarray nsstring *str= [locationarray objectatindex:0]; //nsstring *str= @"new delhi" nsstring *urlstring = [nsstring stringwithformat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [str stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]; nsstring *locationstring = [nsstring stringwithcontentsofurl:[nsurl url...

xml - XSL to Copy root node into + add attributes -

i new user xslt , have been struggling problem. source xml: <abc x="" y="" z=""/> result xml: <cde f=""> <abc x="" y="" z"" g=""/> </cde> thus need to create root node attribute default value in result xml. copy node ( source has 1 node only) source result xml. add additional attributes node copied source xml. i able these separately not able of these in 1 xslt. given assumptions, seems need 1 minimal template: <xsl:template match="abc"> <cde f=""> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="g">hello</xsl:attribute> </xsl:copy> </cde> </xsltemplate> or, if prefer: <xsl:template match="/"> <cde f=""> <xsl:apply-templates select="abc"/> </cde> </xsl:template> <...

python - Assuming a many to many relationship model in sqlalchemy with mysql, how to update data ignoring duplicates? -

i little stuck sqlalchemy trying update data. i have many many , one many relationship. first relationship between author , possible spellings of name. second linking authors written literature. paper may have several authors , vice versa. assuming author "peter shaw" has 4 papers stored , linked him in database. no want "add" new set of 6 papers "peter shaw". unfortunately 4 of 6 papers stored in database. why session.commit() results in duplicate error. is there common way avoid duplicate errors, , tell sqlalchemy fill in holes instead of complaining duplicates? neither docus of sqlalchemy nor google enlighten me explicit answer/approach, suggestions apreciated. these models testing with: class namespelling(base): __tablename__ = 'name_spellings' id = column(integer, primary_key=true) name = column(string(255), nullable=false, unique=true, index=true) authors_id = column(integer, foreignkey('authors.id'))...

php - Setting Range for jQuery UI Sliders Based on Results of SQL Query -

if have narrow results filter page jquery ui range sliders post data php page output on same page, there way generate range values assigned jquery ui slider? something placed here imagine.. don't know how grab page doing query/serving results. $(function() { $( "#slider-range" ).slider({ range: true, min: 0, max: 50000, values: [ 0, 50000 ], }); } not 100% sure asking, if need set range values programmatically based on server response, when data server, can get/set values using jquery ui getter/setter. the following shows example of getting/setting range, values, , value //getter var range = $( ".selector" ).slider( "option", "range" ); //setter $( ".selector" ).slider( "option", "range", 'min' ); //getter var values = $( ".selector" ).slider( "option", "values" ); //setter $( ".selector...

html5 - what exactly is the "onSoundComplete" event in jPlayer? -

here demo: http://sethaldridge.com/demos/ don't know if there such event in html5 audio. i'm trying push stream song song html5 audio node.js. 1. create file stream -> 2. write chunk(if there clients) on 'data' event of stream -> 3. open next file stream on 'close'(this make dead circle) dun't know when open next file stream on server side it's event used jplayer flash player. there's no onsoundcomplete event in html5 audio api. it's used mp3 files signal end of file. closest equivalent imagine ended event triggered when media resource has completed. feasible request next resource in ended handler client side?

c# - Get the target MAPI Folder and EntryID of a MailItem after applying Outlook rules -

i'm creating add-in outlook 2007, handles newmailex event , gives storeid of mapi folder , entryid of incoming email in folder, after outlook rules applied it. add-in track email later, using getitemfromid() method of system.namespace class . tried searching unique pr_search_key of mailitem, taking time unnecessarily scanning folders , sub-folders. need way remember email, , not searching again. when handling newmailex entryidcollection containing comma separated string. these guids. need save string somewhere (or id wish save) , can item(s) using outlook.mailitem mi = thisaddin.application.session.getitemfromid(id, type.missing) outlook.mailitem where id single id item want. you'll have call once each item in collection. doesn't matter ends after rules applied. id same. @rotard contact folder use public string getfolderfullname(outlook.contactitem ci) { outlook.mapifolder mf = ci.parent; string path = mf.folderpath; return path; ...

gsp - Customize Grails create-app -

i want grails apps have different look&feel standard grails one. didn't want modify every single application, customize project creation ( grails create-app ) after googling bit around found possibility modify templates directly in grails_home directory. (http://grails.1312388.n4.nabble.com/create-app-customization-td1351040.html) so modified grails_home/src/grails/grails-app/views/main.gsp , grails_home/src/war/css/main.css nothing changed when creating new grails app. rebuild whole grails_home project via ./gradlew assemble nothing changed. have missed? jar file @ grails_home/dist/grails-resources-1.3.7.jar contains updated files. this better implementing own plugin grails, replace required files ( main.gsp , main.css ) after installing.

c# - How to do debug output in Azure roles code? -

suppose write console c# application - can use console.writeline() print whatever status messages , can read when program started in console. now have windows azure role runs somewhere in cloud there's no console anymore. how do debug output spot role current state , debug problems using debug output easily? sometimes resort low-tech (but instantaneous instead of waiting diagnostics transfer stuff): http://blog.smarx.com/posts/printf-here-in-the-cloud

erlang - fault-tolerant counters -

i keep set of counters in fault-tolerant data store following properties: can communicate erlang production ready fault tolerant out of box (multi-server , no roll-your-own master-slave shenanigans) the number of counters dynamic (let's 1k 100k) i willing trade c ap. may assume counters increasing. things i've considered: riak i assume 1 try turning on allow_mult, , aggregating siblings @ read time. works great sets i'm unsure if works counters. riak_zab at time of writing it's not production ready. there's counters code in statebox in branch i've been prototyping: https://github.com/mochi/statebox/tree/counters this can used in combination riak pretty easily. it should work, haven't written application yet it's not on master yet. doesn't fit production ready goal, nothing (except maybe mnesia, there other issues that).

c# - In-Memory Table Data structure -

i build in-memory table data structure 4 columns can values based on combination of columns (using linq example). there built-in data type or have craft 1 myself (obviously can't)? unless have specific in mind, declare type 4 properties suitable names , types, i.e. public class somethingsuitable { public int foo {get;set;} public string bar {get;set;} public datetime blap {get;set;} public float blip {get;set;} } and use list/array/dictionary etc necessary, or data.single(x => x.bar == "abc"); etc.

rails 3,Kaminari pagination for an simple Array -

for paginating common array got solution, @arr_name = kaminari.paginate_array(@arr_name).page(params[:page]).per(per_page_records) per_page_records variable value per needed pagination. any better ideas?? also have ajax call using pagination 1 can use this, in view, give id div tab div id="paginate" and inside <%= paginate @arr_name, :remote => true %> and in js response file put, $('#paginate').html('<%= escape_javascript(paginate(@arr_name, :remote => true).to_s) %>'); so requests ajax. thanks. this available helper method paginate array object using kaminari. alternative is, suggested solution in kaminari wiki page , add instance methods array object. if trying common solution based on activemodel return type ( .all returns array , .where returns arl) following workaround. unless @arr_name.kind_of?(array) @arr_name = @arr_name.page(params[:page]).per(per_page_records) else @a...

osx - How do I change the Ruby version Textmate uses? -

edit: found solution this, can read in answer bellow. i using textmate on snow leopard, , have installed ruby 1.9. problem reason textmate uses ruby 1.8.2 but when use irb, or run ruby scripts shell, proper version of ruby (1.9) used. how can configure textmate uses 1.9.2? i've been googling , apparently have use t_ruby variable , textmate, , set environment variable in osx, far none of methods i've found works me. could give step step solution problem? update: tried adding ruby binary path tm_ruby in textmate, , error: > can't find > “/users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby > /users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby > /users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby > ” on path. theme: current path is: > /usr/bin /bin /usr/sbin /sbin please > add directory containing > “/users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby > /users/myname/.rvm/rubies/ruby-1.9.2-p180/bin/ruby > /users/myname/.rvm/rubies/rub...

Show timezones using google maps api v3 -

i want show timezones on map created using google maps api v3. want show --> http://24timezones.com/ if don't mind using deprecated api, can use api v2 in combination sample code found google search. otherwise, think need find data source give timezones in format (perhaps kml?), , draw them on map perhaps using polyline objects.

Git: How to create a new branch from an earlier/older commit in master branch? -

i made 3 commits in master branch: c1, c2 , c3. point made new branch 'branch1'. did changes , have them commited in c4 on branch1. things follows: c1--c2--c3<--master \ c4<--branch1 however, want use earlier commit in master fork off new branch 'branch2'. i.e. in master branch, want go in time @ c2 , build on top of in new branch. master branch not disturbed in way. c5 commit saving changes done in new 'branch2'. graphically, following figure should explain want: c5<--branch2 / c1--c2--c3<--master \ c4<--branch1 what git command sequence(s) take me there? my second question after achieving case in second figure, if 'revert' performed remove c3 in master branch, effect have on branch1? code in branch1 become corrupted or unstable? simply check out commit , specify branch create: git checkout -b branch2 c2 for second question, depends on ho...

What is the best iphone wireframe creator software? prototype -

can tell me best iphone wireframe creator software? try iplotz. other tools here

php - Facebook Query Language gives just user ids -

Image
i'm trying print friends of user uses application.using facebook query language(flq) it. query gives user id's.how can usernames profile pictures here code: require 'facebook.php'; $facebook = new facebook(array( 'appid' => 'xxxxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxx', 'cookie' => true, // enable optional cookie support )); $session = $facebook->getsession(); if ($session) { try { $some_friends = $facebook->api(array( 'method' => 'fql.query', 'query' => 'select uid2 friend uid1='.$facebook->getuser().' limit 10' )); } catch (facebookapiexception $e) { error_log($e); } } print_r($some_friends); here result: array ( [0] => array ( [uid2] => 521117187 ) [1] => array ( [uid2] => 526583873 ) [2] => array ( [uid2] => 527579769 ) [3] => array ( [uid2] => 531219912 ) [4] => array ( [uid2] => ...

kohana 3 - Kohana3 method invocation from CRON - despite proper routes, always redirected to user/login -

i have such problem running methods in kohana3 cron. the situation follows 1) have set (proper ?) cron jobs in cpanel: php /home/myuser/public_html/index.php --uri=mycontroller/mymethod 2) have set (proper ?) routes in bootstrap.php: route::set('myroute', 'mycontroller/mymethod') ->defaults(array( 'controller' => 'mycontroller', 'action' => 'mymethod' )); 3) globally, app uses auth mycontroller written in such way, can manually access methods webbrowser without need log in. my problem proper methods not invoked cron. instead, receive cron reports email, stating invocation redirected user/login... status: 302 found x-powered-by: php/5.2.17 set-cookie: session=2a41c5efa2a25efb0c698136abb174f5; path=/ location: http://myserver/~myuser/user/login content-type: text/html; charset=utf-8 to honest, out of ideas - might cause , fix? me ? in advance! regards, peter i decided change approach. i creat...

c# - Service call works in main thread, but crashes when multithreaded -

my company has application keeps track of information related web sites hosted on various machines. central server runs windows service gets list of sites check, , queries service running on target sites response can used update local data. my task has been apply multithreading process reduce time takes run through sites (almost 3000 sites take 8 hours run sequentially). service runs through successfuly when it's not multithreaded, moment spread out work multiple threads (testing 3 right now, plus watcher thread) there's bizarre crash seems originate call remote services supposed provide data. it's soap/xml call. when run on test server, service gives , doesn't complete it's task, doesn't stop running. when run through debugger (dev studio 2010) whole thing stops. i'll run it, , seconds later it'll stop debugging, not because completed. not throw exception or give me kind of message. breakpoints can walk through point stops. event logging...

iphone - presentModalViewController not responding -

i have 3 classes. first controllor first controllor in tabbar. using presentmodalviewcontroller present login screen , home screen. have presentmodalviewcontroller in firstcontrollor present login screen , in loginscreen viewdidload method have presentmodalviewcontroller present home screen. home screen presentmodalviewcontroller dismissed in homepage_btn_clicked , presentmodalviewcontroller dismissed in login_btn_clicked. problem have home screen never presented. help? new in iphone development. //first controllor firstcontrollor.m - (void)viewdidload { [super viewdidload]; accounts_login *lvc = [[accounts_login alloc]initwithnibname:@"accounts_login" bundle:[nsbundle mainbundle]]; [self presentmodalviewcontroller:lvc animated:no]; [lvc release]; } //login_view class login_view.m - (void)viewdidload { [super viewdidload]; home_screen *lvc1 = [[home_screen alloc]initwithnibname:@"home_screen" bundle:[nsbundle mainbund...

iis 6 - Using Powershell to Manipulate IP Restrictions on IIsWebVirtualDir -

having trouble using powershell manipulate ip restrictions on iiswebvirtualdir (virtual directories). however, have code in vbs, simple matter :) code in vbs: sub add2iprlist(websiteadsi, strip2add, strip2addsubnet) set webrootobj = getobject(websiteadsi) '"iis://localhost/w3svc/2/root/testvdir" set ipsecobj = webrootobj.ipsecurity if(ipsecobj.grantbydefault)then iplist = ipsecobj.ipdeny else iplist = ipsecobj.ipgrant end if redim preserve iplist (ubound(iplist)+1) 'resize local copy of iplist array currentsize+1 iplist(ubound(iplist))=strip2add&","&strip2addsubnet 'add entry end of array if(ipsecobj.grantbydefault)then ipsecobj.ipdeny = iplist else ipsecobj.ipgrant = iplist end if webrootobj.ipsecurity = ipsecobj webrootobj.setinfo 'apply setttings on server. set ipsecobj = nothing set webrootobj = nothing end sub attem...

semantic markup - Preferred approach for marking up a blog with Schema.org -

background/context as schema.org relatively new, perhaps question promote more discussion definitive answer. either way, learning others' application/experience can gained. having studied http://schema.org documentation pages – , whilst there seems extensive array of properties (read: itemprop attributes) available enrich blog post, there seems inconsistencies , 'grey areas' regard best approach mark blog comments. let me provide example: the schema.org documentation blogs can found on within thing > creativework > blog , reference, blog post lives within thing > creativework > article > blogposting so far, documentation , markup examples on aforementioned pages provide enough reference format blog index page, , bulk of content within individual post ( author , pubdate , articlebody , interactioncount , etc.) the problem: applying userinteraction schema individual blog comments it when start @ individual userinteraction elements (blog comm...

neural network - How do I make an OCR Program? -

i want make program takes image input , outputs text. know can use neural network turn image of single character character. difficult part is: given image text in it, how produce rectangles around each individual character? so sort of methods used , know of research papers discuss how it? thank you a basic approach make histogram of black pixels. first: project pixels on line. deep valleys in histgram indicate separation between lines (try different angles if paper might tilted). then, per line (or per page if know font monospaced) project pixels on horizontal histogram. give strong indication of inter character spaces. minimum gives value average character height , width in next steps. after that, need take care of kerning (where characters overlap). find connected pixels, possibly first doing dilatation or erosion on image compensate scanning artifacts. depending on quality of scan image may have use more advanced techniques, going.

How to remove one or more fields from the DataForm.Validating() event in Silverlight 4? -

i have data form bound object properties decorated system.objectmodel.dataannotation attributes validaton. the problem facing properties of class conditionally needed , not need validated. example when admin of app decides edit user, or may enter password/password confirm/password question/password answer. or he/she may entirely skip properties. so if admin decides enter of 4 fields, have present , validation rules these fields have applied. if admin wants change firstname, lastname, email, or whatever other arbitrary properties - password related fields not need validated. is there way "exclude" them validation process? this sample of object work with: public class registrationdata { public string firstname { get; set; } public string lastname { get; set; } public string email { get; set; } public string username { get; set; } public string password { get; set; } public string passwordconfirm { get; set; } public string passwordquestion { ...

multithreading - Android Connect to Running Thread -

i creating app has uithread , background thread. background thread being used timer - every second sends message uithread update ui. when user exits app hitting backbutton, thread continues run. want happen since user may want open app while timer continues count down. my question when user comes app. want connect background thread running display current state of app - how time left, etc. question how hook in thread still running in background. have tried using thread , asynctask, same issue occurs. thanks can provide. your thread still turning sheer chance - application in fact still running , thread shut down when android decides needs resources. however want well-provided in android - need implement service have process runs in background separately application. can have service start @ boot , run whether or not application started. this http://developer.android.com/reference/android/app/service.html has of need know. communicate between service , foregr...

ASP.Net AJAX calendar - only allow the user to select Mondays -

i have asp.net ajax calender , textbox. want user should able select mondays calender business rule. i can achieve using regular asp.net calendar control using dayrender event, wish use ajax calender control because of better appearance, easy navigation , partial postback. how can achieve (selecting mondays) using asp.net ajax calendar? you workaround alert user if tries select else monday: <script type="text/javascript"> function checkdate(sender,args){ if (sender._selecteddate.getday() != 1){ alert("you can select mondays!"); sender._selecteddate = new date(); //set current date sender._textbox.set_value(sender._selecteddate.format(sender._format)) } } </script> <asp:textbox id="textbox1" runat="server"></asp:textbox> <cc1:calendarextender id="calendarextender1" runat="server" onclientdateselectionchanged="checkda...

java - Hide instead of dispose viewpart when x is clicked -

i have viewpart closable set true. user clicks x. want hide viewpart rather close it. how can done? if app created template makes contributions ui should have workbenchwindowadvisor file in 1 of pregenerated packages. not sure exact implementation details hide window on close, sounds need modify prewindowshellclose method in workbenchwindowadvisor implementation of application.

iphone - release or not release -

i'm developing iphone application. i have following property: @property (nonatomic, retain) point2d* endpoint; and method on same class: - (id)initwithx:(cgfloat)x y:(cgfloat)y; { if (self = [super init]) { endpoint = [[point2d alloc] initwithx:x y:y]; ... } and dealloc method on same class: - (void)dealloc { [endpoint release]; [super dealloc]; } my question code correct? endpoint = [[point2d alloc] initwithx:x y:y]; or maybe have autorelease here. your assignment endpoint = [[point2d alloc] initwithx:x y:y]; does not increase retaincount, if want keep endpoint use later don't use autorelease here. or can use self.endpoint = [[[point2d alloc] initwithx:x y:y] autorelease]; => assignment increase counter of endpoint.

rest - For RESTful services in Java, is JAX-RS better than an MVC framework like Swing, Grails or Play? -

for example, play-framework supports restful services this: restful on play! framework how compare jax-rs jersey implementation? framework play run circles around jersey because of it's cool bells , whistles, , rest too? developer productivity important, proper implementation. perhaps using mvc framework rest services 'wrong'? note, restful services, no ui components @ all. even though it's not "wrong" use mvc framework restful services, there pros , cons versus using jax-rs implementation. (disclaimer: have used jersey , play! fun, , not on production-grade systems, have tailored comments more mvc vs. jax-rs. keep in mind these broad generalizations.) mvc frameworks--at least ones considered developer friendly , "slick"--typically save having build persistence layer (the model part). simplify "routing" requests using either scaffolding via convention or form of configuration. downsides have conform conventio...

hyperlink - jquery: how use sumbit() functions in click() event? -

how use submit , ajax functions on click event? need send input hidden server using link no found in click event.... solution? please help! p.d. sorry english xd $('#delete_link').click(function() { $('#myform').submit(function() { if ($('#codigo').val().length < 1) {$('#notice').html('error'); return false; } $.ajax({ type: "post", url: 'mantenimiento.php?action=eliminar', data: $(this).serialize(), success: function(data) { switch(data){ case 'success': window.location.reload(); ...

Trying to load an offsite page in Fancybox lightbox on form submit -

i'm attempting load lightbox (via fancybox) on submission of mailing list sign-up form. sign-up form action loads off-site link constant contact when form submitted. normally, page loaded in standard pop-up, work fine. but, because folks have pop-ups blocked, we're trying spiff lightbox. so here's rub: when submit form, loads lightbox, won't load page in lightbox. suspect because it's not passing information through iframe/lightbox , it's because don't have set properly. i'm hoping can help, i'm not totally versed in jquery yet. may not need use iframe, i'm not sure. i did find reference passing information via ajax , i'm not totally clear on how works. found similar post , it's not clear how resolved it. here code, perhaps can help? :) i'd appreciate it. $(document).ready(function() { $("#iframe").fancybox({ 'hideoncontentclick': true, 'transitionin' : 'fade', ...

objective c - How can I conditionally declare a delegate in an interface declaration? -

i have xcode 4 project builds 2 different targets. i've defined constants in build settings can run different code each target this: #ifdef version1 // #else // #endif in 1 version of app, need main view controller open view controller , become delegate, other version doesn't use view controller , shouldn't compile code or try become delegate. i've set main view controller header this: #ifdef version2 #import "specialviewcontroller.h" #endif @interface mainviewcontroller : uiviewcontroller <mpmediapickercontrollerdelegate, specialviewcontrollerdelegate> { // etc. the conditional around #import tag works fine, how can declare class specialviewcontrollerdelegate in 1 version not other? just use #define preprocessor directive change delegates between versions. here's example "version2". #ifdef version2 #import "specialviewcontroller.h" #define args pmediapickercontrollerdelegate, specialviewcontrollerdelegate ...

c# - Visual studio 2010 empties the file on crash -

i got bad problem while working on visual studio 2010. accidently power plug switched off , when started computer again file completly empty. tried out following things: i opened in notepad , other couple of editors , empty. i opened in hex editor. hex editor shows bytes set 0. i programatically read file , showd bytes set 0. checked "documents\visual studio 2010\backup files\" project , empty. the file size still showing in kbs code completly gone. is there possible way can recover code? if there not, can suggest me setting/patch taht should there never happens again. note: have autorecover option set every 5 minutes in ide. update : suggested henok, if have compiled , built code @ least once, can reverse engineer binary through reflector. doesn't it, stop in future though, save , save often. @ using subversion svn, or git.