Skip to content

Instantly share code, notes, and snippets.

View derencius's full-sized avatar
🍀
Wish me luck, I'm fixing my bugs

Marcus Derencius derencius

🍀
Wish me luck, I'm fixing my bugs
  • Ubatuba, São Paulo, Brazil
View GitHub Profile
@derencius
derencius / db.rb
Created March 4, 2014 01:32
heroku db download
#!/usr/bin/env ruby
require "thor"
class MyCLI < Thor
desc "download", "production database"
def download(remote)
puts "Downloading... #{remote}"
system "heroku pgbackups:capture --expire --remote #{remote}"
system "curl `heroku pgbackups:url --remote #{remote}` -o #{remote}.dump"
puts "Done!"
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
m := make(map[string]int)
words := strings.Fields(s)
@derencius
derencius / style.css
Created May 17, 2013 18:47
garoa bold
@font-face {
font-family: "GaroaBold";
src: url(/assets/garoaminuscula.eot);
src: local("GaroaBold"),
url(/assets/garoaminuscula.eot?#iefix) format("embedded-opentype"),
url(/assets/garoaminuscula.woff) format("woff"),
url(/assets/garoaminuscula.ttf) format("truetype"),
url(/assets/garoaminuscula.svg#GaroaBold) format("svg");
font-weight: normal;
font-style: normal;
@derencius
derencius / new_gist_file
Created March 28, 2013 03:56
postgres lc_collate
CREATE DATABASE "db" with ENCODING = 'unicode' lc_collate='pt_BR.UTF-8' lc_ctype='pt_BR.UTF-8' TEMPLATE=template0;
show lc_collate;
select * from (values('Éder', 'Eda', 'Edu')) x order by 1;
@derencius
derencius / image.rb
Created November 8, 2012 21:04
MiniMagick & ImageMagick - Level Colors and Composite
require 'rubygems'
require 'mini_magick'
color = '#103afc'
img = MiniMagick::Image.open("letter_x.png")
img.combine_options do |c|
c.add_command( 'level-colors')
c.+ "#{color},"
@derencius
derencius / distance.sql
Created April 20, 2012 22:04
latitude/longitude distance function - for mysql (original source: http://derickrethans.nl/spatial-indexes-mysql.html - syntax changed to fit in 1 line for easy use in a rails migration).
CREATE FUNCTION distance (latA double, lonA double, latB double, LonB double)
RETURNS double DETERMINISTIC
RETURN 2 * ASIN(SQRT((SIN((radians(latA) - radians(latB))/2) * SIN((radians(latA) - radians(latB))/2) +
COS(radians(latA)) * COS(radians(latB)) * SIN((radians(lonA) - radians(LonB))/2)*SIN((radians(lonA) - radians(LonB))/2)))) * 6371.01
def create
erros = []
variants = []
ProductionLabel.transaction do
begin
label = ProductionLabel.create!(params[:production_labels])
unless (label.valid?)
raise label.errors.full_messages
end
@derencius
derencius / dabblet.css
Created December 16, 2011 02:22
The first commented line is your dabkjkjblet’s title
/*ok
/**
* The first commented line is your dabkjkjblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
[branch]
       autosetuprebase = always