Posts

Showing posts from January, 2011

ruby on rails - Using inherited_resources for nested, polymorphic comments -

i new using inherited resources , want use polymorphic nested comments. have several objects commentable (articles, galleries, etc.) , comments can nested. i'm using combination of awesome_nested_set (parent_id, lft, rgt) comment model having polymorphic commentable columns. the controller needs receive ajax request (only) create action , perform below: posting /articles/12/comments/34 creates comment commentable equal @article (12) , parent equal @comment (34) /articles/12/comments/34 posting /gallery/12/comments/34 creates comment commentable equal @gallery (12) , parent equal @comment (34) i'm bit stuck on begin. use case inherited resources? class commentscontroller < inheritedresources::base respond_to :js, :only => :create belongs_to :article, :cheat, :gallery, :video, :polymorphic => true belongs_to :comments end def create create! |format| # how in here build comment handles polymorphism? @

c# - LINQ: How to force a value based reference? -

i want provide set of filters user pick from, , each filter correspond expression<func<x, bool>> . so, might want take dynamic list of available items ('joe', 'steve', 'pete', etc), , create collection of "hard-coded" filters based on names, , let user select filter(s) wants use. problem when try "hard-code" expression based on string value dynamic list, expression still storing value as, looks me, property hanging off of anonymous type (and don't know how serialize anon. type). sorry if confusing, i'm not quite sure how articulate this. here's sample code: public class foo { public string name { get; set; } } static void main(string[] args) { foo[] source = new foo[] { new foo() { name = "steven" } , new foo() { name = "john" } , new foo() { name = "pete" }, };

iphone - Maps page curl button custom implementation highlighted -

i've been trying same maps app icon map options no success. trying make map curl button in right corner of uitoolbar. couldn't button comes in sdk follow colouring had create own similar looking button. to add tool bar create custom button image uicontrolstatenormal, create uibarbuttonitem customview pageflip button. this works fine need keep highlighted when user touches (and return normal after user finished). when user touches become shaded i've tried setting [button setselected:yes]; , no dice. i've tried setting different states of button current image doesn't work either. assume create highlighted image button set thats lot of time seems simple. any thoughts try? to make uibarbuttonitem blue, must have "done" style. cant change style of button @ run-time alternative left replace contents of toolbar new buttons. fortunately, can specify must animated. i know you're thinking. it's pretty bad.

c# - ValidationAttribute's value always null -

here's simple validation attribute wrote enforce number-only strings (i use validate phone numbers, postal codes , alike): public class numericattribute : validationattribute { public numericattribute() { errormessage = sharedmodelresources.validationstrings.numeric; // message coming .resx file } public override bool isvalid(object value) { string stringvalue = value string; if (stringvalue.isnotnull()) foreach (var c in stringvalue) if (!char.isdigit(c)) return false; return true; } } the problem when used validate other strings, let's decimal, short, int or else, object value null . why validate numeric decimals? because if don't, default validation message 'the value 'x' not valid 'propertyname'. i'm aware of solutions specific problem of default validation message. i want understand why it's null... btw, i'm using vs2008, as

javascript - Variable changed before the fact, can you explain this Chrome V8 behavior? -

i writing javascript program , running in chrome 7, when encountered strange behavior. now, in code, other stuff going on, took me time figure out wasn't me. i have distilled essence of code below. <html> <script> var data = [1,2,3,4,5]; var data_copy = []; (var i=0; i<data.length; i++){ data_copy.push(data[i]); } console.log("printing before:"); console.log(data_copy); //alert(data_copy); console.log("------------------------"); (var i=0; i<data_copy.length; i++){ data_copy[i] = data_copy[i] * 1000; } console.log("printing after:"); console.log(data_copy); </script> </html> when run on chrome 7, output follows in javascript console: printing before: [1000, 2000, 3000, 4000, 5000] ------------------------ printing after: [1000, 2000, 3000, 4000, 5000] how come first call console.log prints changed version of data_copy? now, if uncomment "alert" , run same code, expect: printin

user controls - pass button click event through several usercontrols to a form and let another usercontrol know the button clicked -

i know sounds complex thats true. have winform(clientfile) in project. uses usercontrol in project. usercontorl financialmanager.it initialized in constructor. in financialmanager, there child usercontrol(financialservice) initialized in constructor too. in financialservice, has button , in button click event, initialized last usercontrol(financialitem). i need use winform , c# let usercontrol(timecontrol) in clientfile(initialized in page_load) know button in financialitem clicked. is there way it? if can give sample code, perfect. thank you. by way, usercontrols in 1 project. except usercontrol(timecontrol). since can control code in own usercontrols, seems me want add custom event in 1 of usercontrols. diferent code can subscribe event , know if event triggered. ...but bit hard understand wanted... look basic event tutorial, , you're go.

PHP Filtering Form Input -

hello have simple form on site allows users send feedback. form validated in more 1 way emails bunch of gibberish like: sadfasdasd sadfsa dasd werqwer gsdfh hdfgh. question: there clever way check input string prevent this? distinguishing between rubbish , sense hard job computer , apparently not easy humans either. way degree of success use sort of spam filtering software.

objective c - applicationWillTerminate does not get invoked -

i want save data before terminating, appcontroll class conforms nsapplicationdelegate protocol, , declared method; , in interface builder bound window's delegate outlet appcontroller, cannot method invoked. where wrong, should do? did remember add handler application? uiapplication *app = [uiapplication sharedapplication]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(applicationwillterminate:) name:uiapplicationwillterminatenotification object:app];

jQuery Hotkeys "Tab" on Chrome will still insert \t character, even after return false -

suppose have 2 code below, 1 uses alert() 1 doesn't. found in chrome, 1 using alert() insert tab character \t textarea. $(function() { $("textarea").bind("keydown", "tab", function() { alert("something"); return false; }); $("textarea").bind("keydown", "shift+tab", function() { this.value = "don't alert()"; return false; }); }); http://jsfiddle.net/tu6vf/4/ why happening? , how can prevent behaviour (adding of tab character after return false) you can try use code before "return false" if(jquery.browser.msie) { event.cancelbubble = true; } else { event.stoppropagation(); } you need add parameter event in each binding : function(event) { ... }

c++ - selecting or deselecting a row in qt4 -

how set or reset counter when row of table selected or deselected using mouseevent in qt4? assuming using qtableview or qtablewidget table, can receive qt-signal whenever set of selected cells has changed doing this: connect(thetable.selectionmodel(), signal(selectionchanged(const qitemselection &, const qitemselection &)), this, slot(selectionwaschanged(const qitemselection &, const qitemselection &))); note that work whether selection changed via mouse, keyboard, or other means. if need callback when selection made via qmouseevent, implement overriding qtableview::mousepressevent() and/or qtableview::mousereleaseevent() in subclass , setting flag true before calling superclass (and setting false again afterwards) , checking flag within selectionwaschanged() slot.

php - Upload error 500 when using flash to upload -

i've been trying configure uploading , i've been getting error 500. i'm running server on apache2 php5+ installed. i'm curious why keep getting error. i added these commands try fix it, nothing has worked yet. <ifmodule mod_security.c> secfilterengine off secfilterscanpost off </ifmodule> <ifmodule mod_php5.c> php_value upload_max_filesize 1000m php_value post_max_size 1000m </ifmodule> i looked @ solution don't know module command it, secruleengine off secrequestbodyaccess off note: added .htaccess file a 500 should put useful in /var/log/apache2/error.log

simple Toggle with CSS & jQuery, problems with icons to show state! -

i trying use make simple toggle css & jquery project. problem when 1 item open, , clicked. icon changing when clicked let user see possible expand or collaps (+ -). when 1 clicked, open ones closed want to, icon not changing + closed ones. dos have solution that?? my file looks this: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" media="print" href="print.css" /> <title>simple toggle css &amp; jquery soh tanaka</title> <style type="text/css"> .container { width:200px; min-height:490px; position:absolute; top: 120px; left:810px; background-color:#f4f3f3; padding:5px; } h

php - Using c_url upload file to remote host, file name is incorrect -

using c_url upload file remote host. here code. <?php /* http://localhost/upload.php: print_r($_post); print_r($_files); */ $ch = curl_init(); $data = array('name' => 'foo', 'file' => '@/home/autouvl/public_html/asmallorange/log.txt'); curl_setopt($ch, curlopt_url, 'http://www.test.com/test/receivefile.aspx'); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $data); echo(curl_exec($ch)); ?> question: in receivefile.aspx . got file name "/home/autouvl/public_html/asmallorange/log.txt" . want should "log.txt", not full path. file can uploaded except incorrect file name. what's wrong in code? thank you! $data = array('name' => 'foo', 'file' => '@/home/autouvl/public_html/asmallorange/log.txt;filename=log.txt');

python: curly bracket and colon -

homework question, write function called like: replace_all({'a':'123', 'b':'zab'}, 'acb') what function declaration like? what kind of variable 'a':'123' , {} ? it's dictionary (mapping). see http://docs.python.org/library/stdtypes.html#dict . generally, when define function in python, don't need types. python dynamically typed language.

ios4 - custom scrollbar in UIWebView iphone -

my uiwebview has huge data display , default scrollbar comes uiwebview takes lot of time scroll. is possible implement scrollbar on user can tap , drag wants. any hint in right direction highly appreciated. waiting reply. in advance it depends on type of contents displaying in uiwebview. did try make use of javascript calls scroll ids within html page? take @ wikipedia application or wikipanion iphone example... have navigation screen user can jump section of interest without need scroll whole page. hope help.

Using VIM how do I 'set statusline' to align right? -

my ~/.vimrc uses following statusline setting set statusline=%f%m%r%h%w\ %{&ff}\ %y\ [0x\%02.2b]\ %l/%l,%v\ %p%% everything left aligned. help 'statusline' says - character used "left justify item. default right justified when minwid larger length of item." however, haven't been able use (or not use) - ever align things right. so example of having 1 group of items left aligned , 1 group right aligned? i've tried use = prints = sign. you need prefix = percent sign: %= . using example: set statusline=%f%m%r%h%w\ %{&ff}\ %y\ [0x\%02.2b]\ %=l/%l,%v\ %p%% will right-align " %l/%l,%v\ %p%% " group. should force truncation using %< in suitable place accommodate narrow windows: set statusline=%f%m%r%h%w%<\ %{&ff}\ %y\ [0x\%02.2b]\ %=l/%l,%v\ %p%%

java - Question about Signing Application for Android -

i got question singing applications in android. i worked on update app dat made , put in market before. signed , tried upload update said keystore different. i emailed original developer , signed me. asked if had send him each time wanted upload update. this got him: it's not first time i've done , know sure works . apk give me must unsigned , sign , you're developers market . after not need keystore again . maybe things changed since last time did , in order know happening need know details . this unsigned apk ? other 1 uploaded on market ? did encountered error .... message . attached can find signed apk . is true? if upload signed apk gave me, can use different keystore next update? no, person you're interacting wrong. need sign new apk each time want upload update , each time keystore should same, otherwise market treats other person.

security - How to forbid a .NET DLL class library to be referenced -

how can forbid dll class library referenced in other solutions? you adding strongnameidentitypermission class library matches strong name of program do want able use with. alternatively, explore using internalsvisibletoattribute , although may require design changes in library code. should work long neither assembly signed, or both signed strong name. argument specified on attribute should match public key , name of assembly want able access internal members. but really, stop isn't trying hard use library. won't able add reference, doesn't prevent bypassing through reflection or disassembling code. there ways around security measure implement.

asp.net - Gridview not supported in Firefox and Chrome -

<cc1:tabpanel id="tabpanel2" runat="server" headertext="assigned me"> <contenttemplate> <table style="width: 950px; max-width: 950px;"> <tr> <td style="width: 933px"> <asp:panel runat="server" id="pnlasgntome" width="100%"> <asp:gridview id="grdthread" skinid="gridy" runat="server" autogeneratecolumns="true" width="99%" datakeynames="thread_id" onrowcreated="grdthread_rowcreated" cssclass="grid-view" onrowcommand="grdthread_

sharepoint 2010 - How to enable search for Custom Site Collection Help? -

i've enabled custom site collection feature in sharepoint 2010 install, , verified works creating collection folder , uploading html files topics. the problem search box @ top of windows doesn't work - gives me message of "search service not found.". looks occurs when have custom site collection selected in search scopes drop-down, when select 1 of default sharepoint search collections, such "sharepoint server 2010", can search , find results. i've reset search index, done full crawl , can search , find content main site search page (using content scope), still "search service not found" result. has else come across problem , found way resolve it? there service hidden away somewhere have enable? i found answer here: “search service not found” sharepoint 2010 custom site collection if you’re getting “search service not found” executing search against sharepoint 2010 custom site collection following: make sure share

Export Oracle Table Data by DBMS_XMLGEN -> How to Import? -

Image
i can easy export table data using dbms_xmlgen. there package reimport xml? create table foo( id number ,text varchar2(30) ) / insert foo values (1,'hello'); insert foo values (2,'world'); declare l_foo_xml clob; begin l_foo_xml := dbms_xmlgen.getxml('select * foo'); delete foo; --- ???? insert xml foo ??? end; / thanks christian have looked @ dbms_xmlsave ? the oracle documentation doesn't give examples of it's use, quick google show you. here based on example. (which inspired information here ) create table foo( id number ,text varchar2(30) ) create or replace procedure p(p_xml in clob, p_table_name in varchar2) l_context dbms_xmlsave.ctxtype; l_rows number; begin l_context := dbms_xmlsave.newcontext(p_table_name); l_rows := dbms_xmlsave.insertxml(l_context, p_xml); dbms_xmlsave.closecontext(l_context); end; / call pro

3D modeling in WPF using C# -

is possible open 3d maya file in wpf application , transformations in wpf application itself, if how it,,, can recomend samples? this tool convert maya files xaml: http://www.creativecrash.com/maya/downloads/applications/3d-converters/c/maya-to-xaml taken similar question on mdsn forums: http://forums.silverlight.net/forums/p/2826/7705.aspx

iphone - Textures in Opengl ES 2 not working properly -

i'm working opengl es 2 on iphone , right trying textures working on objects. i'm using .obj files , data in them correct. have written parser myself retrieve data, convert static arrays in c. discard material properties now, getting image path .mtl files manually. i have object 336 triangles, making non-trivial observe, appertaining vertices, vertex faces , texture coordinates (u,v). passing data shaders, resulting image this: http://img530.imageshack.us/img530/9637/pic1io.png http://img404.imageshack.us/img404/7358/pic2pg.png but should (displaying in object viewer). please ignore material properties. http://img16.imageshack.us/img16/1401/pic3cq.png using image texture: http://img217.imageshack.us/img217/1300/shirtdiffuse.png i'm thinking might have texture coordinate faces ? defined in .obj file, , i'm not using them @ all. in books , tutorials have not found concerning this. regards niclas have tried flip texture vertically? times wh

Issue With @OneToMany and Abstraction in JPA -

i have issue one-to-many relationship. have abstract class artifact.java. not mapped table. there other concrete classes extending this, , mapped different tables. have class, mapped table, , class can have collection of of these classes, i.e. collection of type artifact.java. need map using jpa, , have done follows. @onetomany(mappedby="artifactid",targetentity=artifact_item.class, fetch=fetchtype.eager, cascade=cascadetype.all) private list<artifact_item> artifactitemlist; this results in following exception. org.hibernate.annotationexception: use of @onetomany or @manytomany targeting unmapped class: dao.model.artifact.artifactitemlist[dao.model.artifact_item] can please me solve issue? thanks. alright, rephrasing question. have class, artifact.java, mapped table artifact. each artifact can have multiple sub items (one-to-many), aren't related in anyway. so, decided have abstract class artifactitem.java, sub items can extend this. thus, ar

Most efficient way of setting up a project Pydev PYTHONPATH in Eclipse (Helios)? -

i want add folders in pydev project pythonpath can reap benefits of seeing unused imports etc. seemingly have add folders manually including subfolders, 1 one. there way add them @ once (recursively) or doing wrong? now right click project in navigator , select preferences . there go pydev-pythonpath , can add folders. ok, give proper answer, should add folder(s) want in pythonpath source folder(s). so, if have structure such as /myproject /myproject/src /myproject/package /myproject/package/__init__.py /myproject/package2 /myproject/package2/__init__.py you'd want add /myproject/src pythonpath. if had multiple folders add there, edit .pydevproject file (which @ root of project) , add multiple folders there @ once (although noted, should have few folders there, so, not needed -- although may want if you're adding multiple libraries folder or alike). the pydev faq explains on items listed below: how import existing projects/sources pydev? how impo

.net - Sum and Group By in Linq to Entities -

Image
i'm trying sum of values grouping , i'm stuck. sample structure of table: what want is: user name, project name, total work time of project users, grouped user name , project name. the trick need display 0 or null value if user in project , user doesn't have work time yet. example result should this: username project total time user1 project1 15 user1 project2 -- user2 project1 10 how can accomplish this? this scary select work, once add references (navigational properties) db.users.selectmany( x=> x.projects .select(i=> new { user = x.name, project = i.name, worktime = (int?)i.userworktimes.sum(t=>t.worktime) }) ); my assumptions are worktime of int type. nav.property projects projectuserworktimes called userworktimes nav.property users projects called projects

How to add JavaScript in the content page that inherits from Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage -

how add javascript in content page inherits inherits="microsoft.sharepoint.publishing.publishinglayoutpage"? i need pass client ids of dropdownlists present on content in javascript function. there several ways accomplish master page. use resolveclienturl content pages able resolve javascript location. content editor webpart sample article sharepoint (moss) pages: embedding javascript

git - Problems Installing Gitolite on CentOS 5.5 -

am hoping might able point out i'm going wrong. i'm experimenting git , trying install gitolite on centos 5.5 development server. i have been following guide found here: http://www.atomcloud.co.uk/blog/creating-your-own-git-repository-server-with-gitolite/ has been fine until gets point of installing gitolite. the commands guide advises run are: cd $home git clone git://github.com/sitaramc/gitolite gitolite-source cd gitolite-source mkdir -p /usr/local/share/gitolite/conf /usr/local/share/gitolite/hooks src/gl-system-install /usr/local/bin /usr/local/share/gitolite/conf /usr/local/share/gitolite/hooks everything , including mkdir line fine. when running command src/gl-system-install /usr/local/bin /usr/local/share/gitolite/conf /usr/local/share/gitolite/hooks nothing seems happen. changed src , tried running command there without src/ in front of , following error: cp: cannot stat `src/*': no such file or directory cp src/* usr/local/bin failed beneath

performance - How to find an element in a linked list of blocks (containing n elements) as fast as possible? -

my data structure linked list of blocks. block contains 31 elements of 4 byte , 1 4 byte pointer next block or null(in summary 128 bytes per block). add elements time time. if last block full, add block via pointer. one objective use less memory (= blocks) possible , having no free space between 2 elements in block. this setting fix. code runs on 32-bit arm cortex-a8 cpu neon pipeline. question: how find specific element in data structure possible? approach (right now): use sorted blocks , binary search check element (9 bit of 4 byte search criteria). if desired element not in current block jump next block. if element not in last block , last block not yet full, use result of binary search insert new element (if necessary make space using memmove within block). blocks sorted. do have idea make faster? how search right now: (q->getposition() inline function extracts 9-bit position element via "& bitmask") do { // binary search algorithm (bsearch)

php - Symfony - which version to get started -

now symfony2 pr4 released, last 1 before official release. have done tutorials latest symfony 1.4 (the complete jobeet tutorial). my question now: better learn symfony2 before getting closer 1.4? if yes, sources learning symfony2? blogs, books, etc.. thanks! a big part of answer should based on timetable. if have launch project within next 3-4 months go symfony 1.4. since ga release of symfony2 not planned until next year not begin alot of work on system since things may change , may have bugs code hard track down. even though there major changes between 1.4 & 2, don't believe wasted time learning 1.4 for learning symfony2, 2 best places symfony site. blog here , forum here

asp.net - How do i get the tab name in a usercontrol umbraco -

does enyone know how tabname can id dont know how name... code far: int userid = umbraco.basepages.umbracoensuredpage.getuserid(umbraco.basepages.umbracoensuredpage.umbracousercontextid); documenttype typetocreate = documenttype.getbyalias("faqitem"); document newdoc = document.makenew("test123", typetocreate, new global::umbraco.businesslogic.user(userid), 1161); newdoc.getproperty("yourname").value = newdoc.getproperty("question"); foreach(var prop in newdoc.genericproperties) { newdoc.getproperty("email").value += prop.propertytype.tabid + " "; } i managed same using .getvirtualtabs, like: foreach (var t in dt.getvirtualtabs()) { if (t.id == id) return t.caption; }

.net - Customize Windows Form Scrollbar -

i have searched world wide web without proper answer. in windows form application, want change width of scrollbar belongs flowlayoutpanel. the scrollbar added "automatically" since content of flow layout panel larger form. from i've found on web, seems tricky. is there solution this? cheers! no, there's no way change width of scrollbar displayed on single control (although there system-wide setting affect all scrollbars in applications). the ugly truth lowly scrollbar control far more complicated looks. basically, scrollbars on flowlayoutpanel drawn windows (rather .net framework) because of ws_hscroll and/or ws_vscroll window styles set control behind scenes. flowlayoutpanel doesn't provide facility change or modify how these built-in scrollbars drawn. unlike other more advanced modifications in winforms, there no such messages can send control's window procedure. , make matters worse, scrollbars drawn in non-client area of flow

php - codeigniter : pass data to a view included in a view -

i have controller , including 2 views 1 function below $this->load->view('includes/header',$data); $this->load->view('view_destinations',$data); the view file view_destinations.php including php menu file follows <? $this->load->view('includes/top_menu'); ?> my question is, how can pass data fetched controller included top_menu.php ? thank guys inside controller, have $data['nestedview']['otherdata'] = 'testing'; before view includes. when call $this->load->view('view_destinations',$data); the view_destinations file going have $nestedview['otherdata']; which can @ point, pass nested view file. <? $this->load->view('includes/top_menu', $nestedview); ?> and inside top_menu file should have $otherdata containing 'testing'.

html - How to force a piece of text to be 'direction ltr' inside a 'direction rtl' paragraph -

so, phone numbers ltr (left right). working on multilingual website need insert phone number (with '+' prefix , numbers separated '-') inside text paragraph has direction rtl (for relevant languages of course) so have this: .ltr #test {direction:ltr} .rtl #test {direction:rtl} #phone {direction:ltr} <p id="text">please call <span id="phone">+44-123-321</span> help</p> of course not working because ' direction ' works block elements , ' span ' inline element. need phone number inside paragraph can't change ' span ' ' display:inline ' i'm being clear? how make work? you can use unicode directionality marker character before + sign give algorithm hint needs. these are: ltr: 0x200e rtl: 0x200f so: <p id="text">please call <span id="phone">0#x200f;+44-123-321</span> help</p> see this answer more details.

Android ExpandableListView -

recently i'm trying use android's expandable list view, googled around , stumbled upon this http://about-android.blogspot.com/2010/04/steps-to-implement-expandablelistview.html i followed steps exactly, created file contain implementation of own adapter. on oncreate method of main activity call: mentries = findviewbyid(r.id.entries); expandablelistadapter adapter = new myexpandablelistadapter(this); mentries.setadapter(adapter); here's code (taken above url , modified): import android.content.context; import android.view.gravity; import android.view.view; import android.view.viewgroup; import android.widget.abslistview; import android.widget.baseexpandablelistadapter; import android.widget.textview; public class myexpandablelistadapter extends baseexpandablelistadapter { private string[] groups = {"vehicle", "baj"}; private string[][] children = { {"mol", "mor"}, {"in", "ruh&qu

linq - Is there a C# unit test framework that supports arbitrary expressions rather than a limited set of adhoc methods? -

basically nunit, xunit, mbunit, mstest , have methods similar following: assert.isgreater(a,b) //or, little more discoverable assert.that(a, is.greaterthan(b)) however, there limited number of such comparison operators built-in; , duplicate languages operators needlessly. when want complex, such as... assert.that(a.sequenceequals(b)) i'm either left digging through manual find equivalent of expression in nunit-speak, or forced fall-back plain boolean assertions less helpful error messages. c#, however, integrates arbitrary expressions - should possible have method following signature: void that(expression<func<bool>> expr); such method used both execute test (i.e. validate assertion) , provide less-opaque diagnostics in case of test failure; after all, expression can rendered pseudo-code indicate expression failed; , effort, evaluate failing expressions intelligently give clue of value of subexpressions. for example: assert.that(()=> == b);//co

lighting - OpenGL: What happens if I specify a light as both specular and diffuse? -

on sphere lighting example of redbook read this: glfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; glfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; glfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; glfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; gllightfv(gl_light0, gl_ambient, light_ambient); gllightfv(gl_light0, gl_diffuse, light_diffuse); gllightfv(gl_light0, gl_specular, light_specular); gllightfv(gl_light0, gl_position, light_position); then says: in example, first 3 calls gllightfv() superfluous, since they’re being used specify default values gl_ambient, gl_diffuse, , gl_specular parameter as understand far, every light source has default values ambient, diffuse , specular parameters , these 3 arrays specify default values, is right? does every light source default diffuse, specular , ambient? in opengl lighting model, 4 separate lighting equations computed object: ambient, diffuse, specular, , emission. ambient doesn't take normals

Analyze JAR dependencies in a Java project -

i'm looking tool show me graph of jar dependencies in java project based on static analysis of compiled byte code. specifically, i'm trying figure out if there unused jars can eliminate, i'd better understanding of dependencies exist. i'm not using maven. dependency finder comes close, deals in packages rather jars , there doesn't seem way query jars have no dependents. recommendations? free , open source preferred. thanks! see jaranalyzer claims to: ... traverse through directory, parse each of jar files in directory, , identify dependencies between jar files.

unix - script to tar and copy directories -

hey, think best way ask question show need happen. i need go from: project_direcory project solution1 solution2 solution3 to: project_direcory project.tar.gz solution1.tar.gz solution2.tar.gz solution3.tar.gz project.tar.gz still contains solution directories. having issues copying files inside of solution directories , placing them in project_directory. there text files in project, should not copied. trying: for file in $(find /place/* -type d);do tar zcf ${file}.tar.gz $file;done file in $(find /place/* );do mv ${file} /place;done file in $(find /place/* -type d);do cp -r ${file} /place;done what best way this? use find -maxdepth 2 restrict depth.

javascript - navigate back to same page on select-dropdown selection without clearing down controls? -

i have text box , drop-down selection on page, plus bunch of urls. clicking on urls navigate page updated url (for asp.net mvc2 functionality). not cause texbox clear down. on dropdown "onchanged" event call window.location = url; (with url being pages url sortorder in query string)... causes pages text-box text clear down. is there way can drop-down postback page on selection changed , not clear down text box? cheers, james. what mean "clear down"? dropdown lose it's selected item (e.g. gets reset default value)?

iPhone API for recording sound and measuring the sound frequency and power(db) -

i want develop simple iphone application can record external sounds, , measure sound wave frequency , power in decibels, ideas how this? the section of documentation labeled audio & video might place start.

xcode - How do get a list of discarded symbols when iOS app is linked against a static library? -

i'm building ios static library third parties use. it's built using several other static libraries containing large amount of c++, resulting in huge deliverable library. the api ios library quite simple, , know doesn't exercise of included code. i'd remove unwanted modules various libraries can final size down. i have example app uses library apis, , when it's linked of symbols in library discarded. there way of getting list of symbols? this answer seems indicate want isn't possible in gcc 3.x , 4.x: restricting symbols in linux static library

c# - Convert from a sequence diagram to collaboration diagram -

i know can convert sequence diagram collaboration diagram using rational rose, but... using visual studio, possible? or have create myself? there's no support collaboration diagram conversion in visual studio.

android - Howto use Google Accounts as login -

i'm thinking using google accounts user verification service i'm developing. client , server. i'm hoping able use signed-in google account on android phone , use verification on server. where can find information this? is possible use signed-in account on phone or have re-sign-in in application? there's class called accountmanager acts registry users online account. think looking for. there's called federated login google , allows users login using google account. more openid

Perl on Windows Server 2008? -

does perl work on windows server 2008 (and win server 2008 r2)? there distribution these os? yes does. need active perl: http://www.activestate.com/activeperl/downloads

Adding structure view to delphi 5 ide menu -

Image
exist ide expert add structure view delphi 5 ide menu? thanks in advance. modelmaker code explorer nice alternative structure view of source code. works nicely in delphi 5. --jeroen

jquery - using quicksand plugin to get specific data -

can me quicksand plugin, trying load web data-value first not data-value loaded on pageload.the idea when click on drop down menu instance web design web.html has web projects loaded not value under default.this html: thanks! <div id="smoothmenu1" class="ddsmoothmenu"> <ul> <li>home</li> <li>design <ul> <li>web design</li> <li>banners</li> <li>posters</li> </ul> </li> <li>video< <ul> <li>category 1</li> <li>category 2</li> <li>category 3</li> </ul> </li> <li>games</li> <li>contact</li> </ul> <ul id="content" class="gallerynav"> <li class="selected-1 button2">< data-value="all">all</li> <li class="button2"

local storage - Javascript localStorage and domains -

because ipad/iphone doesn't support cookies third party sites, want store values in localstorage. example on domaina might be: <script src="http://domainb/something.js"></script> this script on domainb can access window.localstorage , works great. values stored in domaina because that's document's location. if put script inside iframe source on domainb, works, i'm trying avoid frames. question is: there way get/set values in localstorage on remote domain such they'll there when visit domainb @ later time? this isn't possible without iframe workaround. the ability access same localstorage object multiple domains violate same origin policy,and spec: user agents must raise security_err exception whenever of members of storage object returned localstorage attribute accessed scripts effective script origin not same origin of document of window object on localstorage attribute accessed. http://dev.w3.o

Converting Date string starts with days to DateTime Format vb.net -

i have date "27/03/1985" , because starts days can't convert datetime. see: http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx datetime.parseexact() lets specify format of string representation.

php - How to call a function with a variable number of parameters which correspond to an array values? -

ok, know sounds weird need make function receive 2 parameters first 1 string , second array (containing strings). this function call sprintf . first parameter $format , array correspond various $args . how can achieve (if possible)? thanks! well want vsprintf() function.

java - Dynamic call to message bundles? -

i have simple jsf 2.0 project. i have index.xhtml file show me picture of mount rushmore. on page, can click on picture , want go "president.xhtml" - no problem in that. simple action=""... my problem message bundle file (messages.properties) set static keys , values, ex.: jeffersonpagetitle=thomas jefferson rooseveltpagetitle=theodore roosevelt lincolnpagetitle=abraham lincoln washingtonpagetitle=george washington and in "president.xhtml" file, want show these titles depending on clicked on. <h:form> <span class="presidentpagetitle">#{msgs['rushmore.president'],pagetitle}</span> <br /> <h:graphicimage library="images" name="jefferson.jpg" styleclass="leftimage" /> <span class="presidentdiscussion">#{msgs.washingtondiscussion}</span> <br /> <h:commandlink action="index" styleclass="backlink">${msgs.in

python - Generating a graph with certain degree distribution? -

i trying generate random graph has small-world properties (exhibits power law distribution). started using networkx package , discovered offers variety of random graph generation. can tell me if possible generate graph given node's degree follows gamma distribution (either in r or using python's networkx package)? if want use configuration model should work in networkx: import random import networkx nx z=[int(random.gammavariate(alpha=9.0,beta=2.0)) in range(100)] g=nx.configuration_model(z) you might need adjust mean of sequence z depending on parameters in gamma distribution. z doesn't need graphical (you'll multigraph), need sum might have try few random sequences (or add 1)... the networkx documentation notes configuration_model give example, reference , how remove parallel edges , self loops: notes ----- described newman [1]_. non-graphical degree sequence (not realizable simple graph) allowed since function returns graphs self loops , paral

email - Equivalent of Firebug for Thunderbird -

when build newsletter , send myself test, able analyze resulting html in email client (thunderbird). is there tool similar firebug thunderbird? found 1 called "dom inspector" pretty weak , hard use... chromebug works on xul applications , tried on thunderbird. program use debug firebug. http://getfirebug.com/wiki/index.php/chromebug_user_guide you want recent 1.7x.0a build. jjb

Accessing XML nodes using XPath -

<attributes> <attribute name="mail zone" property="alerts.p45" type=""> <value>mailzone</value> </attribute> <attribute name="employee name" property="acm_alert_custom_attributes.cs11" type=""> <value>employeename</value> </attribute> <attribute name="manager name" property="alerts.p23" type=""> <value><managername></value> </attribute> how can select node <value> based on attribute "name" of above xml using xpath? let's wanted select value element child of attribute name "employee name". the xpath expression following: /attributes/attribute[@name="employee name"]/value in xsl can use this: <xsl:value-of select="/attributes/attribute[@name='employee name']/value"/> it's built following way. first

c# - Access XmlAttributesOverrides added attributes in IXmlSerializable methods -

how access xmlattributes applied fields in ixmlserializable object using xmlattributesoverrides ? sample ixmlserializable object: public class person : somebaseclass, ixmlserializable { public string name1; public string name2; [xmlignore] public string name3; public person() { } public person(string first, string second, string third) { name1 = first; name2 = second; name3 = third; } public xmlschema getschema() { return null; } public void readxml(xmlreader reader) { // .... } public void writexml(xmlwriter writer) { fieldinfo[] finfo = this.gettype().getfields(); foreach (fieldinfo finf in finfo) { fieldattributes attr = finf.attributes; object[] atts = finf.getcustomattributes(true); if (atts.length == 0) { // handle field no attributes ... should name1

SVN Pre-commit Hook FTP Upload in Windows -

i've got svn repo running on windows machine. need script upload committed file remote web server. i've read on pre-commit hooks, don't know how write script, or in language should written in. seems script needs .bat or .exe run in windows. does have script run on windows machine? i'm not looking upload entire site, individual file(s) committed. want pre-commit hook because give user feedback should ftp upload fail. if you've done before, please explain whole process newb. a pre-commit hook used when want able fail commit reason. want fail commit cause ftp site down, or disk full? you should use pre-commit scripts fail stuff under developer's control such files missing required properties, etc. gives developer chance correct problem, resubmit commit. a post-commit script still ties user's terminal wait complete, script can fail , notify user failed, commit happens anyway. if want hooks, should doing post-commit hook , not pre-commit hook

linux - Recursive Function to Return Directory Depth of File Tree -

i'm trying write function traverse file directory , give me value of deepest directory. i've written function , seems going each directory, counter doesn't seem work @ all. dir_depth(){ local olddir=$pwd local dir local counter=0 cd "$1" dir in * if [ -d "$dir" ] dir_depth "$1/$dir" echo "$dir" counter=$(( $counter + 1 )) fi done cd "$olddir" } what want feed function directory, /home, , it'll go down each subdirectory within , find deepest value. i'm trying learn recursion better, i'm not sure i'm doing wrong. here version seems work: #!/bin/sh dir_depth() { cd "$1" maxdepth=0 d in */.; [ -d "$d" ] || continue depth=`dir_depth "$d"` maxdepth=$(($depth > $maxdepth ? $depth : $maxdepth)) done echo $((1 + $maxdepth)) } dir_depth "$@"

multithreading - Monitoring C# Threads - Which does what/when -

as everybody, used debugging code in vs in step-by-step mode. well, have application many background workers everywhere, not in kansas anymore. what efficient way debug threaded applications , able monitor each , every thread keep track of what's happening on code? as of now, stick ol' debugging using separate logger instances each thread, becoming nightmare , i'll drowning own logs. don't try debug @ once. narrow focus particular behavior in 1 thread or pair of threads interact around mutex lock. if accessing shared resource problem, set breakpoints around use of resource (which should in common code, not on place). if want see thread 3 completed before thread 1, or thread 2 used work items , sitting idle, use logs that. you can use vs threads view see each thread doing whenever process stopped @ breakpoint on thread. can give insight threads doing @ given instant.

functional programming - Trying to improve a current ugly piece of code in haskell dealing with lists -

i trying implement function in haskell that'll take arbitrary integer list xs , integer k , , returns set of lists k in possible positions. for example, xs = [0, 1] , k = 2 , we'd have myfunction [0, 1] 2 = [ [2, 0, 1], [0, 2, 1], [0, 1, 2] ] i've implemented puton xs x = (take xs) ++ (x:(drop xs)) putonall xs x = map (puton xs x) [0..(length xs)] yet, feel there must other smarter ways achieve same. code seems trying kill bug missile. make sugestions on ways clever bit of code? thanks taken this question : ins x [] = [[x]] ins x (y:ys) = (x:y:ys):[ y:res | res <- ins x ys]

java - Is synchronization needed while reading if no contention could occur -

consider code sniper below: package sync; public class lockquestion { private string mutable; public synchronized void setmutable(string mutable) { this.mutable = mutable; } public string getmutable() { return mutable; } } at time time1 thread thread1 update ‘mutable’ variable. synchronization needed in setter in order flush memory local cache main memory. @ time time2 ( time2 > time1, no thread contention) thread thread2 read value of mutable. question – need put synchronized before getter? looks won’t cause issues - memory should date , thread2’s local cache memory should invalidated&updated thread1, i’m not sure. rather wonder, why not use atomic references in java.util.concurrent ? (and it's worth, reading of happens-before not guarantee thread2 see changes mutable unless uses synchronized ... headache part of jls, use atomic references)

ruby on rails - Sharing Rspec tests between classes -

hey all; in writing tests controller controller rspec, i've found myself duplicating few basic tests, such check index: describe "on index" "renders index template" :index response.should render_template('index') end end i feel test important, redundant, when added 5 different controllers. there way share tests between controller classes, or include specific code blocks method call in rspec? or best practices duplicate, in case? yes you can , , think lead cleaner code.

Perl performance: for(1..200000) vs for($_=1;$_<=200000;$_++) -

for(1..200000) {...} vs for($_=1;$_<=200000;$_++) {...} does first 1 have create array of 200,000 items or same second? i can definitively for range ( $lower .. $upper ) doesn't create actual temporary list in memory. it did 12 years ago, not anymore. , matter of fact, gives better performance explicit c-style for-loop (as others' benchmarks have shown), because perl able counting loop in nice, efficient internal code. shouldn't afraid use it.

Customizing Google Maps information bubble -

how customize google maps information bubble when user clicks on red pin? instance, want add input text field , submit button within bubble. thanks. you can put html infowindow here's google's examples http://code.google.com/apis/maps/documentation/javascript/examples/infowindow-simple-max.html

caching - Expiring all caches on a controller -

i got resourceful controller custom action. action pretty heavy, i'm working on caching it: class mycontroller < applicationcontroller caches_action :walk_to_mordor # /my/:id/walk_to_mordor/:direction def walk_to_mordor # srz bzns end end it works nice, caching done , page fast. however, want allow user "bust" cache clicking on link on page. @ first tried: def bust_cache expire_action :action => :walk_to_mordor end rails complained no route matches action. might because of parameter. hmm, let's give him: def bust_cache myentities.all.each |e| expire_action walk_to_mordor_path(e, ??) end end problem, can't possibly identify choices of :direction . is there way clear action caches match regular expression, or action caches specific controller? the secret called expire_fragment : expire_fragment(key, options = nil) removes fragments cache. key can take 1 of 3 forms: string - take form o