This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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ó :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
require 'net/http' | |
# Script tested on 1.9.2-Head Ruby (Linux) | |
# | |
# Nokogiri gem install required | |
class RubyGet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Robot | |
def self.attr_state(*names) | |
names.each{|n| | |
n = n.to_sym | |
attr_writer n | |
attr_reader n | |
} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + '"'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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 %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |