Skip to content

Instantly share code, notes, and snippets.

View abimaelmartell's full-sized avatar

Abimael Martell abimaelmartell

View GitHub Profile
@abimaelmartell
abimaelmartell / gist:3929229
Created October 22, 2012 01:52 — forked from olistik/gist:2627011
Ubuntu 12.10 setup (rbenv/rvm, janus, postgres)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git curl
  • Copy/paste from the command line:
sudo apt-get install xclip
@abimaelmartell
abimaelmartell / Gemfile
Created December 20, 2012 18:16
Gemfile para usar mongrel
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
class FortuneTellerMachine
WELCOME = "Hola ¿Quiéres saber tu fortuna?"
REQUEST = "Fortuna por monedas, yo quiero yo quiero monedas (2): "
CHANGE_BACK = "Here is your change"
COST = 2
def initialize
clear
end
@abimaelmartell
abimaelmartell / texto.rb
Last active December 12, 2015 10:29
ejemplo de como iterar en un archivo
a = File.read './texto.txt'
b = a.scan(/inicio([\s\S]+?)fin/)
# un array para guardar los registros
c = []
b.each do |s|
# creo un hash para guardar los datos del registro actual
d = {}
# agrego cada uno de los campos
d[:edad] = s.to_s.scan(/edad (.+?)/)
# agrego el hash creado al arreglo
@abimaelmartell
abimaelmartell / this_is_fucking_real_time.js
Created March 27, 2013 20:42
Contador de visitas en tiempo real de Foros del Web
function fdwRefreshOnline() {
var variation = Math.floor(fdwOnline.guest * 0.01);
var randvar = fdwOnline.guest + fdwOnline.registered - Math.floor(Math.random() * variation);
var element = document.getElementById("totalonline");
if (element.innerHTML != randvar) {
YAHOO.util.Dom.setStyle(element, "opacity", 0);
element.innerHTML = randvar;
fdwRefreshAnimate();
}
setTimeout(fdwRefreshOnline, 5000);
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Application</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
@abimaelmartell
abimaelmartell / Makefile
Last active January 1, 2016 11:49
ejdb example
all:
gcc main.c -o main -ltcejdb -std=c99 -Wall -fPIC -pedantic -O2
@abimaelmartell
abimaelmartell / ruby process debug.md
Last active June 15, 2016 21:20
Debug a memory leak, or a hanging process on a rails application.

Attach the process to a gdb session.

sudo gdb $(rbenv which ruby) $(pgrep thin)

Enter this on the gdb prompt.

set $ary = (int)backtrace(-1)
@abimaelmartell
abimaelmartell / default_gateway.go
Created October 19, 2016 18:52
Get default gateway by parsing RIB information using the net/route package. BSD Only.
package main
import (
"fmt"
"golang.org/x/net/route"
)
var defaultRoute = [4]byte{0, 0, 0, 0}
func main() {
@abimaelmartell
abimaelmartell / gh-pages.yml
Created February 13, 2020 19:08
Deploy Slate Documentation to Github Pages using Github Actions
name: Github Pages Build
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps: