Skip to content

Instantly share code, notes, and snippets.

View leandroh's full-sized avatar
:shipit:
To deploy or not to deploy?

Leandro Pará leandroh

:shipit:
To deploy or not to deploy?
View GitHub Profile
#!/usr/bin/ruby
require 'net/http'
botid = "f5d922d97e345aa1"
botcust = "a47d79b2be70536d"
url = "http://www.pandorabots.com/pandora/talk"
response = Net::HTTP.post_form(URI.parse(url), {'input' => ARGV.join(' '), 'botid' => botid, 'botcust2' => botcust, 'skin' => 'custom_input'})
puts response.body.split("ALICE:").last.split("\n").first.gsub(/<\/?[^>]*>/, "").strip
module ActiveRecord
module Acts
module AsFlagable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_flagable(options)
unless flagable?
puts $1+$2 if "12345555567890" =~ /(\d)(\1{4})/
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
module Varz
module GetSet
def initialize(init = {})
@variables = init
end
def get(key)
@variables[key] || "Bang!"
end
@leandroh
leandroh / queryString.js
Created May 4, 2010 17:42
simple query string parser based on element id and value
var queryString = {
createById: function() {
var args = [];
for (var i = 0; i < arguments.length; i++) {
var el = document.getElementById(arguments[i]);
args[i] = el.id + "=" + el.value;
}
return args.join("&");
}
};
@leandroh
leandroh / init.sh
Created May 21, 2010 11:44 — forked from atmos/init.sh
#!/bin/sh
curl http://gist.github.com/raw/323731/install_homebrew > install_homebrew.rb
ruby install_homebrew.rb
rm install_homebrew.rb
echo "PATH=/usr/local/bin:/Developer/usr/bin:\$PATH; export PATH" >> ~/.profile
source ~/.profile
echo "Your path is now $PATH"
brew install git
brew update
@leandroh
leandroh / index.sh
Created May 24, 2013 20:09
Basic structure of an HTML5 document.
#!/usr/bin/env bash
TITLE=$@
[ -z "$TITLE" ] && TITLE="page title"
printf "<!DOCTYPE html>\n<html lang=\"pt-br\">\n <head>\n <meta charset=\"utf-8\">\n <title>${TITLE}</title>\n </head>\n <body>\n </body>\n</html>" > index.html
@leandroh
leandroh / find-rpi.sh
Last active December 23, 2015 13:29
encontrando a raspberry pi em uma rede local
#!/usr/bin/env bash
ROOT_UID=0 # somente para usuarios com privilegio de root
E_NOTROOT=87 # erro de usuario nao root
SCRIPT_NAME=$(basename $0) # nome do arquivo
if [ "$UID" -ne "$ROOT_UID" ]
then
echo -e "\e[31m\e[40m[ ✗ ] Você deve executar o script '$SCRIPT_NAME' como root."
exit $E_NOTROOT
@leandroh
leandroh / gist:9599888
Created March 17, 2014 14:13
remove files
find fontes -name "*.so" -exec rm -v "{}" \;
find fontes -name "*.pyc" -exec rm -v "{}" \;