Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View filipebarcos's full-sized avatar

Filipe Costa filipebarcos

View GitHub Profile
@filipebarcos
filipebarcos / guruce-api.md
Last active March 2, 2021 11:29
Palestra "NAS COXA" GURU-CE 15 (Apr 18th, 2015)

“APIs, you're doing it wrong!”

What is an API?

From Wikipedia, we have “a set of Routines, protocols and tools for building software applications”.

Web API

REST

Re presentation S tate T ransfer is a software architecture style consisting of guidelines and best practices for creating scalable web services. REST is a coordinated set of constraints applied to the design of components in a distributed hypermedia system...

RESTful

O bom e o ruim do Quebec

Disclaimer

Essa é a minha visão particular, dentro do meu contexto.

Distância da família

Visitar a família, ou a família visitar você é complicado. Somos 4, passagens para o Brasil são caras e para 4, pior ainda. É longe, fisicamente. Montreal -> Miami, Miami -> Fortaleza é o caminho mais curto que conheço, ainda dura umas

@filipebarcos
filipebarcos / 01-sample-es6-generator.js
Last active May 13, 2017 12:20
Code Snippets for my CEJS 2017 Talk
function* foo(x) {
const y = 2 * (yield (x + 1));
const z = yield (y / 3);
return (x + y + z);
}
var it = foo( 5 );
// note: not sending anything into `next()` here
console.log(it.next()); // { value:6, done:false }
class Project < ActiveRecord::Base
has_many :time_entries
has_many :unbilled_time_entries, -> { unbilled }, class_name: 'TimeEntry'
end
class Project < ActiveRecord::Base
has_many :time_entries
has_many :unbilled_time_entries, -> { unbilled }, class_name: 'TimeEntry'
end
#!/usr/bin/python
try:
from AppKit import NSWorkspace
except ImportError:
print "Can't import AppKit -- maybe you're running python from brew?"
print "Try running with Apple's /usr/bin/python instead."
exit(1)
from datetime import datetime
client_name = ''
if @invoice.client_company_name.present?
client_name = @invoice.client_company_name.gsub(' ', ' ').gsub(/[^0-9A-z\-]/, '_').gsub('__', '_')
elsif @invoice.client_name.present?
client_name = @invoice.client_name.gsub(' ', ' ').gsub(/[^0-9A-z\-]/, '_').gsub('__', '_')
elsif @invoice.client_email.present?
client_name = @invoice.client_email.gsub(' ', ' ').gsub(/[^0-9A-z@.\-]/, '_').gsub('__', '_')
end
contractor_name = @invoice.contractor_name.gsub(' ', ' ').gsub(/[^0-9A-z\-]/, '_').gsub('__', '_')
def dragon(name)
-> (size) {
-> (element) {
"#{name} is a #{size} dragon that breathes #{element}!"
}
}
end
puts dragon("Karo").("large").("ice")
git diff --stat | grep spec | awk '{print $1}' ORS=' ' | xargs rspec
@filipebarcos
filipebarcos / srt.rb
Created February 5, 2016 11:47
Localize SRT files (pt-br). Rename all SRT files in nested folders to add `pt-br` in the end.
#!/usr/bin/env ruby
Dir.glob("#{Dir.pwd}/**/*.srt").each do |file|
newfile_name = file.sub(/\.srt$/, ".pt-br.srt")
File.rename(file, newfile_name)
end