Skip to content

Instantly share code, notes, and snippets.

View luan's full-sized avatar

Luan Santos luan

View GitHub Profile
@luan
luan / .bashrc
Created October 4, 2011 01:10
BashRC
# ~/.bashrc: executed by bash(1) for non-login shells.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# check the window size after each command and, if necessary,
@luan
luan / sudoku.pl
Created March 7, 2012 19:52
Sudoku Solver in Prolog
squares([
[X11, X12, X13, X14, X15, X16, X17, X18, X19],
[X21, X22, X23, X24, X25, X26, X27, X28, X29],
[X31, X32, X33, X34, X35, X36, X37, X38, X39],
[X41, X42, X43, X44, X45, X46, X47, X48, X49],
[X51, X52, X53, X54, X55, X56, X57, X58, X59],
[X61, X62, X63, X64, X65, X66, X67, X68, X69],
[X71, X72, X73, X74, X75, X76, X77, X78, X79],
[X81, X82, X83, X84, X85, X86, X87, X88, X89],
[X91, X92, X93, X94, X95, X96, X97, X98, X99]
@luan
luan / gist:2038297
Created March 14, 2012 18:07
53467890tyuftyrtyru
{{#form_for user classes=”form-horizontal”}}
<legend>User Data:</legend>
{{input “name”}}
{{input “birthday” as=”date”}}
{{input “another_date” as=”string” mask=”##/##/####” component=”datepicker”}}
{{input “email”}}
{{input “gender” as=”select” collection=App.genders}}
{{input “categories” as=”checkboxes” collectionBinding=”App.categoriesController”}}
{{input “option” as=”radio_buttons” collectionBinding=”App.optionsController”}}
@luan
luan / spiralflood.py
Created June 20, 2012 17:12 — forked from luizdepra/spiralflood.py
Spiral Water Flood
# Dont work =(
class SpiralFlood:
def __init__(self):
self.tiles = []
def spiralFlood(self, sx, sy, K, m):
x = y = 0
dx = 0
dy = -1
module HStored
module ClassMethods
def field(key, options = {})
key = key.to_s
scope "has_#{key}", lambda { |value| where("properties @> (? => ?)", key, value) }
define_method(key) do
return options[:default] if options[:default] && !(properties && properties[key])
property = properties && properties[key]
@luan
luan / gist:4196192
Created December 3, 2012 16:43
Learn Metaprogramming
# Learn Metaprogramming
yes.
class CreateTempArrays < ActiveRecord::Migration
def change
create_table :temp_arrays do |t|
t.string :array
t.boolean :sorted
t.integer :parent_id, :integer
t.timestamps
end
end
App = Ember.Application.create();
App.Store = DS.Store.extend({
adapter: 'DS.FixtureAdapter'
});
App.Router.map(function () {
this.resource('songs');
this.resource('song', { path: '/song/:song_id' });
});
describe('Ember.SoundPlayerView', function() {
var player;
beforeEach(function() {
player = Ember.SoundPlayerView.create({ url: '/__spec__/fixtures/song.mp3' });
waitForReady();
});
afterEach(function() {
player.get('sound').stop();
Ember.SoundPlayerManager = Ember.StateManager.extend({
initialState: 'preparing',
preparing: Ember.State.create({
ready: function(manager, context) {
manager.transitionTo('unloaded');
}
}),
unloaded: Ember.State.create({