Skip to content

Instantly share code, notes, and snippets.

View lastk's full-sized avatar

Rafael Oliveira lastk

  • Salvador-Ba, Brazil
View GitHub Profile
1- Escuta a porta 80 ( ou outra qualquer )
2- atender solicitação do tipo get
2.1 se não houver parâmetro ler pasta com os posts e montar url pra cada um
2.2 se houver parâmetro envia um response com o conteúdo html do arquivo.
acho que só :)
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
aula. Ele pratica. Instrumentistas geniais nao aprendem a tocar tendo
aula. Eles praticam. Pratique. Chegue em casa depois do trabalho e da
require 'open-uri'
require 'nokogiri'
require 'net/http'
# Script tested on 1.9.2-Head Ruby (Linux)
#
# Nokogiri gem install required
class RubyGet
(defn multiplicar [ x y] (* x y) )
; atribuir multiplicar para uma variável
(def m multiplicar)
;agora posso chamar multiplicar
(multiplicar 2 2)
;ou
(m 2 2)
module Robot
def self.attr_state(*names)
names.each{|n|
n = n.to_sym
attr_writer n
attr_reader n
}
end
@lastk
lastk / inspect.js
Created December 23, 2010 11:17 — forked from creationix/inspect.js
function escapeString(string) {
string = string.replace(/\\/g, "\\\\").
replace(/\n/g, "\\n").
replace(/\r/g, "\\r").
replace(/\t/g, "\\t");
if (string.indexOf("'") < 0) {
return "'" + string + "'";
}
string = string.replace(/"/g, "\\\"");
return '"' + string + '"';
<!-- layout file -->
<% if current_user %>
Welcome <%= current_user.username %>. Not you? <%= link_to "Log out", logout_path %>
<% else %>
<%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>.
<% end %>
=form_for(@user_session,:url=>"/sessions",:method=>"post") do |f|
.field
=f.label :credential
=f.text_field :credential
.field
= f.label :password
= f.text_field :password
.field.actions
@lastk
lastk / macenv.rb
Created February 22, 2012 20:37 — forked from pjones/macenv.rb
Create an env file for Mac OS GUI applications
#!/usr/bin/env ruby
PASS_THROUGH = %w(PATH MANPATH EDITOR)
DIRECTORY = File.expand_path('~/.MacOSX')
FILENAME = File.join(DIRECTORY, 'environment.plist')
Dir.mkdir(DIRECTORY) unless File.exist?(DIRECTORY)
HEADER = <<EOT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
class PostCommitmentContext
def initialize(params)
@params = params
end
def save
@post = Post.new(@params)
if @post.save
# @post é ActiveRecord, então não há o que extender mesmo porque ActiveRecord já está encruado
Twitter.send_notification({login: "login",pass:"password"},@post.title)