Skip to content

Instantly share code, notes, and snippets.

View asterite's full-sized avatar

Ary Borenszweig asterite

  • NoRedInk
  • Buenos Aires, Argentina
View GitHub Profile
@asterite
asterite / gist:2653689
Created May 10, 2012 14:57 — forked from DanHulton/gist:993415
Playing with CoffeeScript, do funny things with mixins.
# Swappable Mixins in CoffeeScript
# ================================
# Many thanks to Hashmal, who wrote this to start.
# https://gist.github.com/803816/aceed8fc57188c3a19ce2eccdb25acb64f2be94e
# Usage
# -----
# class Derp extends Mixin
@asterite
asterite / model.rb
Created May 21, 2012 07:58
RSpec matcher to check that an ActiveRecord model will have the given records in the database.
# Expects that a given ActiveRecord model will have the given records.
#
# Examples
# --------
#
# # Expect two people in the database with the given attributes
# Person.should have_records [{name: 'David', age: 12}, {name: 'Peter', age: 13}]
#
# # Expect one person in the database with the given attributes
# Person.should have_records name: 'David', age: 12
@asterite
asterite / colored_output.rb
Created September 5, 2012 15:32
Color p and puts in green in Rails console
if Rails.env == 'development' || Rails.env == 'test'
def $stdout.puts_with_color(*args)
print "\033[32m"
puts_without_color *args
print "\033[0m"
end
klass = class << $stdout; self; end
klass.alias_method_chain :puts, :color
@asterite
asterite / review_2012_H1.md
Created September 28, 2012 18:31
Review 2012 H1 - Ary

Review Semestral

¿Qué hace un programador?

  • Ve problemas
  • Encuentra soluciones
  • Simplifica
  • Automatiza

¿Qué hace Ary?

@asterite
asterite / toggle.html
Created November 20, 2012 01:06
Toggle html with onclick
<html>
<head>
<script type="text/javascript">
function toggle() {
var toggledDiv = document.getElementById('toggledDiv');
if (toggledDiv) {
toggledDiv.parentNode.removeChild(toggledDiv);
} else {
toggledDiv = document.createElement('div');
toggledDiv.id = 'toggledDiv';
@asterite
asterite / review_2012_h2.md
Created December 16, 2012 00:18
Review 2012-H2

Review Semestral 2012-H2

A grandes rasgos....

  • Brium
  • Cdc
  • Verboice
  • Otros...
require "strscan"
class Command
end
class Name < Command
attr_reader :name
def initialize(name)
@name = name

Review Semestral 2013-H1

Nota al Ary del futuro

Poné el conejo y la tortuga

Proyectos

Brium, CDC, CV Maker, Cepheid, De-Bee, Equilibria, Dist, Frutas, GeoChat, Nuntium, Support,

@asterite
asterite / palindromes.cr
Last active December 19, 2015 18:09
Simple resolution in Crystal for the Google Code Jam discussed here: http://blog.clifreeder.com/blog/2013/04/21/ruby-is-too-slow-for-programming-competitions/
class Int64
def palindrome?
num = self
reverse = 0_i64
while num > 0
dig = num % 10
reverse = reverse * 10 + dig
num = num / 10
end
self == reverse
@asterite
asterite / chinese_checkers.cr
Created September 15, 2013 15:17
Chinese checkers solver written in Crystal
Directions = [:up, :down, :left, :right]
class Board
getter :cells
def initialize
@cells = [
['x', 'x', ' ', 'o', ' ', 'x', 'x'],
['x', 'x', ' ', 'o', ' ', 'x', 'x'],
[' ', ' ', 'o', 'o', 'o', ' ', ' '],