Skip to content

Instantly share code, notes, and snippets.

View tiomoreno's full-sized avatar
🎯
Focusing

Tio Moreno tiomoreno

🎯
Focusing
View GitHub Profile
Sete Atitudes para Hackear a Indústria de Software
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo

Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.

Required modules

JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.

Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted Upper Camel Case variable names for all module global variables

Local SSL websites on Mac OSX

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on Mac OSX Yosemite.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward edit to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@tiomoreno
tiomoreno / world_cup.rb
Created June 20, 2014 02:47
Um hack simples para pegar uma parcial com os jogos da copa em Ruby
require 'net/http'
require 'json'
response = Net::HTTP.get('worldcup.sfg.io', '/matches')
JSON.parse(response).each do |jogo|
if jogo['status'] === 'completed'
home = [jogo['home_team']['country'], jogo['home_team']['goals'].to_s].join(' ')
away = [jogo['away_team']['country'], jogo['away_team']['goals'].to_s].join(' ')
puts home << ' x ' << away
@tiomoreno
tiomoreno / jogos.js
Created June 20, 2014 01:58
Um hack simples para pegar uma parcial com os jogos da copa em Node.js
var http = require('http');
http.get("http://worldcup.sfg.io/matches", function(response) {
var body = '';
response.on('data', function(chunk) {
body += chunk;
});
response.on('end', function() {
A versão do Nginx disponível nos repositórios oficiais do Ubuntu 12.04 é a 1.1.19, mas queremos a usar a versão estável atual, então vamos adicionar o repositório PPA oficial do Nginx ao nosso VPS. Para isso, digite o seguinte comando no terminal:
nano /etc/apt/sources.list
Com o arquivo de repositórios aberto, navegue até o final do arquivo com as setas de direção do seu teclado e adicione a linha abaixo:
deb http://ppa.launchpad.net/nginx/stable/ubuntu precise main
Adicione o repositório PPA do Nginx no final do arquivo sources.list
Feito isso, aperte <Ctrl + O> para salvar e <Ctrl + X> para fechar o arquivo e voltar ao terminal. Agora ainda com o terminal aberto, vamos adicionar a chave de autentificação do PPA, atualizar a lista de repositórios e atualizar o sistema todo. Copie e cole os comandos abaixo, lembrando de dar enter ao final de cada linha:
#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'
from geopy import units, distance
from mezzanine.core.managers import CurrentSiteManager
class GeoManager(CurrentSiteManager):
def near(self, latitude=None, longitude=None, distance_range=30):
queryset = super(GeoManager, self).get_query_set()
if not (latitude and longitude and distance_range):
return queryset.none()
#!/bin/bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-10gen
echo "mongodb-10gen hold" | sudo dpkg --set-selections