Daily Archives

Articles indexed Saturday March 27 2010

Page 3/84 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Does Perl's Net::Cassandra module support UTF-8?

    - by knorv
    I've run into a really strange UTF-8 problem with Net::Cassandra::Easy (which is built upon Net::Cassandra): UTF-8 strings written to Cassandra are garbled upon retrieval. The following code shows the problem: use strict; use utf8; use warnings; use Net::Cassandra::Easy; binmode(STDOUT, ":utf8"); my $key = "some_key"; my $column = "some_column"; my $set_value = "\x{2603}"; my $cassandra = Net::Cassandra::Easy->new(keyspace => "Keyspace1", server => "localhost"); $cassandra->connect(); $cassandra->mutate([$key], family => "Standard1", insertions => { $column => $set_value }); my $result = $cassandra->get([$key], family => "Standard1", standard => 1); my $get_value = $result->{$key}->{"Standard1"}->{$column}; if ($set_value eq $get_value) { # this is the path I want. print "OK: $set_value == $get_value\n"; } else { # this is the path I get. print "ERR: $set_value != $get_value\n"; } When running the code above $set_value eq $get_value evaluates to false. What am I doing wrong?

    Read the article

  • jQuery Roundabout IE images pixellated

    - by luke
    Hi at http://lunatestsite.co.uk my jQuery roundabout near the bottom of the homepage is problematic in IE7 and 8 - book cover images blurred/pixellated. http://stackoverflow.com/questions/1985303/ie-image-display-problems/2355921#2355921 suggests something to do with em sizing in IE being the root of it but I don't really understand the conclusion reached there. I don't think opacity is an issue in this. Any help gratefully appreciated, this is more or less last on more checklist for this site! Thanks Edit: fixed by resetting to font-size: 1em before the height and width em declarations for the roundable-movable-item and roundabout-movable-item img. Now working in IE7 and 8.

    Read the article

  • PHP Captcha without session

    - by Anton N
    Ok, here is an issue: in the project i'm working on, we can't rely on server-side sessions for any functionality. The problem is that common captcha solutions from preventing robotic submits require session to store the string to match captcha against. The question is - is there any way to solve the problem without using sessions? What comes to my mind - is serving hidden form field, containing some hash, along with captcha input field, so that server then can match these two values together. But how can we make this method secure, so that it couldn't be used to break captcha easily.

    Read the article

  • How do I run a command as a different user from a root cronjob?

    - by rob
    I seem to be stuck between an NFS limitation and a Cron limitation. So I've got root cron (on RHEL5) running a shell script that, among other things, needs to rsync some files over an NFS mount. And the files on the NFS mount are owned by the apache user with mode 700, so only the apache user can run the rsync command -- running as root yields a permission error (NFS being a rare case, apparently, where the root user is not all-powerful?) When I just want to run the rsync by hand, I can use "sudo -u apache rsync ..." But sudo no workie in cron -- it says "sudo: sorry, you must have a tty to run sudo". I don't want to run the whole script as apache (i.e. from apache's crontab) because other parts of the script do require root -- it's just that one command that needs to run as apache. And I would really prefer not to change the mode on the files, as that will involve significant changes to other applications. There's gotta be a way to accomplish "sudo -u apache" from cron?? thanks! rob

    Read the article

  • Work-around for PHP5's PDO rowCount MySQL issue

    - by Steven Surowiec
    I've recently started work on a new project using PHP5 and want to use their PDO classes for it. The problem is that the MySQL PDO Driver doesn't support rowCount() so there's no way to run a query and then get the number of affected rows, or rows returned, which is a pretty big issue as far as I'm concerned. I was wondering if anyone else has dealt with this before and what you've done to work around it. Having to do a fetch() or fetchAll() to check if any rows were affected or returned seems like a hack to me, I'd rather just do $stmt-numRows() or something similar.

    Read the article

  • Few questions about a good projector on my PC and tv?

    - by jasondavis
    I have always wanted a projector for my tv, satelite, cable, and even PC in a spare bedroom. Well it's more of a home office that I spend most my time in and the catch here is it is a small room. Room is only the standard 8foot tall. Room is about 13 feet wide on the wall where I would like to mount the project and the wall where the screen would be for it. So only about 13 feet away from projector to screen. I would like to know... 1) From experience or knowledge what would be a good projector I could hook up to my satelite box and also my PC? Cheaper is better in this case but I would still like the best image for my buck and something reliable. There is no sunlight in the room either to worry about. 2) From that distance of about 12-13 feet away, how big of a clear picture could I expect? 3) What kind of cables would I need to purchase and run through my attic to my cable/satelite receiver box as well as my PC? 4) These cables in question 3 would most likely need to be a good 15-20feet in length to reach, would I need anything special for that to work at those distances?

    Read the article

  • An event for when xVal validation fails?

    - by Dusda
    I have a registration form leveraging xVal to handle all validation on the form. It works really well, with one exception: the user doesn't get feedback because another element on the page (a tip telling the user that their username will be their email address) draws on top of the span element xVal spits out when it notices a problem. If I had a way to detect when xVal has a problem with the email field, I could just toggle the visibility of that tooltip and be on my way, but I'm not sure how to do so. I know that xVal uses jquery.validate.js under the hood; is there an event or something I could tie into to do this?

    Read the article

  • Exposing APIs - third party or homegrown?

    - by amelvin
    Parts of the project I'm currently working on (I can't give details) will be exposed as an API at some point over the next few months and I was wondering whether anyone could recommend a third party API 'provider' (possibly Mashery or SO advertiser Webservius). And I mean recommend in the 'I've used these people and they are good' sense because although I can google for an answer to this question it is more difficult to get truly unbiased opinions. As an addendum is there much mileage in creating a bespoke API solution and has anyone had any joy going down that road? Thanks in anticipation.

    Read the article

  • Encode double quotes inside XML element using LINQ to XML

    - by davekaro
    I'm parsing a string of XML into an XDocument that looks like this (using XDocument.Parse) <Root> <Item>Here is &quot;Some text&quot;</Item> </Root> Then I manipulate the XML a bit, and I want to send it back out as a string, just like it came in <Root> <Item>Here is &quot;Some text&quot;</Item> <NewItem>Another item</NewItem> </Root> However, what I am getting is <Root> <Item>Here is \"Some text\"</Item> <NewItem>Another item</NewItem> </Root> Notice how the double quotes are now escaped instead of encoded? This happens whether I use ToString(SaveOptions.DisableFormatting); or var stringWriter = new System.IO.StringWriter(); xDoc.Save(stringWriter, SaveOptions.DisableFormatting); var newXml = stringWriter.GetStringBuilder().ToString(); How can I have the double quotes come out as &quot; and not \"? UPDATE: Maybe this can explain it better: var origXml = "<Root><Item>Here is \"Some text&quot;</Item></Root>"; Console.WriteLine(origXml); var xmlDoc = System.Xml.Linq.XDocument.Parse(origXml); var modifiedXml = xmlDoc.ToString(System.Xml.Linq.SaveOptions.DisableFormatting); Console.WriteLine(modifiedXml); the output I get from this is: <Root><Item>Here is "Some text&quot;</Item></Root> <Root><Item>Here is "Some text"</Item></Root> I want the output to be: <Root><Item>Here is "Some text&quot;</Item></Root> <Root><Item>Here is "Some text&quot;</Item></Root>

    Read the article

  • Reducing Duplicated Code

    - by cam
    I have some code that works on the color structure like this public void ChangeColor() { thisColor.R = thisColor.R + 5; } Now I need to make a method that changes a different variable depending on what it is passed. Here is what the code looks like now. public void ChangeColor(int RGBValue) { switch(RGBValue) { case 1: thisColor.R = thisColor.R + 5; break; case 2: thiscolor.B = thisColor.B + 5; break; } } Now, this is something I would normally never question, I'd just throw a #region statement around it and call it a day, but this is just an example of what I have, the actual function is quite long. I want it to look like this: public void ChangeColor(int RGBValue) { thiscolor.RGBValue = thiscolor.RGBValue; } So essentially the value would refer to the variable being used. Is there a name for this? Is this what Reflection is for? Or something like that... Is there a way to do this?

    Read the article

  • Get notified/receive explicit intents when an activity starts

    - by qtips
    Hi, I am developing an application than gets notified when an activity chosen by a user is started. For this to work, the best approach would be to register a broadcastreceiver for ACTION_MAIN explicit intents, which as far as I know doesn't work (because these intents have specific targets). Another, probably less efficient approach, is to use the system ActivityManager and poll on the getRunningTask() which returns a list of all running tasks at the moment. The polling can be done by a background service. By monitoring the changes in this list, I can see whether an activity is running or not, so that my application can get notified. The downside is ofcourse the polling. I have not tried this yet, but I think that this last approach will probably work. Does anyone know of a better approach(es) or suggestions which are less intensive?

    Read the article

  • Best way to copy the entire contents of a directory in C#

    - by Keith
    I want to copy the entire contents of a directory from one location to another in C#. There doesn't appear to be a way to do this using System.IO classes without lots of recursion. There is a method in VB that we can use if we add a reference to Microsoft.VisualBasic: new Microsoft.VisualBasic.Devices.Computer(). FileSystem.CopyDirectory( sourceFolder, outputFolder ); This seems like a rather ugly hack. Is there a better way?

    Read the article

  • R: Are there any alternatives to loops for subsetting from an optimization standpoint?

    - by Adam
    A recurring analysis paradigm I encounter in my research is the need to subset based on all different group id values, performing statistical analysis on each group in turn, and putting the results in an output matrix for further processing/summarizing. How I typically do this in R is something like the following: data.mat <- read.csv("...") groupids <- unique(data.mat$ID) #Assume there are then 100 unique groups results <- matrix(rep("NA",300),ncol=3,nrow=100) for(i in 1:100) { tempmat <- subset(data.mat,ID==groupids[i]) #Run various stats on tempmat (correlations, regressions, etc), checking to #make sure this specific group doesn't have NAs in the variables I'm using #and assign results to x, y, and z, for example. results[i,1] <- x results[i,2] <- y results[i,3] <- z } This ends up working for me, but depending on the size of the data and the number of groups I'm working with, this can take up to three days. Besides branching out into parallel processing, is there any "trick" for making something like this run faster? For instance, converting the loops into something else (something like an apply with a function containing the stats I want to run inside the loop), or eliminating the need to actually assign the subset of data to a variable?

    Read the article

  • Paypal subscriptions IPN - problem with users subscribing multiple times

    - by Brian Armstrong
    I'm using paypal subscriptions and the instant payment notification (IPN) to handle subscribers on my site. For the most part it works well but there is one occasional problem I've encountered. Usually if a user cancels their subscription, I wait for the "end of term" (subscr_eot) notification before disabling access to my site. So if they prepay for the whole month, and then cancel right away, they still have access for the rest of the month (as it should be). But some users are having this problem where they: Cancel their subscription Before the "end of term" is reached they decide to re-subscribe When the "end of term" is reached for their first subscription, my app receives the notification and fires off an email to the user with something like "your account has been disabled, if you ever want to sign up again, you can re-subscribe by clicking here". This confuses them because they are thinking...that's weird, I thought I subscribed like a week ago (and they did). So they go subscribe AGAIN. Now they have two concurrent running subscriptions to my site and I get a support email in a month or two ("wtf you billed me twice this month jerk!!") So I haven't found a good way to fix this. I guess the best solution would be to do an additional API call when the "end of term" notification is received which asks paypal "hey did this person already re-subscribe?". If so then no need to fire off that email. But I haven't seen any way to do this API call yet. Another solution is to disable their account immediately when they cancel (the "subscr_cancel" notification) but then I get different angry support emails "hey I prepaid for the whole month why was my account disabled already!!". Anyone else solved this?

    Read the article

  • Python c_types .dll functions (pari library)

    - by silinter
    Alright, so a couple days ago I decided to try and write a primitive wrapper for the PARI library. Ever since then I've been playing with ctypes library in loading the dll and accessing the functions contained using code similar to the following: from ctypes import * libcyg=CDLL("<path/cygwin1.dll") #It needs cygwin to be loaded. Not sure why. pari=CDLL("<path>/libpari-gmp-2.4.dll") print pari.fibo #fibonacci function #prints something like "<_FuncPtr object at 0x00BA5828>" So the functions are there and they can potentially be accessed, but I always recieve an access violation no matter what I try. For example: pari.fibo(5) #access violation pari.fibo(c_int(5)) #access violation pari.fibo.argtypes=[c_long] #setting arguments manually pari.fibo.restype=long #set the return type pari.fibo(byref(c_int(5))) #access violation reading 0x04 consistently and any variation on that, including setting argtypes to receive pointers. The Pari .dll is written in C and the fibonacci function's syntax within the library is GEN fibo(long x) (docs @http://pari.math.u-bordeaux.fr/dochtml/html/Arithmetic_functions.html#fibonacci, I need more rep it seems). Could it be the return type that's causing these errors, as it is not a standard int or long but a GEN type, which is unique to the PARI library? Any help would be appreciated. If anyone is able to successfully load the library and use ANY function from within python, please tell; I've been at this for hours now.

    Read the article

  • Dealing with ArrayLists in java...all members of the arraylist updating themselves?

    - by Charlie
    I have a function that shrinks the size of a "Food bank" (represented by a rectangle in my GUI) once some of the food has been taken. I have the following function check for this: public boolean tryToPickUpFood(Ant a) { int xCoord = a.getLocation().x; int yCoord = a.getLocation().y; for (int i = 0; i < foodPiles.size(); i++) { if (foodPiles.get(i).containsPoint(xCoord, yCoord)) { foodPiles.get(i).decreaseFood(); return true; } } return false; } Where decreaseFood shrinks the rectangle.. public void decreaseFood() { foodAmount -= 1; shrinkPile(); } private void shrinkPile() { WIDTH -=1; HEIGHT = WIDTH; } However, whenever one rectangle shrinks, ALL of the rectangles shrink. Why would this be?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >