How do I parse a URL query parameters, in Javascript? [duplicate]

Today (2.5 years after this answer) you can safely use Array.forEach. As @ricosrealm suggests, decodeURIComponent was used in this function. function getJsonFromUrl(url) { if(!url) url = location.search; var query = url.substr(1); var result = {}; query.split(“&”).forEach(function(part) { var item = part.split(“=”); result[item[0]] = decodeURIComponent(item[1]); }); return result; } actually it’s not that simple, see the … Read more

Safe integer parsing in Ruby

Ruby has this functionality built in: Integer(‘1001’) # => 1001 Integer(‘1001 nights’) # ArgumentError: invalid value for Integer: “1001 nights” As noted in answer by Joseph Pecoraro, you might want to watch for strings that are valid non-decimal numbers, such as those starting with 0x for hex and 0b for binary, and potentially more tricky … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)