Skip to content

Instantly share code, notes, and snippets.

View TheNaoX's full-sized avatar
🌮
Tacos

Antonio Chavez TheNaoX

🌮
Tacos
View GitHub Profile
@TheNaoX
TheNaoX / Rails dynamic model
Created August 3, 2012 22:12
This model allows you to manipulate your variables as Setting.apple = {:color => "red", :taste => "sweet"}, and fetch data like this Setting.apple.color # => 'red'
require 'ostruct'
class Setting < ActiveRecord::Base
class SettingNotFound < RuntimeError ; end
validates_uniqueness_of :key
serialize :value
class << self
# /bin/bash
// save as somefile.sh and apply execution permissions
// Installing jupiter for battery managment on ubuntu 11.10 64-bit, works for 32-bit computers too
sudo add-apt-repository ppa:webupd8team/jupiter
sudo apt-get update
sudo apt-get install jupiter
function parse_git_dirty {
git diff --quiet HEAD &>/dev/null
[[ $? == 1 ]] && echo "…"
}
if [ -n __git_ps1 ]; then
function parse_git_branch {
local branch=$(__git_ps1 "%s")
[[ $branch ]] && echo " $branch$(parse_git_dirty)"
}
fi
@TheNaoX
TheNaoX / checkboxes.scss
Created March 17, 2015 04:29
SASSy font awesome checkboxes.
input[type="checkbox"] {
display: none;
& + label {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
@TheNaoX
TheNaoX / generate_sdk_files.rb
Last active August 29, 2015 14:14
Generate unfingerprinted version of assets and uploading them to s3
class GenerateSDKFiles
FILE_NAMES = [ "application.js" ]
ONE_HOUR = 3600
def generate
Rails.logger.info "Started to sync libraries #{FILE_NAMES}"
FILE_NAMES.each do |file_name|
@TheNaoX
TheNaoX / server.rb
Created July 29, 2014 18:38
Polyglot server
['Chicho', "Toño"].each do |name|
puts "Ola k ase #{name}"
end
system "node app.js"
func makeIncrementer() -> (Int -> Int) {
func addOne(number: Int) -> Int {
return 1 + number
}
return addOne
}
var increment = makeIncrementer()
increment(7)
@TheNaoX
TheNaoX / mail.rb
Created February 4, 2014 23:46
Here's a basic example of how to use the Mail gem without action mailer on rails.
recipients = ['email@example.com']
mail_body = <<-HTML
Hello world!
HTML
mail = Mail.new do
delivery_method(
:smtp,
:address => "address",