Posts

Showing posts from March, 2011

c# - Force JSON.NET to include milliseconds when serializing DateTime (even if ms component is zero) -

i'm using json.net serialize datetime values directly object instances (not using datetime.tostring() formatter). is there way force json.net include milliseconds in serialization if millisecond component of datetime zero? background: have slow web service consumer json endpoint. conditional logic expensive consumer, i'd provide same data formatting every time. we ran same issue on current project. using web api (and hence json.net) implement rest api. discovered that, when serializing datetime objects, json.net omits trailing zeros milliseconds, or omits milliseconds date entirely if zero. our clients expecting fixed-length date-time string, 3 digits milliseconds. fixed doing following in application_start() : jsonserializersettings settings = httpconfiguration.formatters.jsonformatter.serializersettings; isodatetimeconverter dateconverter = new isodatetimeconverter { datetimeformat = "yyyy'-'mm'-'dd't'hh':'mm&

streaming - What Java technology use to capture and modify video stream on the fly -

i have write application capture video , audio external camera , change video stream on fly. able find, xuggler awesome java wrapper on c code, doesn't support camera , worst, project seems closed time. some examples web using old , deprecated api camera stream.and post here on stackoverflow says should forget using xuggler capture camera. is there can advice me java technology can capture video , make operation on decoded video ? have combine more 1 stream 1 , add animations on or kind of blue box ( if 1 possible) , return in real time show on wall. i'm pretty new in video streaming :) technologies should ? maybe xuggler work on stream , other api capture ? opencv best video/image processing library there is. you have 2 options using it, javacv (a wrapper non-opencv guys made) or use opencv's own java api (which calls native code, too) (not complete, they're working on , there's lot of stuff already). it's here: http://opencv.org/ edit:

Where can I find an easy reference for http headers? -

i'm looking reference possible http request , response headers part of http specification. want know syntactically acceptable in terms header names , header values. i'm sure it's defined in http specification, it's bit dense me read quickly. suggestions? , if answer @ http specification, approach suggest in reading , understanding quickly? thanks! the best reference actual http 1.1 specification . it's not difficult understand once it. @ least, through table of contents understand structure, can jump straight sections interest you. sections reference 1 another, need jump different section (or document) understand reading. section 14, header field definitions , explains standard header fields. section 4.2, message headers , specifies format of header. to understand 4.2, might need refer section 2 . look @ these also: http://en.wikipedia.org/wiki/list_of_http_header_fields the iana registry of message headers (contains headers used other

Paypal credit card refund failing when currency is set to GBP -

i've implemented paypal credit card payment xml api, using wsdls provided. appears work great if currency usd. initial transactions approved , refunds both partial , full succeed well. however, have issues when switch usd gbp. gbp credit card authorization request succeeds when try perform refund error code of 10009 "you cannot refund type of transaction". same code being executed usd , gbp difference between requests currency code being set on amount , i'm @ loss why usd refund requests succeed usd payments gbp refunds fail gbp payments. appreciated. thanks if log paypal merchant account (or sandbox) find original payment has not been accepted. happens if account not yet hold funds in currency of payment. at least, happening me. once payment has been accepted should refund fine. , if accept creating balance in gbp, future payments accepted automatically.

javascript - Creating a table with results of two findall calls using Rally SDK 1.33 -

i recreate rally's iteration summary app. therefore, able display information defects, iterations, etc... in 1 ui component. currently, have 2 tables (one displaying results of findall defects, 1 displaying results of findall iterations). way have 1 findall results both of these? or there way access results of multiple findall calls in 1 rally ui component (meaning 1 table able display results of findall(s) iterations , associated defects)? thank you here full example of appsdk 1.33 app makes 2 queries, , builds single table of 2 different artifacts, defects , stories based on selection in iteration dropdown: user stories iteration example <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.33/sdk.js"></script> <script type="text/javascript"> rallydatasource = null; iterdropdown = null; function showtable(results) { (var i=0; < results.stories.length; i++) {

php - MySQL query not updating -

using code: $sql = mysql_query("update tablename set auth = '$new_auth' index = '$index'"); i printed out variables. it's working correctly, it's not updating auth or playing around code it'll update first result when i'm having issues queries use or die() trouble shooting. try updating code following: $sql = mysql_query("update tablename set auth = $new_auth index = $index") or die(mysql_error()); this kick error involving query , give better understanding of problem is.

copy - Check if a folder exist and rename in vbscript -

okay here want do. script copies folder appdata folder on computer here need do. need check if folder of name exists , if rename else copy folder here current script need modify check if folder excists. thanx in advance set oshell = createobject("wscript.shell") strhomefolder = oshell.expandenvironmentstrings("%appdata%") set oshell = createobject("wscript.shell") set ofso = createobject("scripting.filesystemobject") oshell.currentdirectory = ofso.getparentfoldername(wscript.scriptfullname) destinationfolder = strhomefolder & "\vlc" sourcefolder = oshell.currentdirectory & "\vlc" dim filesys set filesys=createobject("scripting.filesystemobject") if filesys.folderexists(sourcefolder ) filesys.copyfolder sourcefolder , destinationfolder end if you detect whether destination folder exists same way detect whether source folder exists: if filesys.folderexists(destinationfolder) 'do s

C Base128 Function -

what c function use encode/decode number in leb128 format? not find simple documentation or examples. it might interest readers why leb128 useful. provides kind of compression representing numbers if of time magnitude of numbers relatively small. on random input, on average use 5 out of 8 bytes represent 64 bit number (although worst case, use 10 bytes). below implementations encode , decode unsigned 64 bit numbers. i'll leave signed version exercise interested reader. size_t fwrite_uleb128 (file *out, uint64_t x) { unsigned char buf[10]; size_t bytes = 0; { buf[bytes] = x & 0x7fu; if (x >>= 7) buf[bytes] |= 0x80u; ++bytes; } while (x); return fwrite(buf, bytes, 1, out); } size_t fread_uleb128 (file *in, uint64_t *x) { unsigned char buf; size_t bytes = 0; while (fread(&buf, 1, 1, in)) { if (bytes == 0) *x = 0; *x |= (buf & 0x7full) << (7 * bytes++); if (!(buf

ruby on rails - Allow method to accept an :id param -

i have created method called verify in controller (events_controller.rb), , want allow page (verify.html.erb) accept object (@event), , show of objects parameters. i'm creating show page in essence, need build special logic page don't want build show page. have created route, still error when tell find event params[:id]. actual url going /verify.(event :id) , believe should routing events/verify/(event :id). my error couldn't find event without id. routes.rb get "verify", to: 'events#verify' resources :events events_controller.rb def verify @event = event.find(params[:id]) respond_to |format| format.html # verify.html.erb format.json { render json: @event } end end thanks stack! get "verify/:id", to: 'events#verify', as: "verify" in browser go url example: localhost:3000/verify/1

c# - Make .NET WebBrowser not to share cookies with IE or other Instances -

since webbrowser in c# shares cookies other instances of webbrowsers including ie webbrowser have it's own cookie container doesn't share cookies created in ie or other instances. so example when create webbrowser shouldn't have cookies. , when run 2 instances of webbrowsers have own cookie container , don't share or conflict cookies each other. how can achieve ? you per process using internetsetoption win32 function: [dllimport("wininet.dll", charset = system.runtime.interopservices.charset.auto, setlasterror = true)] public static extern bool internetsetoption(int hinternet, int dwoption, intptr lpbuffer, int dwbufferlength); and @ application startup call following function: private unsafe void suppresswininetbehavior() { /* source: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385328%28v=vs.85%29.aspx * internet_option_suppress_behavior (81): * general purpose option used suppress behaviors on process-w

groovy - What means ?. in Java? -

this question has answer here: null-safe method invocation java7 3 answers i've got such piece of code: private string getusername(personalaccount account) { user usr = (user)account?.usr string name = usr?.getname() return name } and in personalaccount class we've got field: simpleuser usr user extends simpleuser what means this: ?. in 2 lines? user usr = (user)account?.usr string name = usr?.getname() that's not java, that's groovy. if java you'd have semicolons ending each statement. the method returns name of user on account passed in, or null if account null or if user null. it uses the safe-navigation operator . safe-navigation operator evaluates null if operand null, otherwise evaluates result of method call. way, if have method call on might null, don't have worry getting nullpointerexception.

android - AsyncTask implementation issues -

can me implementing asynktask code? i´m new android , don´t know how structure code public class displayactivity extends listactivity { private final string tag="links"; private arrayadapter<string> madapter = null; arraylist<string> listitems=new arraylist<string>(); arrayadapter<string> adapter; string sites[]={"http://www.dn.pt/inicio", "http://www.expresso.sapo.pt","http://www.publico.pt/?fullsite=true"}; @suppresslint( "newapi") @override protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.activity_display); // make sure we're running on honeycomb or higher use actionbar apis //if (build.version.sdk_int >= build.version_codes.honeycomb) { // show button in action bar. // getactionbar().setdisplayhomeasupenabled(true); //} final intent intent = getintent(); final string url_link =i

ef code first - Entity Framework Inheritance share database fields -

so, using entity framework code first. model: public class stockmove { public int id { get; set; } public int productid { get; set; } public virtual product product { get; set; } } public class stockmoveout : stockmove { public int customerid { get; set; } public virtual customer customer { get; set; } public int originlocalid { get; set; } public virtual local originlocal { get; set; } } public class stockmovein : stockmove { public int supplierid { get; set; } public virtual supplier supplier { get; set; } public int destinationlocalid { get; set; } public virtual local destinationlocal { get; set; } } public class stockmovetransfer : stockmove { public int originlocalid { get; set; } //should same stockmoveout public virtual local originlocal { get; set; } public int destinationlocalid { get; set; } //should same stockmovein public virtual local destinationlocal { get; set; } } public class datacontext : dbcon

php - Query return and empty array -

the following script: <?php try { $db = new pdo("sqlite:./path/phrases"); $result = $db->query('select * phrases'); foreach($result $row){ $row['phrase']; $row['score']; } } catch(pdoexception $e) { echo $e->getmessage(); } ?> is returning: warning: invalid argument supplied foreach() in myscript.php on line 5 if execute: select * phrases; in sql browser, long list of results, regard columns phrase , score. doing wrong? there 2 examples in answer. the first example found @ http://juanmanuelllona.blogspot.ca/ am providing hope solution. 1) try { $db = new pdo("sqlite:./path/phrases"); echo 'database open'; $sql = "select * phrases"; $obj= $db->query($sql) ; foreach ($obj $row) { print('phrase ='.$row['phrase'].' course='.$row['score']. '&ltbr/>'); // or <br/> } } catch(pdoexception $e) {

python - Find unique columns and column membership -

i went through these threads: find unique rows in numpy.array removing duplicates in each row of numpy array pandas: unique dataframe and discuss several methods computing matrix unique rows , columns. however, solutions bit convoluted, @ least untrained eye. here example top solution first thread, (correct me if wrong) believe safest , fastest: np.unique(a.view(np.dtype((np.void, a.dtype.itemsize*a.shape[1])))).view(a.dtype).reshape(-1, a.shape[1]) either way, above solution returns matrix of unique rows. looking along original functionality of np.unique u, indices = np.unique(a, return_inverse=true) which returns, not list of unique entries, membership of each item each unique entry found, how can columns? here example of looking for: array([[0, 2, 0, 2, 2, 0, 2, 1, 1, 2], [0, 1, 0, 1, 1, 1, 2, 2, 2, 2]]) we have: u = array([0,1,2,3,4]) indices = array([0,1,0,1,1,3,4,4,3]) where different values in u represent set of unique columns in or

cocoa touch - Cancel ccTouch on State Change in Cocos2d-iPhone -

could please with issue having canceling touch event when character dies. have character controller (touch sprite , drag left/right move) based on screen x-axis. controller class subclass of ccnode , has required methods register touch touchdispatcher. cctouchbegin, cctouchmove & cctouchend works fine, while cctouchmove in action , character dies want reset controller, player position start location on screen not trigger until lift finger(thus cctouchend) triggers reset player/controller in gamelayer(cclayer) fires. i thought adding cctouchcancel method trick not getting fired. each of touch event methods first checks controller's state (idle, active, stop) before doing actions. have update method handle dragging checks controller.state == active before allowing player drag/move character. in gamelayer's update method when character dies, set controller.state = stop. in controller's update method stop state, call [[[ccdirector shareddirector] touchdispatcher] re

jquery - iOS app not rendering correctly on Android 4.3 -

i build ios app using cordova , renders expected on ios device. i'm using same framework jquery android version , when run android simulator renders different. can see screen shots. first android app i'm not sure if should coding differently. thoughts or suggestions welcome. thanks. https://www.dropbox.com/s/daigevqmmhwttdc/ios.png https://www.dropbox.com/s/b9p9ewqee68ty8b/android.png it's impossible have same behavior on devices html.

In Project Euler 47, why is 2^2 considered a prime number distinct from 2? -

how code reflect that? should have consider number 4 prime? project euler: problem 47 the first 3 consecutive numbers have 3 distinct prime factors are: 644 = 2² × 7 × 23 645 = 3 × 5 × 43 646 = 2 × 17 × 19. if factorize 644 2 × 2 × 7 × 23. 644 has 4 prime factors, 3 distinct prime factors.

c - gdb cannot print the contents of array -

i try print contents of array this, , it's successful: p/x t->arr $1 = {0x63, 0x61, 0x74, 0x31, 0x2e, 0x6a, 0x70, 0x67, 0x0 <repeats 248 times>} however, when try different way this: (gdb) p &t->arr $2 = (char (*)[256]) 0x60c4d0 p/100x *0x60c4d0 item count other 1 meaningless in "print" command. t->arr defined arr[256] in struct. do wrong? in gdb , can cast literal pointer value whatever type think appropriate. so, if want treat address pointer array, can cast such, , print that. (gdb) p argv $1 = (char **) 0x7fffffffe898 (gdb) p *(char *(*)[2])0x7fffffffe898 $2 = {0x7fffffffeae1 "/tmp/a.out", 0x0}

Rspec + Rails: table_name_prefix not loaded for module -

when run rspec on specific file: rspec spec/models/my_namespace/my_model_spec.rb i run error because rspec appears not load app/models/my_namespace.rb, contains declaration of self.table_name_prefix . in fact, if use pry , run mynamepsace.table_name_prefix # => nomethoderror: undefined method ``table_name_prefix' . when try query db rails console (no rspec), works, though: mynamespace::mymodel.where(foo:'bar') # => [...] any idea problem or fix is? rails 3.2.14, ruby 1.9.3, debian at top of spec file: require_relative '../../../app/models/my_namespace' this load namespace file specifies table prefix.

php - Ensure field in database record is required -

how can ensure field in table required? for example: have posts table , users table. when post saved requires user_id field. where if did this: $post = new post; $posttext = "test post one"; $post->text = $posttext; $post->save(); i error because there no user_id field. instead need this: $post = new post; $posttext = "test post one"; $post->text = $posttext; $post->user_id = 1; $post->save(); is done by overriding save() method of post class? hooking model events? there several ways this, i'm giving basic using if statement. since fields predefined, can check if fields has corresponding value. can use: if($post->text == "" || $post->text == null){ something... } or yes can touch model , check there. thanks

javascript - How does AngularJS update the DOM? -

specifically, i'm wondering how update elements without using innerhtml. in docs, state how they're better other templating engines because don't re-render innerhtml (ctrl-f innerhtml -- sorry). started poking through source code there's lot of , hoping perhaps faster answer guys. so far guesses have been the compiler converts {{test}} <ng-bind>test</ng-bind> linker can update when data changes, doesn't seem happening when @ dom of rendered angular page. , seems interfere client's css , other javascript components external angular. they using innerhtml they're not re-rendering entire dom -- small snippet of (perhaps data inside sort of custom <ng-bind></ng-bind> tag). they're somehow removing , appending new elements ... bad guess think. if knows i'd love learn. otherwise it's source code me. edit new guess after thinking more, believe might happens: compiler swallows html, <p> {{model}

vba - Importing text files to xlsm, then overwriting sheetname if already exsits -

after hours of failed googled vb scripts, thought i'd come here. currently have modified vba script imports multiple txt files, , copies them new sheets in xlsm file, according txt file name. i want 2 things, {solved} answers on google don't seem working me. 1) overwrite existing sheet if exists --- (nb: not delete it... linked sheet calculations), and 2) import text file in space delimited format --- again, solved answers not playing game. thanks (ps -- there several similar questions here, have similar solved answers question, seem more convoluted... i'm after simple possible) sub getsheets() path = "c:\test\" filename = dir(path & "*.txt") while filename <> "" workbooks.open filename:=path & filename, readonly:=true each sheet in activeworkbook.sheets sheet.copy after:=thisworkbook.sheets(1) next sheet workbooks(filename).close filename = dir() loop end sub i faced same problem while ago, similar constr

grep - is there a way to restrict the find to only *.py files -

i have following find command..is there way restrict find *.py files? find . | xargs grep 'git' -sl thanks, you using find , it's simple. here's 1 way: find . -name '*.py' -print | xargs grep 'git' -sl {}

sql server 2008 r2 - Convert nvarchar to date in query -

i have date value in string below how can query against date. how need query evtdate nvarchar , has date value 2013-07-18 06:30:30.843000000 declare @yesterday datetime - dateadd(day,diff(day,1,getdate(),0) select count(*) tbl1 evtdate >= dateadd(hour,10,@yesterday) or select count(*) tbl1 evtdate >- dateadd(day,'20010102',getdate()-2),'2001-01-01t10:00:00') i assume in question want count rows in 24-hour period, starting 10 yesterday, (but not including) 10 today. declare @yesterday datetime = dateadd(day, datediff(day,1,getdate()),0); select count(*) dbo.tbl1 convert(datetime, evtdate) >= dateadd(hour, 10, @yesterday) , convert(datetime, evtdate) < dateadd(hour, 34, @yesterday); i recommend change evtdate nvarchar datetime (and consider indexing if query pattern common). column has absolutely no business whatsoever being nvarchar - varchar bad enough, nvarchar not losing built-in validation , date/time methods, you're

html - YouTube iframe, browser looks for file locally -

i have problem building html pages on local machine , trying embed youtube video page using provided code: <iframe width="560" height="315" src="//www.youtube.com/embed/objwlxlrowc" frameborder="0" allowfullscreen></iframe> however when test page locally file not found c:\desktop\testsite\ http://www.youtube.com ...., etc anyone know why happening, don't believe have encountered before. browsers used latest ff , latest chrome, both show file not found. have checked code , nothing seems wrong, can show local content (same directory) in iframe no problem. tested other external sites/resources , same issue. thanks add http: start of src: <iframe width="560" height="315" src="http://www.youtube.com/embed/objwlxlrowc" frameborder="0" allowfullscreen></iframe>

web scraping - New to PHP, trying to extract information from another website -

<?php $content = file_get_contents('http://na.lolesports.com/season3/split2/schedule'); preg_match('<time datetime="(.*)"', $content, $match); $match = $match[1]; echo "$match"; ?> i'm trying use dates , times of matches, page takes forever , comes blank. as joão rafael pointed out, there missing > between " , ' in <time datetime="(.*)" reformatted code: <?php $content = file_get_contents('http://na.lolesports.com/season3/split2/schedule'); preg_match('<time datetime="(.*)">', $content, $match); $match = $match[1]; echo "$match"; ?>

internet explorer - IE9 and below starts to slow down and hang when adding lots of google map markers via Symbol (SVG path) -

google maps api let's specify custom marker icon in form of svg path. on fast machine, displaying 500 of these markers (svg paths) on ie9 or less causes browser come slow crawl , hang. works fine in chrome, ff, opera, , safari, , ie10 @ higher numbers, not ie9 , below. looking way speed ie. jsfiddle example // cripple ie 9 , below (var = 0; < 500; i++) { new google.maps.marker({ map: map, position: new google.maps.latlng(locations[i].latitude, locations[i].longitude), icon: { path: 'm 5, 5 m -3.75, 0 3.75,3.75 0 1,0 7.5,0 3.75,3.75 0 1,0 -7.5,0', //a small circle fillcolor: 'red', fillopacity: 1, strokecolor: 'blue' } }); } okay i've found way load symbols in ie9 , below without hanging, it's not @ once other browsers. basically, have throttle addition of markers map using settimout . allows ie9 , below browsers continue working user interact

wordpress - KMZ layers are showing on a jQuery gmap3, KML not -

h, i want display kml/kmz attachments wordpress post in 1 single gmap3. page rendering without js errors , kml urls being pulled attachments correctly. kmls not showing, kmz. see here in action: http://dev.felixsalomon.net/wordpress/geo-kml-kmz-bg/ (check source code see 2 different urls) any ideas i'm doing wrong? after more testing got run. seems every kmllayer has added individually so: $the_map.gmap3({ kmllayer:{ options:{ url: "first.url", opts:{} } } }); $the_map.gmap3({ kmllayer:{ options:{ url: "second.url", opts:{} } } }); wheras approach fail: $the_map.gmap3({ kmllayer:{ options:{ url: "first.url", opts:{} } }, kmllayer:{ options:{ url: "second.url", opts:{} } } }); i hope in future!

Why Linux kernel memory subsystem is named slab -

slab of object-caching kernel memory subsystem. why call slab? i have deep search. jeff bonwick's paper, name slab derives 1 of allocator's main data structures, slab. so, why data structure called slab ? a slab , in common usage, refers big flat block of solid material. analogy, slab allocator manages large, contiguous chunks of memory, dividing them smaller pieces allocation.

php - Encrypting a password column in a SQL database -

i have column in database name password, want hash or encrypt password before posting database. have code in php submit file. <?php session_start(); include('config.php'); $id=$_post['id']; $name=$_post['name']; $password=$_post['password']; $department=$_post['department']; $email=$_post['email']; $id_arr=array(); $name_arr=array(); $password_arr=array(); $dept_arr=array(); $email_arr=array(); $i = -1; ++$i; $id_arr[$i]= $_post['id']; $name_arr[$i]= $_post['name']; $password_arr[$i]= $_post['password']; $dept_arr[$i]= $_post['department']; $email_arr[$i]= $_post['email']; $j=0; while ( $j <= $i) { $id = $id_arr[$i]; $name = $name_arr[$i]; $password = $password_arr[$i]; $department = $dept_arr[$i]; $email = $email_arr[$i]; $sql = "insert `employee`. `admin` (id ,name ,password ,department ,email) values ( '$id' ,'$name' ,'$password' ,

Rails 4 Relation#all deprecation -

in app created recent posts feature. @recentposts = post.all(:order => 'created_at desc', :limit => 5) this variable makes trouble. when run tests have following error: deprecation warning: relation#all deprecated. if want eager-load relation, can call #load (e.g. post.where(published: true).load ). if want array of records relation, can call #to_a (e.g. post.where(published: true).to_a ). (called show @ /home/mateusz/rails4/bloggers/app/controllers/users_controller.rb:18) i seraching solution on google don't find it... just write: @recentposts = post.order('created_at desc').limit(5) the to_a not explicitly necessary, data lazy loaded when needed.

What does "__fips_constseg" means in openssl -

in openssl c code, (aes_core.c, set_key.c, spr.h , on) there "__fips_constseg". i don't know "__fips_constseg" means. what's role of it? assembly code? the source code below: #include < openssl/crypto.h > #include "des_locl.h" openssl_implement_global(int,des_check_key,0) /* defaults false */ __fips_constseg static const unsigned char odd_parity[256]={}; from openssl source code: crypto/crypto.h #if defined(openssl_fipscanister) # include <openssl/fipssyms.h> #else # define __fips_constseg #endif fips/fipssyms.h #if defined(_msc_ver) # pragma const_seg("fipsro$b") # pragma const_seg() # define __fips_constseg __declspec(allocate("fipsro$b")) #else # define __fips_constseg #endif the __fips_constseg constant defined value, if openssl_fipscanister defined and the code compiled using microsoft c compiler (which can detected defined _msc_ver constant). then, code mar

java - An interview topic: What can go wrong with this code? -

a simple calculator class that's wired spring bean in web application: public class calculator { int result; public int addtwonumbers(int first, int second) { result = first + second; return result; } } what can potentially go wrong this? multi threading problems. default spring beans singletons.

math - How to Round 46.565 to 46.57 in Java? (no ceiling) -

this question has answer here: how round number n decimal places in java 28 answers i've been using math.round , seemed fine until noticed number ended in "5" wasn't rounded. double roundtotal = math.round(total * 100.0) / 100.0; which rounds 2 decimal places, doesn't round 46.565 46.57 example can help? you this: double roundtotal = ((int)((total*100.0)+0.5)) / 100.0;

XSLT Parsing error when using Umbraco GetMedia -

i trying retrieve url image using getmedia mediapicker. the code below works fine: <xsl:for-each select="umbraco.library:getxmlnodebyid(1123)/* [@isdoc]"> <article> <img width="1822" height="600"> <xsl:attribute name="src"> <xsl:value-of select="umbraco.library:getmedia(1139, 0)/umbracofile" /> </xsl:attribute> </img> <div class="contents"> <h1> <xsl:value-of select="bannerheading1"/> </h1> </div> </article> </xsl:for-each> however, if replace key line this: <xsl:value-of select="umbraco.library:getmedia(bannerimage, 0)/umbracofile" /> i parsing error exception being overflowexception (value either large or small int32), suggests it's not 1139 being passed in. is there way can pass in property want? value of "bannerimag

c - Does Comments/Identifiers can impact on code performance/operability? -

today presented wiered fact (or not) it said: "at disallowed write long, descriptive identifier names, , forbidden write comments linux drivers written in ansi c ." when asked "wtf? why?" told caused performence issues , errors of such... not many details there. i supprised, have ask... can real? knowing comments stripped compilation pre-processor, , identifiers either way converted adresses. so... can cause problems ? well, ansi c standard, , standard must follow (i mean compiler designers , programmers, if decide support it). ansi c standard states exported identifiers (yeah, exported identifiers stored symbols in symbols table is, not addresses) must not longer 6 characters, , non-exported identifiers ok not longer 31 character. on commenting. except obvious pitfalls accidental code swallowing multi-line commenting, recommend read coding style article kernel developers explains kind of comments not encouraged.

javascript - How to validate a currency input -

i creating form, , includes salary, need check if input value salary valid currency , has 2 decimal places because database accepts. if input salary has alphabets (a-z) or symbols (!@#%^&*() except $ or other currency sign) should change border color. example: 10000.00 25846.00 213464.12 code: function isnumeric(){ var numeric = document.getelementbyid("txtsalary").value; var regex = /^\d+(?:\.\d{0,2})$/; if (regex.test(numeric)){ $("#txtsalary").css("border-color","#ffffff"); }else{ $("#txtsalary").css("border-color","#ff0000"); } } this working wanted too, problem got 6 more input boxes needs kind of validation. how can make function, when called change border-color of specific selector , return false value not numeric like: isnumeric(selector); function isnumeric(selector){ var regex = /^\d+(?:\.\d{0,2})$/; $(selector).filter(function() { r

c - segmentation fault (core dumped) Error while calling the mknode function -

define yystype struct node1 * %token int float char double void start: declaration function declaration1 {$$ = mknode($1, $2, $3,null,0);} |declaration function {$$=mknode($1,$2,null,null,0);} | declaration {$$ =mknode($1,null,null,null,0); } | function {$$ =mknode($1,null,null,null,0); } ; declaration1 :function {$$ =mknode($1,null,null,null,null); } ; function: type id '(' arglistopt ')' compoundstmt {$$ = mknode($1,$2,$4,$6,null); } ; type: int {$$ = mknode(null,null,null,null,"int"); } | float {$$ = mknode(null,null,null,null,"float"); } | char {$$ = mknode(null,null,null,null,"char"); } | double {$$ = mknode(null,null,null,null,"double"); } | void {$$ = mknode(null,null,null,null,"void"); } ; compoundstmt: '{' stmtlist '}'

ruby on rails - Is that a proper way to refactor ActiveRecord fat models? -

if example i've activerecord model: app/models/order.rb class order < activerecord::base # model logic end require "lib/someclass.rb" lib/somelass.rb class order before_save :something # more logic here end is way refactor/extract logic model? or maybe use concern class, service class or else? like told me long time ago: code refactoring not matter of randomly moving code around. in example doing: moving code file why bad? by moving code around this, making original class more complicated since logic randomly split several other classes. of course looks better, less code in 1 file visually better that's all. prefer composition inheritance . using mixins asking "cleaning" messy room dumping clutter 6 separate junk drawers , slamming them shut. sure, looks cleaner @ surface, junk drawers make harder identify , implement decompositions , extractions necessary clarify domain model. what should then? you should a

.net - Paragraph between hyperlink and Image URL has been cut off using Image hyperlink pattern -

i have paragraph looks this: first.check out <a href="https://sample.com/applications/documents/solutioncontingency.html" target="_blank">demo </a>to learn solution contingency feature of mme. second paragraph. head out of fog , use solution contingency feature in mme! costs wmu displayed on costs screen in forecast menu. <a href="https://blog.sample.com/mme/files/2013/07/sc2.jpg"><img title="sc2" alt="" src="https://blog.sample.com/mme/files/2013/07/sc2.jpg" width="1262" height="711" /></a> fourth.you should review solution contingency @ least once month. i replaced image url using regex empty string using this: (<a.*?<img.*?>.*?/a>|<img.*?>) do have idea why output cut off hyperlink upto picture. displays first , fourth paragraph. here's output: first.check out fourth.you should review solution contingency @ least once month.

lucene - index unrelated entities in same index with hibernate search -

in our domain model using aggregates quite aggressively, ie don't connect classes through jpa-relations rather use services can query related objects. so, lets have 2 example classes, person , workplace related reference rather direct object-relation. public class person { int id; string name; } public class workplace { int id; string name; list<int> personid; } now build hibernate search index should index fields both person , workplace. possible though hibernate search or have handroll our own lucene-indexer , take care of maintenance hibernate search performs on index ourself? are there other solutions should consider? using hibernate search can make index containing both, or can have 2 indexes 1 each entity query them single index. @indexed @entity public class person { int id; @field string name; } @indexed @entity public class workplace { int id; @field string name; list<int> personid; } you can use index fi

jquery - What is wrong with this code? I am trying to find the width of each items image, if the image is a certain width, apply a class to that item -

$(window).load(function() { $('#grid .item').each(function() { var imageh = $(this).children('img').attr('width'); if(imageh = 506) { $(this).addclass('d'); } else if (imageh = 250) { $(this).addclass('a'); } }); }); the page here - http://stable.dev.pixel-geeks.co.uk/news/ i trying create dynamic grid in wordpress. require system see image size has been uploaded, if image size meets criteria apply class container of image it be if(imageh == 506) { $(this).addclass('d'); } else if (imageh == 250) { $(this).addclass('a'); } you not comparing ,you assigning imageh return true

Java Splitting of strings from text File -

Image
i'm trying split strings text file has tabs in between integers. integer /t integer /t integer. 50 1 2 46 1 15 38 1 16 43 1 21 4 1 25 24 1 35 2 1 43 6 i tried using string token arrayindexoutofboundsexception came out, did debugging myself , found out this. how codes like: public static void main(string[] args) throws filenotfoundexception { scanner input = new scanner(new file("datas.txt")); string data; int = 0; while (input.hasnextline()) { data = input.nextline(); string[] sp = data.split("\\t+"); string n1 = sp[0]; system.out.println("|" + n1 + "|"); } input.close(); } here's picture link of result when compile , run it. edit: no idea why result turns out this. switched bufferedreader , everything's now. people. change code follows public static void main (string []args) throws filenotfoundexception { scann

Cloud9 tries to recreate .settings file -

i've installed cloud9 ide on linux machine in order play around bit (i had use nodejs 0.8 because cloud9 uses package depends on node-waf, no longer supported higher versions of nodejs). i can start without problems, when try access cloud9 via browser, gives me error message: file exists. . here's trace log: error: file exists. @ module.exports.from (/home/xyz/repos/cloud9/node_modules/vfs-local/localfs.js:678:35) @ object.fs.exists [as oncomplete] (fs.js:91:19) relevant code section: exists(topath, function(exists){ if (options.overwrite || !exists) { // rename file fs.rename(frompath, topath, function (err) { if (err) return callback(err); // rename metadata if (options.metadata !== false) { rename(wsmetapath + from, { to: wsmetapath + to,

debugging - Excel VBA: 'excel vba run-time error 1004' application-defined or object-defined error -

i have line in module , keeps spitting run-time error 1004 when try , run it. can help? i'm guessing it's how range referenced, i'm not sure. new me. rngfirst = thisworkbook.worksheets("still in progress").range("g" & 1 & ":g" & lw) many in advance this works me: sub button1_click() dim rngfirst range dim int1 integer int1 = 2 set rngfirst = thisworkbook.worksheets("sheet1").range("g" & 1 & ":g" & int1) rngfirst.select end sub i getting same error until used dim , set.

SQL Server : datetime incorrect results -

using sql server 2008, i have procedure follows: select userid, name, company, languageid, coderegisteredwith, totalloggedinduration, region, isadmin, isrep, isretailer, isteamleader, [dateregistered] roundupacademy.dbo.userprofile with(nolock) (convert(smalldatetime, dateregistered, 120) >= convert(smalldatetime, '2013-1-1', 120) , (convert(smalldatetime, dateregistered, 120) <= convert(smalldatetime, '2013-8-8', 120))) this works fine , shows results between dates. however when expanding on query , more conditions follows: select userid, name, company, languageid, coderegisteredwith, totalloggedinduration, region, isadmin, isrep, isretailer, isteamleader, [dateregistered] roundupacademy.dbo.userprofile with(nolock) userid not null or userid not '' , (@languageid = 0 or ([languageid] = @languageid )) , ((convert(smalldatetime, dateregistered, 120) >= convert(smalldatetime,

web applications - Windows phone web app native date picker -

i working on phonegap web app windows mobile. used date field user input. <input type="date" name="departure" id="text-from" value="" novalidate="true" /> i tried modernizr, $(function() { if (!modernizr.inputtypes['date']) { $('input[type=date]').datepicker(); } }); it working ie 9 browser, not in windows phone simulator. how can show native date picker in windows phone web apps.

sql server - User can delete rows from a table by calling a procedure -

i'm getting confused sql server security we have login , user : test we have table : dbo.tblsessionfilter user test has no select , no delete permission on table (i tested this!!) then have procedure : create procedure dbo.procfilter_clear execute caller delete dbo.tblsessionfilter spid = @@spid user test has execute right on procedure. and now, user test can call procedure , can delete entries table; although has no direct delete access on table, , procedure execute caller ! how possible ? is because procedure , table in same schema? see ownership chains : when multiple database objects access each other sequentially, sequence known chain. although such chains not independently exist, when sql server traverses links in chain, sql server evaluates permissions on constituent objects differently if accessing objects separately. and, when object accessed through chain, sql server first compares owner of object owner of calling

javascript - Phonegap + require Js -

how can use phonegap require js ? try add phonegap using require() method. code given below , .js files in correct location. please me, able load phonegap via amd , or use normal script method <script type="text/javascript" src="cordova.js"></script> this require config , methods require.config({ baseurl: 'js/lib', paths: { controller: '../controller/controller', model: '../model/model', view: '../view/view', router:'../router/router' }, /* map: { '*': { 'tempname': 'actualname' } },*/ shim: { 'backbone': { deps: ['underscore', 'jquery','cordova'], exports: 'backbone' }, 'underscore': { exports: '_' }

windows phone 7 - Will apps developed for WP 7.1 work on WP8? -

i have developed app targeting windows phone 8, doesn't work on windows phone 7.5. working on both platforms, have decided target windows phone os 7.1 via microsoft visual studio 2012 instead. will app works on both wp 7.5 , wp 8 if target wp os 7.1 in vs 2012? windows phone applications forward compatible. means applications built windows phone 7.x should work on windows phone 8. however, not guarantee. applications may not work , should test application on windows phone 8 devices. you can maintain 2 versions of application: 1 windows phone 7 , 1 windows phone 8. publish both versions 1 application users of each device can best application device. you can upgrade windows phone 7 project windows phone 8 project, cannot downgrade. best thing create new windows phone 7 project , move files wp8 project new one.

java - Send special characters in JSON from android to PHP -

i want send json php file have on server, works fine except when field contains special characters (accents, ñ, etc.). java file: httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(uri); jsonobject json = new jsonobject(); try { // json data: json.put("id_u", viaje.getid_u()); json.put("id_vo", viaje.getid_vo()); json.put("titulo", viaje.gettitulo()); [...] jsonarray postjson=new jsonarray(); postjson.put(json); // post data: httppost.setheader("json",json.tostring()); httppost.getparams().setparameter("jsonpost",postjson); // execute http post request system.out.print(json); httpresponse response = httpclient.execute(httppost); php file: $json = $_server['http_json']; $data = json_decode($json); $id_u = $data->id_u; $id_vo = $data->id_vo; $titulo = $data-&

php - How do I fix the Apache error PHPSESSID? -

i getting apache errors aws php library, here error getting apache error log file, [fri aug 09 15:47:12 2013] [error] failed determine home directory after trying "sh: 1: cd: can't cd ~" (exit code 2) [fri aug 09 15:47:12 2013] [error] phpsessid f97oht9qlsuvknc45t075hohn5 [fri aug 09 15:47:12 2013] [error] f97oht9qlsuvknc45t075hohn5 [fri aug 09 15:47:12 2013] [error] f97oht9qlsuvknc45t075hohn5 = i tried fix error of http://blog.isnoop.net/2012/04/02/cd-1-cant-cd-to/ forum. after got other 3 lines errors, [fri aug 09 15:47:12 2013] [error] phpsessid f97oht9qlsuvknc45t075hohn5 [fri aug 09 15:47:12 2013] [error] f97oht9qlsuvknc45t075hohn5 [fri aug 09 15:47:12 2013] [error] f97oht9qlsuvknc45t075hohn5 = how fix these errors? advance help. if using version 1.6.x of sdk , explicitly providing credentials client object (instead of relying sdk's config discovery mechanism), try using aws_disable_config_auto_discovery constant circumvent of self-discovery

c# - Multiplicity constraint violated. The role "....' of the relationship '...' has multiplicity 1 or 0..1 -

again stucked un-clrear error raised ef. have following model class:- public partial class tmsserver { public tmsserver() { this.tmsservers1 = new hashset<tmsserver>(); this.tmsvirtualmachines = new hashset<tmsvirtualmachine>(); } public int tmsserverid { get; set; } public nullable<int> servermodelid { get; set; } public int datacenterid { get; set; } public string iloip { get; set; } public int rackid { get; set; } public nullable<int> statusid { get; set; } public nullable<int> backupstatusid { get; set; } public int roleid { get; set; } public nullable<int> operatingsystemid { get; set; } public nullable<int> virtualcenterid { get; set; } public string comment { get; set; } public byte[] timestamp { get; set; } public long it360siteid { get; set; } public virtual datacent

Do apps on Android need to be connected to Google Play to access location data? -

im new forum. ive searched it, not found conclusive answers question. im building location based app. ive started it. im reading how location based data. aware not uses googleplay. first question is: do need connected google play access location services of device? get location without google play services -android the above thread mentions using locationmanager without using locationclient, (im still getting grips these terms!) i want app accessible possible users, hence question. thanks john you need google play access google maps api. if want accessible users, it's okay because might publishing on google play , every users have google play adjusted.

proxy - JSON.Net Serialization of NHibernate Proxies (NH 3.3.2.4000) -

i'm still having continuous difficulties getting json.net , nhibernate play nicely together. namely, in getting json.net serialize proxied nhibernate object. i've followed recommendations here , both accepted answer , ammendments, no dice. the biggest problem above solution seems modern versions of nhibernate using inhibernateproxyproxy interface create proxies (rather inhibernateproxy? can anyne else confirm this?), base class in case nhibernate.proxy.dynamicproxy.proxydummy , reveals nothing underlying object when attempt create json constract using custom scontract resolver, ie: protected override jsoncontract createcontract(type objecttype) { if (typeof(nhibernate.proxy.inhibernateproxy).isassignablefrom(objecttype)) return base.createcontract(objecttype.basetype); else return base.createcontract(objecttype); } does have advice how deal inhibernateproxyproxy effectively? the full solution: in glob

Difference between Parameters and HTTP headers -

i'm wondering if can explain me difference between passing values in http request parameters or headers in example : http request : get /<api version>/<account> http/1.1 host: storage.swiftdrive.com x-auth-token: eaaafd18-0fed-4b3a-81b4-663c99ec1cbb http response http/1.1 200 ok date: thu, 07 jun 2010 18:57:07 gmt server: apache content-type: text/plain; charset=utf-8 content-length: 32 is host, x-auth-tiken in request, , date, server, content-type, content-length on response parameters or http headers if use them in 'curl' request ? i'm working on tool in weach must specify if these values parameters or request headers, , don't how do. thank's

creating list of empty lists - Python -

test = [[none e in range(1)] e in range(len(foobar)/2)] delete in range(0,len(test)): del test[delete][0] this not pythonic way create empty list would suggest else? i know question explains it. not duplicate of previous 1 can see. does want? test = [[] e in range(len(foobar)/2)] it has same output code

functional programming - Scala class wrapping a partially applied constructor - how to use it to create API methods? -

i'm trying create simple api dealing intervals of hours. (i'm aware of joda time, , i'm not trying reinvent it. rather exercise). what achieve this: (1) assert(from("20:30").to("20:50") == interval("20:30", "20:50") ) //same thing, without implicit defs assert(from(time(20, 30)).to(time(20, 50)) == interval(time(20, 30), time(20, 50))) (2) assert(from("20:30").forminutes(10) == from("20:30").to("20:40")) have managed implement (1), this: (ignoring tostring, ordered trait, a.s.o) case class time(hour: int, minute: int) case class interval(start: time, end: time) object interval { case class halfinterval(half: time => interval) { def to(time: time): interval = half(time) def forminutes(minutes: int): interval = ??? } def from(start: time): halfinterval = halfinterval(interval(start, _)) } object time { def apply(hourminute: string): time = { val tries