View video_file.cr
module MediaManager
class VideoFile
def self.compute_hash(file_path : String)
filesize = File.size(file_path)
hash = filesize
# Read 64 kbytes, divide up into 64 bits and add each
# to hash. Do for beginning and end of file.
File.open(file_path, "rb") do |f|
View atom-better_errors.md

First, configure better_errors gem config/environments/development.rb:

BetterErrors.editor = "atom://open?url=file://%{file}&line=%{line}"

Next, create a new desktop entry /usr/share/applications/atom-urihandler.desktop:

[Desktop Entry]
Name=Atom
Comment=Open atom:// links in Atom editor
GenericName=URI handler
View gist:7502268f28695b4e29a0
<!-- Modal Filtro -->
<div class="modal fade" id="ModalFilter" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
<%= form_tag countries_path, method: :get do %>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="ModalLabel">Filtro</h4>
View gist:364acf1559fbad363847
require 'rubygems'
require 'mechanize'
require 'pp'
a = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
a.get('https://google.com/') do |page|
search_result = page.form_with(:action => '/search') do |search|
search.q = 'Hello world'
View alias.txt
alias dm='rake db:migrate'
alias dmt='rake db:migrate && rake db:test:prepare'
alias dmp='RAILS_ENV=production rake db:migrate'
alias rc='rails c'
alias rg='rails g'
alias rcp='RAILS_ENV=production rails c'
alias rs='rails s'
alias rsp='RAILS_ENV=production rails s'
alias zdm='zeus rake db:migrate'
alias zdmt='zeus rake db:migrate && zeus rake db:test:prepare'
View up_postgres.sh
sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main" >> /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.3 postgresql-contrib-9.3 libpq-dev postgresql-9.3-postgis-2.1
cd /tmp
View gist:6413691
Editar
sudo xed /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache
sudo xed /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules.cache
Adicionar :en na linha "cedilla"
sudo xed /usr/share/X11/locale/en_US.UTF-8/Compose
substituir "ć" por "ç" e "Ć" por "Ç". ( Contrl + h )
View post_install.sh
#atualizado para mint 18
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl zsh git terminator ruby2.3 ant vim coffeescript libcurl4-openssl-dev exuberant-ctags htop iotop
sudo locale-gen pt_BR.UTF-8
#cedilha no teclado internacional
# sudo sed -i.bak 's/\("cedilla".*\)"\(.*\)" *$/\1"\2:en"/g' /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache
# sudo sed -i.bak 's/\("cedilla".*\)"\(.*\)" *$/\1"\2:en"/g' /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules.cache
# sudo sed -i.bak "s/ć/ç/g;s/Ć/Ç/g" /usr/share/X11/locale/en_US.UTF-8/Compose
View schedul.rb
inicio = Time.local(2012,04,19,8,00)
termino = Time.local(2012,4,19,18,00)
excecao = Time.local(2012,4,19,12,00)
schedule = IceCube::Schedule.new(inicio, :end_time => termino)
schedule.add_recurrence_rule( IceCube::Rule.hourly(1).day(:monday,:tuesday) )
schedule.add_exception_time(excecao)
View gist:925255
class Calendar < ActiveRecord::Base
has_many :events
end
class Event < ActiveRecord::Base
belongs_to :calendar
def after_find
singleton = class << self; self; end