Posts

Showing posts from January, 2012

javascript - progressbar not appearing -

i have jquery ui progressbar acts timer. when open page, has "loading..." (added in html) , nothing else. links files html file: http://pastebin.com/re0zkvny javascript file: http://pastebin.com/zyna5mny i can't seem find wrong code. tried copy & pasting code jquery ui demos, nothing seems make work (with code.). it seems you're doing few things wrong: you're trying use jquery ui progressbar widget yet you're setting progress bar's width using css (which manipulates usual html div element some of code executes , on ready event this simplified example doesn't use jquery ui progress bar rather custom solution way use. but let me modify code , move belongs: // progressbar stuff $(function() { /* don't need $( "#loading" ).progressbar({ value: 0 }); */ //increment progressbar var loading = $('#loading'); width = 0; //loading.width(); var interval ...

Xcode save text -

how can save label, then, if close app , open again still there? you can use nsuserdefaults if data general preferences type data won't cripple app if user prefs wiped reason. it depends on how vital data , how permanent need make persistence.

Java splash screen not working when using a shortcut -

i have created exe jar file launch4j. have splash screen in png loaded executing parameter -splash:logo.png when execute exe file, works properly. if execute program shortcut, doesn't work (i mean splash image, rest of program works ok). why happen? how can fix problem? set working directory in shortcut. one of shortcut properties should "start in" or "working directory". make sure have set same directory shortcut in. when double-click on exe start it, happens automatically. when create shortcut, set anything. the problem here isn't shortcut losing parameter. impossible since it's compiled exe file. problem here application cannot find logo.png, expecting in subfolder of working directory.

c# - htmlunit .net MVC Views unit testing -

i using htmlunit java (converted run in .net) details here using same logic example, using web client , works mvc3 razor code/views. problem occurs when have [authorize] above views webclient can't access page. there way around this? how (if possible) set automatically log on? if parse login page , submit admin/password.. carry on every page visited in "session" i have tried: [setup] public void setup() { //initiate webclient webclient = new webclient(); //login var loginpage = (htmlpage)webclient.getpage(properties.domainnametotest + "account/logon/"); ((htmlinput)loginpage.getelementbyname("username")).setvalueattribute(properties.adminusername); ((htmlinput)loginpage.getelementbyname("password")).setvalueattribute(properties.adminpassword); var action = (htmlpage)loginpage.getelementbyname("loginbutton").click(); ...

python - Are urllib2 and httplib thread safe? -

i'm looking information on thread safety of urllib2 , httplib. official documentation ( http://docs.python.org/library/urllib2.html , http://docs.python.org/library/httplib.html ) lacks information on subject; word thread not mentioned there... update ok, not thread-safe out of box. what's required make them thread-safe or there scenario in can thread-safe? i'm asking because it's seems that using separate openerdirector in each thread not sharing http connection among threads would suffice safely use these libs in threads. similar usage scenario proposed in question urllib2 , cookielib thread safety httplib , urllib2 not thread-safe. urllib2 not provide serialized access global (shared) openerdirector object, used urllib2.urlopen() . similarly, httplib not provide serialized access httpconnection objects (i.e. using thread-safe connection pool), sharing httpconnection objects between threads not safe. i suggest using httplib2 o...

javascript - Find the <th> of a clicked <td> in a table when <th> has span greater than 1 -

i'm trying find td's associated th cell, having trouble using jquery's index() , eq() functions since th's in table have spans of greater one. i know can retrieve td's cellindex property, use find th? or there more appropriate way? intended functionality click cell , have give me name of heading it's under. code sample: http://jsfiddle.net/kytda/ if want find corresponding table header given index of table cell can use following jquery (this assuming have table cell's index): var th = td.closest('table').find('th').eq($td.index());

java - Code color styling in Eclipse -

a nice simple question: there similar http://studiostyl.es/ eclipse? update : since used link figure out how use plugin, figured i'd put here. http://www.eclipsecolorthemes.org/?view=plugin that site looking for. have @ http://www.eclipsecolorthemes.org/ , directly available in marketplace.

How To Add A Ruby Blog to a Rails 3 App -

is possible add blog system toto ou jekyll existing rails 3 app? thanks so long blog rack app, can mount in router. see yehuda katz' excellent post details.

android - ListView is not populating -

i created adapter populate custom listview , when ran on emulator activity blank. plz help. sure i'm missing 'cause new java & android. code snippets correct , pointers appreciated. thnx! my activity: public class list_ac3 extends listactivity { /** * -- called when activity first created * =================================================================== */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.list_view2); displayresultlist(); } private void displayresultlist() { cursor databasecursor = null; domainadapter databaselistadapter = new domainadapter(this, r.layout.list_item, databasecursor, new string[] {"label", "title", "description"}, new int[] { r.id.label, r.id.listtitle, r.id.caption }); databaselistadapter.notifydatasetchanged(); ...

javascript - Spin wheel image in HTML5 (e.g., roulette wheel)? -

what's best way emulate spinning roulette wheel in html5? the wheel spinning should controllable input (i.e., speed of spinning based on user input). wheel labels should blur wheel spins fast, spinning slows, labels on wheel become more , more readable. are there html5 libraries support this, or animations need programmed hand? this needs supported on ios devices. it can done in few lines of css. http://jsfiddle.net/ynbxz/1/ – css-only (see in chrome or safari). http://jsfiddle.net/ynbxz/2/ – javascript, demonstrate how customize animation. blurring optical effect, doesn't need simulated.

php - in_array() does not work as expected -

this question has answer here: php in_array() / array_search() odd behaviour 2 answers for array ($options) : array ( [0] => 0 [1] => 1 [2] => 2 ) php returns true: $this->asserttrue( in_array('bug', $options ) ); // true $this->asserttrue( in_array('feature', $options ) ); // true $this->asserttrue( in_array('task', $options ) ); // true $this->asserttrue( in_array('rockandroll', $options ) ); // true why? this because 0 == "string" true , , 0 element of array. set parameter $strict in in_array true: $this->asserttrue( in_array('bug', $options, true) );

asp.net - Generating PDF from HTTPS causes error -

i'm using winnovative pdf converter generate pdf files html (url) when triggering button on http web page, generate pdf http url, works fine. however when triggering button on https web page, generate pdf http url, error: could not render url. not image url.navigation timeout.. why happening , how can prevent it? please note: i'm not getting error when generating pdf of https page, i'm getting error when making web request https page generate pdf

c# - Exception when releasing a Mutex. What could cause this? -

i'm getting following exception "object synchronization method called unsynchronized block of code" when releasing mutex in code below: int count = 0; try { mutex.waitone(); count = requests_sent.count; } catch { } { mutex.releasemutex(); } requests_sent dictionary being accessed (read/write) other threads have no clue why code throwing exception. have ideas? move waitone() call above try block. want release mutex when know acquired it. you'll stand chance better diagnostic.

iphone - Library error in my iPad application -

i getting following error: program received signal: “0”. data formatters temporarily unavailable, re-try after 'continue'. (unknown error loading shared library "/developer/usr/lib/libxcodedebuggersupport.dylib") what mean? it's due short memory while running, in case please leaks. message pasted in saying "data formatters" in several situations, possibly commonly when unable find linked in shared library @ launch time. please check link too, similiar question, data formatters temporarily unavailable

Java: Getting a font with a specific height in pixels -

it’s easy determine rendered height of font using fontmetrics , other way around? how can obtain font fit specific height in pixels? "give me verdana in size 30 pixels high ascender descender." how ask java this? jen, i don't think there's "direct" way find font height; indirect way... looping through sizes, , testing height of each <= required height. if you're doing once, loop through them... if you've doing "on fly" binary search, it'll quicker. cheers. keith.

c# - Task.Start fails when continuation actions are not inline -

what wrong following code? task.start fails index out of range exception. more clear.. failing because value coming 3 in loop !!! actionprovider m1 = new actionprovider(); actionprovider m2 = new actionprovider(); actionprovider m3 = new actionprovider(); list<action> actions = new list<action>() { ()=> { m2.doit(); }, ()=> { m3.doit(); }, }; task t = new task(() => { m1.doit(); }); (int = 0; < actions.count; i++) { t.continuewith(t1 => actions[i]()); } t.start(); it because reuse same variable, i, several times. when execute task has been incremented. try change for-loop follows: (int = 0; < actions.count; i++) { var action = actions[i]; t.continuewith(t1 => action()); } the difference here create copy of variable pass continuewith.

javascript - Make JSON-RPC jQuery plugin work with GAE ProtoRPC -

i trying make these 2 libraries work together. not sure can connect out of box. before using json-rpc plugin did standard $.ajax functionality. please give me short example of how client-side function should , entry point on gae side. or maybe there should special protorpc jquery library created make work easily? json-rpc plugin homepage protorpc doesn't use json-rpc message format. uses simpler format each api method provides own endpoint, rather 1 endpoint takes method name part of request dictionary. here's example provide $.ajax : $.ajax({url: '/hello.hello', type: 'post', contenttype: 'application/json', data: '{ my_name: bob }', datatype: 'json', success: function(response) { // response { hello: "hello there, bob!" } alert(response.hello); } }); do need special jquery library this? i'm not sure can simp...

android - do not understand xml parsing code -

the following code xml parsing. try { httpentity entity = response.getentity(); final inputstream in = entity.getcontent(); final saxparser parser = saxparserfactory.newinstance().newsaxparser(); final xmlhandler handler = new xmlhandler(); reader reader = new inputstreamreader(in, "utf-8"); inputsource = new inputsource(reader); is.setencoding("utf-8"); parser.parse(is, handler); //todo: data handler } catch (final exception e) { log.e("parseerror", "error parsing xml", e); } over here pass url. response object in line response.getentity() object of httpresponse()? thank in advance. the code show processing after url connection has been opened, , result has been obtained. @ point there no more url pass. response httpresponse.

Why do php form arrays behave strangely/(unexpectedly) in jQuery -

why php form input arrays act funny in jquery? is there way overcome this? hi, wrote code , works.. updating form of 21 radio inputs emphasize label next checked radio(s). *visually - not in html tag $(function() { for(count = 0;count<21;count++) { result = $("input:radio[name=choice"+count+"]:checked").val(); $("input[name=\"choice"+count+"\"][ value=\""+ result +"\"]").attr("class", "magic"); $("div.radio:has(input.magic)").attr("class", "radio spell"); } $("input").click(function() { $("div.radio:has(input.magic)").attr("class", "radio"); $("input.magic").removeattr("class", "magic"); var count = 0; var result = 0; for(count = 0;count<21;count++) { result = $("input:radio[name=choice"+count+"]:checked")....

c# - Can we make assumptions over structs layouts? -

is there convention on algorithm used make layouts of structs on c? i want able have code running in vm able have structures compatible c counterparts, c# interop works. need know how alignment algorithm works. gather there must convetion that, works nicely on c#. have in mind probable algorithm have used work out, haven't found proof right one. here's how think works: for each declared field (by order of declaration) see if field fits in remaining bytes (until next alignment) if doesn't fit, align field; otherwise add current offset for example, on 32-bit system struct like: { byte b1; byte b2; int32 i1; byte b3; } would this algorithm: { byte b1; byte b2; byte[2] align1; int32 i1; byte b3; byte[3] align2; } in general, structure alignment in c depends on compiler used, , especially compiler options in effect @ time structure declaration processed. can't make general assumptions except particular structure in particular program compiled...

passwords - bcrypt -- keeping up with Moore's law -

this question has answer here: optimal bcrypt work factor 1 answer i'm using bcrypt store passwords in database, using work factor of 7, takes 0.02s hash single password on reasonably modern laptop. coda hale says using bcrypt allows 'keep moore's law' tweaking work factor. there's no way re-encrypt user's password, since i'm not storing plaintext. how can keep database up-to-date , difficult crack (assuming hangs around 5+ years take become issue)? re-encrypt on login. see optimal bcrypt work factor . remember value stored in password: $2a$(2 chars work)$(22 chars salt)(31 chars hash) . not fixed value. if find load high, make next time log in, crypt faster compute. similarly, time goes on , better servers, if load isn't issue, can upgrade strength of hash when log in. the trick keep taking same amount of ...

ruby on rails - How do I add timezone configuration to my environment.rb file? -

first, difference between configuring in application.rb file vs. environment.rb file? i read need configure timezone default in environment.rb file. not quite sure how though. far have in environment.rb file: # load rails application require file.expand_path('../application', __file__) # initialize rails application sampleapp::application.initialize! do need rerun rails server after make changes? additional steps? thanks! in rails 2, environment.rb had configuration. in rails 3 it's changed application.rb, environment/production.rb , environment/development.rb, , gemfile. configure timezone, put in application.rb in application class: class application < rails::application config.time_zone = 'eastern time (us & canada)' end you can run rake time:zones:all see list of available timezones. edit in rails 3 don't need touch environment.rb.

html - Show checkbox with image thumbails -

Image
i have lot of thumbnail , want show check box on images @ left-top side shown in image. displaying thumbnail images in repeater. anyone have idea how can do? thanks in advance keep image , check box in container after absolutely position checkbox

WPF How do I align buttons on the right with x number of buttons -

i trying align buttons on right of dockpanel, hide , show buttons based on certian criteria. in need of howto right justify based on shown. using this: <dockpanel horizontalalignment="stretch" height="34" margin="0,0,2,35" verticalalignment="bottom"> <button dockpanel.dock="right" height="23" x:name="btnone" click="btnone_click" margin="0,0,5,5" verticalalignment="bottom" horizontalalignment="right" width="auto"> <textblock x:name="txtbtnonetext" /> </button> <button dockpanel.dock="right" height="23" width="auto" x:name="btntwo" visibility="hidden" click="btntwo_click" horizontalalignment="right" margin="0,0,5,5" verticalalignment="bottom"> <textblock x:name="txtbtntwotext...

linux - Filter log file entries based on date range -

my server having unusually high cpu usage, , can see apache using way memory. have feeling, i'm being dos'd single ip - maybe can me find him? i've used following line, find 10 "active" ips: cat access.log | awk '{print $1}' |sort |uniq -c |sort -n |tail the top 5 ips have 200 times many requests server, "average" user. however, can't find out if these 5 frequent visitors, or attacking servers. is there way, specify above search time interval, eg. last 2 hours or between 10-12 today? cheers! updated 23 oct 2011 - commands needed: get entries within last x hours [here 2 hours] awk -vdate=`date -d'now-2 hours' +[%d/%b/%y:%h:%m:%s` ' { if ($4 > date) print date fs $4}' access.log get active ips within last x hours [here 2 hours] awk -vdate=`date -d'now-2 hours' +[%d/%b/%y:%h:%m:%s` ' { if ($4 > date) print $1}' access.log | sort |uniq -c |sort -n | tail get entries within relative...

android - Problem loading some dynamic png image, BitmapFactory.decodeStream retuns null -

i have listview contains image , textview, used lazy image loader code found net. problem while using bitmapfactory.decodestream gives null png images. sample link of these in getting null below image1 image2 here code using. works fine jpg image didnt work png. tried bypass scalling part still didnt work. package com.sensacionalista.api; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.inputstream; import java.io.outputstream; import java.net.url; import java.util.hashmap; import java.util.stack; import android.app.activity; import android.content.context; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.widget.imageview; import com.sensacionalista.r; public class imageloader { //the simplest in-memory cache implementation. should replaced softreference or bitmapoptions.inpurgeable(since 1.6) private hashmap<string, bitmap> cache=...

java - Re-Sizing of an image? -

how retain resolution of image while reducing or expanding... there way... you shoould check here, same problem exists: http://forums.oracle.com/forums/thread.jspa?threadid=1270008 solution offered there: tiffencodeparam tep = new tiffencodeparam(); // create {x,y}resolution fields. tifffield fieldxres = new tifffield(0x11a, tifffield.tiff_rational, 1, new long[][] {{dpi_x, 1}}); tifffield fieldyres = new tifffield(0x11b, tifffield.tiff_rational, 1, new long[][] {{dpi_y, 1}}); tep.setextrafields(new tifffield[] {fieldxres, fieldyres});

javascript - JQuery live + Disqus / Google Analytics -

i'm using following function overload website url links ajax: $(document).ready(function() { $('.insite').live("click", function(ev) { if ( history.pushstate ) history.pushstate( {}, document.title, $(this).attr('href')); ev.preventdefault(); $('#content').fadeout().load($(this).attr('href')+' #content', function() { $(this).fadein(); }); }); }); i know if it's possible integrate google analytics tracking , disqus loading function. code have tried load disqus loads comments websites reasons: window.disqus_no_style = true; $.getscript("http://disqus.com/forums/mnml/embed.js") thanks you can put google analytics function directly in event call, placing new virtual url in second parameter. $(document).ready(function() { $('.insite').live("click", function(ev) { var href = $(this).attr('href'); if (...

How to open a text file in default view on button click in android -

i want users read instruction use android application text or pdf file when click instruction button. how should read text/pdf file on button click in default view in android? likely best way launch intent action_view action , provide file desire. intent intent = new intent(intent.action_view, uri.fromfile(file)); intent.settype("application/pdf"); startactivity(intent); note dependent on there being application on device registered handle pdf mime type. can choose have text or perhaps rich text instead changing type.

@Schedule annotation in Java EE -

i use following annotation call stateless session bean once 5 minutes: @schedule(second = "0", minute = "0/5", hour = "*") i works expected, except stops after few days. guess there may default lifetime , not know how override it. please me configure scheduler run indefinitely. to know if there expiration date object can use gettimers() return object of timer use method gettimeremaining() know if there expiration date it. anyway, can use annotation @timeout in case of timeout happens : @timeout public void timeout(timer timer) { system.out.println("do ... "); } you can print date here know when timeout happens.. another thing using "automatic timers" , it's configured @ ejb-jar.xml try take @ ejb-jar.xml see if there expiration date there ..

mysql - redesigning my database -

on old web app had table following structure: tools(id, name, abbreviation, width, height, power, type) the thing need add history support tools. working scenario details of each tool can modified, , need keep track of changes. example, if need see details of tool date past, how can that? how database have looks? i keep same table, add dateeffective field, , create new row every time tool changes. when querying table, can version of tool @ given date using: select * tools id=@id , dateeffective<@thisdate order dateeffective desc limit (0,1) edit may wish create field called toolversionid primary key. edit 2 in response comment, how about: select * tools t1 toolversionid in (select toolversionid tools t2 t2.id = t1.id order t2.dateeffective desc limit (0,1) );

why I can't use code files from app_code in my code asp.net c# -

i working on asp.net web app, , have few classes in app_code, reason can't use of them in code. tried using same namespace, tried without namespace in both files, nothing helps. this page code: using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using linkedin; using linkedin.serviceentities; namespace authentication { public partial class linkedinmoreinfo : linkedinbasepage { protected void page_load(object sender, eventargs e) { } } } and code in class: using system; using system.data; using system.configuration; using system.linq; using system.web; using system.web.security; using system.web.ui; using system.web.ui.htmlcontrols; using system.web.ui.webcontrols; using system.xml.linq; using linkedin; namespace authorisation { public class linkedinbasepage : system.web.ui.page { private string accesstoken { ...

data structures - Designing a web crawler -

i have come across interview question "if designing web crawler, how avoid getting infinite loops? " , trying answer it. how begin beginning. google started hub pages hundreds of them (how these hub pages found in first place different sub-question). google follows links page , on, keep making hash table make sure doesn't follow earlier visited pages. what if same page has 2 names (urls) in these days when have url shorteners etc.. i have taken google example. though google doesn't leak how web crawler algorithms , page ranking etc work, guesses? if want detailed answer take @ section 3.8 paper , describes url-seen test of modern scraper: in course of extracting links, web crawler encounter multiple links same document. avoid downloading , processing document multiple times, url-seen test must performed on each extracted link before adding url frontier. (an alternative design instead perform url-seen test when url removed fro...

regex - Need clarification on preg_match in PHP -

i'm kinda of new php, can please clarify below preg_match. preg_match("/^(9)\1+$/",$value); it match string consists of 2 or more 9 s. the regex weird, , not typical of intention imo. i'd write as... /^9{2,}\z/

git - Remove local branches no longer on remote -

is there simple way delete local branches not have remote equivalent? example: branches (local , remote) master origin/master origin/bug-fix-a origin/bug-fix-b origin/bug-fix-c locally, have master branch. need work on bug-fix-a , check out, work on it, , push changes remote. next same bug-fix-b . branches (local , remote) master bug-fix-a bug-fix-b origin/master origin/bug-fix-a origin/bug-fix-b origin/bug-fix-c now have local branches master , bug-fix-a , bug-fix-b . master branch maintainer merge changes master , delete branches has merged. so current state now: branches (local , remote) master bug-fix-a bug-fix-b origin/master origin/bug-fix-c now call command delete branches (in case bug-fix-a , bug-fix-b ), no longer represented in remote repository. it existing command git remote prune origin , more git local prune origin . git remote prune origin prunes tracking branches not on remote. git branch --merged lists branc...

How can I use PHP as a programming language? -

i heard php can used without web server, , executes c++ or java. how can that? program use? that's php cli. command line usage. here's need http://php.net/manual/en/features.commandline.php if you're on windows run file : php.exe -f myfile.php

ios - is "Turn Off Airplane Mode" alert deprecated? -

i think read somewhere deprecated? , alternatives? i'm talking boolean in info.plist says: sbusesnetwork = yes. the alert shown says: turn off airplane mode or use wi-fi access data it has neat "settings" button takes settings app. i'm aware of reachability sample code apple great. don't know how programmatically show alert or similar alert, can take settings app. you can use flag "application uses wi-fi" instead have message settings button plane mode. on ipad message shown if plane mode turn on (no message if wi-fi turn off). on iphone message shown in both cases - when plane mode turn on or when wi-fi turn off. updated: ios5 can open settings directly: [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"prefs://"]]; update: url above works in ios 5.0

c# - Access inherited class in a web service -

i have web service project contains 3 classes: 1 abstract public class (baseclass.cs) and 2 public classes inherit (inheritedclassa.cs , inheritedclassb.cs) in project (test.csproj), added web reference above mentioned web service, , named dal. when i'm trying access example "baseclass" test project, write test.dal.baseclass, , recognizes it. when try same thing access of inherited classes (inheritedclassa , inheritedclassb) test project doesn't work. you need tell service use classes inheritedclassa , inheritedclassb either returning instances of classes in methods, or use xmlinclude include unused classes in reference. make sure update web reference after make of these changes.

WPF library similar to jQuery UI? -

Image
are there wpf libraries similar jquery ui ? i sortable interaction: and resizable interaction: would great if these 2 interactions combined. thanks. the panels expander in wpf world, far can see. make them "sortable" need create custom panel works wrap panel , hosts expanders, , add drag , drop functionality. shouldn't hard do, haven't seen 1 around (at least in free / open-source components).

c++ - Defining a Template Member of a Template Class separately from the Declaration -

#include <cstdlib> template<class a> struct foo { template<class b> static bool bar(); }; template<class b> template<class a> bool foo<a>::bar<b>() { return true; } int main() { bool b = foo<int>::bar<long>(); b; } this results in linker error: main.obj : error lnk2019: unresolved external symbol "public: static bool __cdecl foo<int>::bar<long>(void)" (??$bar@j@?$foo@h@@sa_nxz) referenced in function main i need define member function outside of class template's declaration. in other words, cannot this: #include <cstdlib> template<class a> struct foo { template<class b> static bool bar() { return true; } }; int main() { bool b = foo<int>::bar<long>(); b; } what missing? how can define member function template? what's needed syntax? note: using msvc 2008, in case that's relevant. edit the first thin...

xpand - How to configure Xtext mwe.Reader to fill the root element in a slot -

i using xtext 2.0 mwe 1 , xpand, guess problem mwe 2 , xtend same. my xtext grammer looks (excerpt): grammer org.test.test org.eclipse.xtext.common.terminals generate test "http://www.test.org/test/test model : "common stuff" "{" (formatterdefs+=formatterdef)* "}" ... formatterdef : "formatter" name=id ":" formatter=string; when use mwe definiton (excerpt): <component class="org.eclipse.xtext.mwe.reader" path="${project.src.directory}/xtext/model/" > <register class="org.test.teststandalonesetup"/> <load slot='formatterdefs' type='formatterdef'/> </component> <component class="org.eclipse.xpand2.generator"> <metamodel class="org.eclipse.xtend.typesystem.emf.emfregistrymetamodel"/> <expand value="templates::formatter::formattertxt foreach formatterdefs...

makefile - Update a target when a passed variable changes -

my makefile: ifndef vec_len vec_len = 1 endif my_target: a.c gcc a.c -dvec_len=$(vec_len) is there way tell make my_target should updated when vec_len changes ? update: my scripts (and work): makefile shell := /bin/bash # define answer if not defined yet answertolifetheuniverseandeverything ?= 42 # update header file if answer has changed # := executes shell command, = not! quote http://www.gnu.org/software/make/manual/make.html: # immediate = deferred # immediate := immediate dummy := $(shell ./updateanswer.sh $(answertolifetheuniverseandeverything) >logmakefile.txt) answer : answer.h echo "updated!" touch answer updateanswer.sh #!/bin/bash # check if definition of answer has changed in header file # if yes, re-write it. if not, not touch avoid updated timestamp. if grep -q "answer ${1}" answer.h echo "answer unchanged, still ${1}." else echo "#define answer ${1}" >answer.h...

html - Cannot change Background Color ONLY with CSS -

good morning, i'm trying change background color on link when user hovers on it. current code, link color change expected, no change background color. if attach pseudo-class different tag, "span", works should. naturally suspect "a" tag blame, can't figure out @ all. been staring @ thing since last night. markup: <div id="thumbaboutwrap"> <h4 class="contact">adam [at] layeredfeedback [dot] com</h4> <a class="contact" href="#"><h4>facebook</h4></a> <a class="contact" href="#"><h4>last.fm</h4></a> <a class="contact" href="#"><h4>linkedin</h4><a/> </div><!--thumbaboutwrap--> css: a.contact { font-size:50px; font-weight:800; } a.contact:hover { background-color:#000; color:#fff; } i'm using meyer's reset if makes dif...

javascript - Avoiding var _this = this; when writing jQuery event handlers -

not important question, here go.. how avoid using var _this = in jquery event handlers? i.e. don't doing: var _this = this; $(el).click(function (event) { //use _this access object , $(this) access dom element }); the following 2 ways not ideal $(el).click($.proxy(function (event) { //lost access correct dom element, i.e. event.target not enough (see http://jsfiddle.net/ne3n3/1/) }, this)); $(el).click({_this: this}, function (event) { //have access $(this) , event.data._this, seems verbose }) ideally like $(el).click(function (event) { this.method(); // accessing object event.realtarget; // accessing dom element }, this); // <= notice http://api.jquery.com/event.currenttarget/ says: "this property typically equal of function." http://jsfiddle.net/ne3n3/2/

css - Firefox 4 not rendering a:visited::before (except color) -

i'm making custom stylesheet particular web site in firefox 4. in it, i'm trying prefix red 'x's links i've visited. now, when making, mean used work while ago, , @ point, these 'x's stopped appearing (though rest of stylesheet works fine). now, a:before (and a::before, per css3) works fine. a:visited works fine. neither a:visited:before nor a:visited::before works @ (well, almost). during play-testing, left in a::before, , still had a:visited::before declaration use red 'x's. non-visited links, a::before content same text color, visited links, ::before content 'right' color (red). here pastebin of css @ 1 point: http://pastebin.com/6tzy1q87 and here screencap of css resulted in: http://i.stack.imgur.com/rtw9l.png notice a::before specifies content checkmark. a:visited::before should change weight, color, , content, changes color. i heard recent security 'feature' regarding firefox , page history, understood it, affect...

asp.net mvc - Ideal Folder Structure in MVC 3 -

Image
i started new mvc3 application.i using ef fro data base access .i have doubts folder structure . here attaching solution explorer picture application i created 3 folders in models folder 1.view models - contains view modes use display informations 2.domain model - using entity framework .so put edmx files , related files . 3 . businness logic - here write service function .say if want add new ad, create object of adsservices class , call function in class controller . thiese functions use entity frame work access database . question 1.is folder structure ideal folder structure? if not, please tell suggestion. 2.is idea creating entity data model each module in application ? (eg:ads,categories) note : application average sized appilcation .just not big. 1.is folder structure ideal folder structure? there no ideal structure. structure depends on type of application, size, development methodology. better create project hold domain entities , servi...

sql server 2008 - SQL View, replace a NULL Value -

Image
in sql have datefield thats showing current month data. of dates null , replace null date somethng fn now() date somehow. can guide me updating nulls in query? im using ms sql 2008 r2. select top (100) percent dbo.[001_subitem_price].subitem, { fn now() } date, dbo.potable.date datefield dbo.[001_subitem_price] left outer join dbo.potable on dbo.[001_subitem_price].subitem = dbo.potable.item (month(dbo.potable.date) = month(getdate())) or (month(dbo.potable.date) null) group dbo.[001_subitem_price].subitem, dbo.potable.date order dbo.[001_subitem_price].subitem just use: ...coalesce(datefield, getdate()) datefield

javascript - jQuery show&hide menu basics -

i'm trying make doble menu, click function , hide&show basics, don't understand why not working, can me out? here script: $(document).ready(function() { $('#work').click(function(event){ $(this).addclass("activado"); // add active class $("#other,#contacto").removeclass("activado"); // remove active class $("#menuother").hide(); $("#menuwork").show(); }); $('#other').click(function(event){ $(this).addclass("activado"); $("#work,#contacto").removeclass("activado"); $("#menuwork").hide(); $("#menuother").show(); }); $('#contacto').click(function(event){ $(this).addclass("activado"); $("#work,#other").removeclass("activado"); $("#menuwork").hide(); }); }); and html basic, don't think need it, script speaks self. active class working, hide & show not. t...

c# - Searching on an array of integers -

i've got string coming in so: '202,203,204,205,226,230,274' i want break string down array of numbers , records ids. so far, have: string[] myarray = mystring.split(','); int[] myintarray = new int[myarray.length]; for(int x = 0; x < myarray.length; x++) { myintarray[x] = convert.toint32(myarray[x].tostring()); } model.records = db.records .where(q => q.recordid.contains(myintarray) .tolist(); it's complaining contains not working ints. confused contains does? thanks in advance! i think want do: .where(q => myintarray.contains(q.recorid)) the way have it, you're expecting recordid array (i'm assuming it's int ?), whereas think want take single recordid , see if it in array of int s.

Is there a way to color selected cells of an Excel file using C#? -

i comparing 2 excel files cell cell. 1 source file , target file.i want color cells not matching in target file. there way without creating other excel sheet cells not matching. mean want fill color in cells not matching in target file.. oresizerange range of cells selected. it's of type office.interop.excel.range oresizerange.interior.colorindex = someindex; source

How to set rowspan using PHPExcel library for pdf with table? -

i want generate pdf file report table. need set rowspan. how can this? if mean need merge cells in phpexcel, then $objphpexcel->getactivesheet()->mergecells('a1:a3');

How to iterate a C++ map of maps -

i have map of map std::map< int, std::map<string, double> > mymap; std::map< int, std::map<string, double> >::iterator itr; iterating with: itr = mymap.find(nodei); if (itr == mymap.end()) { exit(1) ; } results in error: error: no match âoperator=â in âitr = ((const pushlist*)this)->pushlist::mymap.std::map&lt:_key, _tp, _compare, _alloc>::find [with _key = int, _tp = std::map&lt:std::basic_string&lt:char, std::char_traits&lt:char>, std::allocator&lt:char> >, double, std::less&lt:std::basic_string&lt:char, std::char_traits&lt:char>, std::allocator&lt:char> > >, std::allocator&lt:std::pair&lt:const std::basic_string&lt:char, std::char_traits&lt:char>, std::allocator&lt:char> >, double> > >, _compare = std::less&lt:int>, _alloc = std::allocator&lt:std::pair&lt:const int, ...

Creating quiz in flash/actionscript with questions passed through flashvars -

i getting questions database (just text) , passing them flash via flash vars. want 1 question displayed user answer (text) , click button , next question displayed them answer , on. i not hoping overly specific advice new flash/actionscript looking broad advice (or links ?) on how approach this. can 1 frame using actionscript ? edit: think after (assuming not way off track) if questions should handled @ once guess require kind of loop listens buttonclick event move next question ..... or 'reloading' flash movie , dealing 1 question @ time. thanks help. i saw edit, here's how it: //class var private var answerholder:sprite = new sprite(); private function createanswers( answerarray:array ){ if(answerholder.parent){ //makes sure have parent, don't ugly error. answerholder.parent.removechild(answerholder); //removes answerholder, cleans out previous answers } answerholder = new sprite(); //new empty sprite addchild(answerho...

ios - Get the Zip Code of the Current Location - iPhone SDK -

how zip code of current location using mapkit, didn't find api's getting in document. used coordinate,attitue,horizontal,vertical,course , speed parameters of cllocationmanager, failed zip code. could 1 please give me api or sample code done. is possible zip code using current location in iphone? you can use latitude , longitude create mkplacemark object , includes zip code. here sample shows how that.

java - Division of numbers -

i see in timestamp class, constructor goes like: public timestamp(long time) { super((time/1000)*1000); .................... what im not understanding is, need of dividing time 1000 , multiplying again 1000. difference make? isn't piece redundant? that's way of truncating next lower multiple of 1000 milliseconds -- i.e., whole second. it's not best way, it's way.

random - shuffle order of images in php -

i have following images in i'm using carousel. each time page loads want them in in different order. thinking of ordering numbers using random number generator, i'm not sure how make numbers used once. if done in loop it's expandable great. see static code below, images named same except number @ end <div class="image-entry"> <img src="/images/carousel-1.jpg" /> </div> <div class="image-entry"> <img src="/images/carousel-2.jpg" /> </div> <div class="image-entry"> <img src="/images/carousel-3.jpg" /> </div> <div class="image-entry"> <img src="/images/carousel-4.jpg" /> </div> thanks! there function that, shuffle() : $images = array ( '/images/carousel-1.jpg', '/images/carouse...

jquery - ASP.Net MVC 3 ViewModel, unobtrusive JavaScript and custom validation -

i'm trying write custom validation method in app - have working server side, i'm trying extend implements in unobtrusive javascript client side validation. i'm using viewmodel well, added fun. here's have trivial test - it's pretty simple - child object has 3 fields - custom validation i'm writing @ least 1 of fields must filled in (obviously actual app has more complex model this): model: public class child { public int id { get; set; } [musthavefavouritevalidator("favouritepudding", "favouritegame")] public string favouritetoy { get; set; } public string favouritepudding { get; set; } public string favouritegame { get; set; } } viewmodel: public class childviewmodel { public child thechild { get; set; } } controller: public actionresult create() { var childviewmodel = new peopleagegroups.viewmodels.childviewmodel(); return view(childviewmodel); } i've followed docu...

Reading terminal response to bash commands into c++ variable -

does know of way read in terminal output bash commands c++? example, entering "ls" terminal returns file names in current directory, there way perhaps import these names string or char array or something? have been looking @ fork() , exec() , , pipe() . attempting open pipe communication between child (system commands entered here) , parent (output read in here) have been thoroughly unsuccessful. ideas? thanks kerrek sb, had seen people using popen() in various ways wasn't sure if route pursue or not. of documentation , putting parts of how other people using it, came this. question wrote asked specifically: importing terminal response command "ls" vector of file names. however, each file name contains newline character implicitly remove pushing last element of string file vector. void currentdirfiles( vector<string> & filesaddress ) { file * pipe = popen( "ls", "r" ); char buffer[1000]; string fi...

Update multiple rows with different values in a single query - MySQL -

i'm new mysql. i'm using update multiple rows different values, in single query: update categories set order = case id when 1 3 when 2 4 when 3 5 end, title = case id when 1 'new title 1' when 2 'new title 2' when 3 'new title 3' end id in (1,2,3) i using "where" improve performance (without every row in table tested). but if have senario (when don't want update title id 2 , 3): update categories set order = case id when 1 3 when 2 4 when 3 5 end, title = case id when 1 'new title 1' end id in (1,2,3) the above code change title id 2 , 3 "null"... what right way make query, skip updating title id 2 , 3 , still keep performance "where id in" gives ? maybe this update categories set order = case id when 1 3 when 2 4 when 3 5 end, title = case id ...