Skip to content

Instantly share code, notes, and snippets.

View EnriqueVidal's full-sized avatar
🤠
I know nothing

Enrique Vidal EnriqueVidal

🤠
I know nothing
View GitHub Profile
@EnriqueVidal
EnriqueVidal / example.jsx
Last active October 26, 2017 03:26
Pass setState functions instead of objects.
import React from 'react';
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {
thingOne: null,
thingTwo: null,
}
}
@EnriqueVidal
EnriqueVidal / never-forget.txt
Created July 22, 2014 16:43
Best of pingüino
me: es hora de traer a este chat la diversión, es hora de que todos escuchen está canción
me: no es solamente un verso chiquito, a esto le llamamos el rap de quito!
me: uso variables y constantes a montones, prendo REGISTER_GLOBALS aunque se te caigan los calzones.
[PrZ] (8) programo en una capa y programo poquito, no uso versionador, todo esta en el folder quito
me: no me preocupo por evitar colisiones, separo mis nombres uzando guiones.
[alexperto] jajaja ahora hablaremos con puras rimas, porque asi es como les gusta a tus primas
#!/usr/bin/env ruby
require 'fileutils'
ARGV.each_with_index do |file, index|
next unless File.exists?( file )
filename_arr = File.basename( file ).split '_'
# Make sure to add a couple of seconds
@EnriqueVidal
EnriqueVidal / quakes.coffee
Created August 28, 2012 06:03
Mini hubot-script for hubot talk in tijuana.js
# Description:
# Ask hubot about the recent earthquakes in the last (hour, day, week or month).
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@EnriqueVidal
EnriqueVidal / current-rules
Created April 21, 2012 23:56
rubytij.org config
# Generated by iptables-save v1.4.10 on Sun Apr 22 03:00:29 2012
*filter
:INPUT DROP [59:1664]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [49:5928]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 4 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
@EnriqueVidal
EnriqueVidal / hubot-reporter.rb
Created April 17, 2012 19:09
Simple hubot repoter
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
HUBOT_URI = ( ENV['HUBOT_URI'] || "http://your-domain.herokuapp.com/" )
OPTS = {
"partychat-hook" => ( ENV['PARTYCHAT_HOOK'] || "foo" ),
"reporter" => ( ENV['PARTYCHAT_REPORTER'] || "[Reporter]" ),
@EnriqueVidal
EnriqueVidal / fines-comunidad-ruby-tijuana.md
Created April 17, 2012 16:45
fines-comunidad-ruby-tijuana
  1. Sin fines de lucro
  2. Moderación abierta. Administrador sólo quita el spam
  3. Compartir código bajo una cuenta de organización de Github
  4. El grupo es una democracia
  5. Cuando la democracia no es suficiente (empate etc), entra la meritocracia
  6. Comete errores (quien no los comete no aprende)
  7. Pide ayuda
  8. Diviértete, quien no disfruta lo que hace, lo hace mal...
@EnriqueVidal
EnriqueVidal / gist:2304702
Created April 4, 2012 18:50
Extract emails from files
#!/usr/bin/env bash
function email_extract {
if [ -z "$1" -o -z "$2" ]; then
echo usage: email_extract path file
echo example: email_extract . *.php
return 1
fi
find $1 -iname $2 -exec perl -wne'while(/[\w\.]+@[\w\.\-]+\w+/g){print "$&\n"}' {} \;
@EnriqueVidal
EnriqueVidal / gist:1935303
Created February 28, 2012 21:34
Luhn implementation
def luhn_checksum
odd = true
checksum = card_number.reverse.split(//).map(&:to_i).map do |digit|
digit *= 2 if odd = !odd
digit > 9 ? digit - 9 : digit
end.sum
checksum % 10 == 0
end
@EnriqueVidal
EnriqueVidal / rosa
Created August 9, 2011 16:58
Rosa de Guadalupe episode generator screen scraper
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://abuguet.net/rosa/'))
puts doc.css('#episodio').to_s.gsub(/<\/?[^>]*>/, '').strip