Today, in Ruby, if I want to make a network request, I block
response = Net::HTTP.get("/post/1")
If I want to do multiple requests in parallel, I can use a thread per request
responses = ["/post/1", "/post/2"].map do |url|
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
Today, in Ruby, if I want to make a network request, I block
response = Net::HTTP.get("/post/1")
If I want to do multiple requests in parallel, I can use a thread per request
responses = ["/post/1", "/post/2"].map do |url|
require 'benchmark' | |
Benchmark.bm(10) do |x| | |
x.report("Array#join") { | |
10000.times do | |
["'", ("a".."z").to_a.join("' , '"), "'"].join | |
end | |
} | |
x.report("String#<<") { | |
10000.times do |
var paypalAddressClient = (function() { | |
"use strict" ; | |
var SERVICE_URL = 'https://www.paypal.com/br/cgi-bin/webscr?cmd=_prefilladdress&countryCode={{#country}}&zipcode={{#zip_code}}' | |
var httpClient = new XMLHttpRequest(); | |
httpClient.onreadystatechange = function() { | |
if(this.status == 200 && this.readyState == httpClient.DONE) { | |
var response = this.responseText, | |
json_response = response.slice(response.indexOf("{")), | |
response_object = JSON.parse(json_response); |
require 'mustache' | |
class MustacheTest | |
def self.init | |
template = DATA.read | |
puts Mustache.render(template, name: "User Name", email: 'user@email.com', subject: 'Contact', area: 'Marketing', question_type: '1', message: 'Hi there, i need some support (...)', date: Time.now.strftime("%d/%m/%Y %T"), ip: '127.0.0.1', origin: File.expand_path(__FILE__) ) | |
end | |
end | |
at_exit { MustacheTest.init } |
SP_COORDINATES = [ | |
[-23.5362800,-46.6764790], # Perdizes | |
[-23.5386997,-46.6745478], | |
[-23.5409620,-46.6736037], | |
[-23.5436570,-46.6704065], | |
[-23.5464110,-46.6745264], | |
[-23.5471302,-46.6717029], # Av. Sumaré | |
[-23.5444353,-46.6765952], | |
[-23.5506316,-46.6774321], | |
[-23.5549590,-46.6676259], |
// clone this gist to a empty folder, the run: | |
// npm init (and follow steps) | |
// npm install express --save | |
// npm install swig --save | |
// node app.js and open http://localhost:3000 | |
function App() { | |
var express = require('express'); |
var runOptimized = function() { | |
"use strict"; | |
function getPrimes(){ | |
var primeCount, primes, obj; | |
primeCount = 0; | |
primes = new Array(100000); | |
obj = {}; | |
obj.getPrimeCount = function() { return primeCount; }; | |
obj.getPrime = function(i) { return primes[i]; }; | |
obj.addPrime = function(p) { primes[primeCount]=p; primeCount+=1; }; |
--- | |
- :cod_uf: '52' | |
:uf: Goiás | |
:city_id: '00050' | |
:city: Abadia de Goiás | |
:sigla_uf: GO | |
:city_code: '5200050' | |
- :cod_uf: '31' | |
:uf: Minas Gerais | |
:city_id: '00104' |
default: &default | |
adapter: postgresql | |
encoding: unicode | |
pool: 5 | |
username: root | |
password: | |
host: localhost | |
development: | |
<<: *default |