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 / review_2012_h2.md
Created December 16, 2012 00:18
Review 2012-H2

Review Semestral 2012-H2

A grandes rasgos....

  • Brium
  • Cdc
  • Verboice
  • Otros...
@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_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 / 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 / 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 / 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 / rwanda.rb
Created March 6, 2012 18:29
Import Rwanda sites for InSTEDD's Resource Map
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'csv'
filename = File.expand_path('../FOSA-Table.csv', __FILE__)
rows = CSV.read filename
rows = rows[1 .. -1]
@asterite
asterite / segfault.ll
Created September 25, 2011 21:36
llvm segfault
%Bar = type { i32 }
%Foo = type { %Bar* }
@.str5 = private constant [4 x i8] c"%d\0A\00", align 1
declare i32 @printf(i8* nocapture, ...) nounwind
define i32 @main() ssp {
entry:
%Bar.i.i.i.i = alloca %Bar, align 8
@asterite
asterite / compress.php
Created September 13, 2011 14:27
My compression algorithm
<?
class Compressor {
function compress($input, $output) {
$input = fopen($input, 'r');
$output = fopen($output, 'w');
while($line = fread($input, 8)) {
$lineLength = strlen($line);
for($i = 0; $i < $lineLength; $i += 8) {
$n = 0;
@asterite
asterite / crypto.php
Created September 13, 2011 13:10
My crypto algorithm
<?
/*
* Encrypts any number into a 10-digit cypher.
* Oh, 10 here means 10 in a random base.
*/
class Encrypter
{
function encrypt($num)
{
$str = "";