web developing
26 Aug
Today after two posts [#1, #2] in the past days here’s something that shows again the JavaScript power. This is not a complete example, but it’s good to start.
var str = '/text/1/text/2/'; var a = str.match(/(\d+)/gi); console.log(a);
in that example you’ll get an array with all the numbers in the string ["1", "2"] – yet another flexible js snippet!
25 Aug
Here’s yet another example of the JavaScript flexibility. You can simply call .replace() on every string and pass a regex as a parameter!
var str = 'my simple string'; str.replace(/ /g, '-'); // now 'str' will contain 'my-simple-string'
24 Aug
After reviewing a chunk of my code for today I continue to admire the flexibility of JavaScript. It’s really powerful. In that example you can get a string split it by a given symbol to an array and than get the Nth element of it. All this on one line! Amazing!
var str = 'my-long-string'; str.split('-')[0]; // will contain "my"
the 1st and 2nd indexes contain respectively “long” and “string”!
23 Aug
I’m sure this is not the first time you’ve been asked this question. However there’s nobody today that doesn’t wonder the answer. For me – yes, twitter can replace the RSS feed readers, and NO – feed readers are awsome!
First of all why do I use a feed reader? I’m simply seeing what’s in it and barely read the article from the reader, but rather I jump to the site, and what’s happening often in twitter is the same scenario, I just see what’s in the tweet and if it seems to be interesting to me I jump to the link (if there’s a link). The good thing is that the tweets are limited and I’m focused. That’s why twitter is my favorite social site. I can follow all of the interesting people I know from their blogs. So perhaps twitter is becoming more useful than the feed readers.
In other hand in twitter you’ve to stay all the day long to get all the tweets you need. The timeline is quickly changing and sometimes you get lots of “junk”. While in the feed reader you’ve all the “important” posts as an incoming mail. You cannot miss anything! That’s why I cannot forget the feed readers they are doing a great job!
19 Aug
In a reply from my latest post after following the comments, there is a much elegant solution to this use case. Simply by changing the output with a JSON helper. This also changes the content-type of the returned response.
$data = array(...); $this->_helper->json($data);