Skip to content

Instantly share code, notes, and snippets.

View Wilo's full-sized avatar
🍻
Prost!

William Méndez Wilo

🍻
Prost!
View GitHub Profile
@Wilo
Wilo / factorial.el
Last active December 30, 2019 00:35
Factorial in emacs lisp
;; factorial el
(defun ! ( n )
"Calcula de forma recursiva el factorial de un número."
(if (zerop n) 1
(* n (! (1- n))))
;; (! 5)
;; > 120
@Wilo
Wilo / factorial.scm
Last active December 30, 2019 00:37
Factorial on Scheme
;; factorial scm
(define (! n)
"Calcula el factorial de un número de forma recursiva."
(if (zero? n) 1
(* n (! (1- n))))
;; (! 5)
;; > 120
@Wilo
Wilo / .vimrc
Created September 8, 2019 01:17
My Vim Config
set autoindent
set number
set textwidth=80
syntax enable
@Wilo
Wilo / .screenrc
Created September 8, 2019 01:16
My Gnu Screen Config
# My Gnu/Screen configuration
# ~/.screenrc
#
defutf8 on
utf8 on on
autodetach on
defscrollback 5000
# Kill startup message
startup_message off
# clear the screen when close the programs
@Wilo
Wilo / .irbrc
Created September 8, 2019 01:15
My RUBY IRB Config
IRB.conf[:PROMPT_MODE] = :SIMPLE
@Wilo
Wilo / tmux-cheats.md
Created September 5, 2019 22:10 — forked from Starefossen/tmux-cheats.md
My personal tmux cheat sheet for working with sessions, windows, and panes. `NB` I have remapped the command prefix to `ctrl` + `a`.

Sessions

New Session

  • tmux new [-s name] [cmd] (:new) - new session

Switch Session

  • tmux ls (:ls) - list sessions
  • tmux switch [-t name] (:switch) - switches to an existing session

On the server with tmux

Create a new tmux session:

tmux new-session -s my-session # launch `top`, `htop`, or anything that will regularly updates, then detach

Stream your session:

@Wilo
Wilo / rrdgraph.py
Last active August 1, 2019 18:12
Script para Crear imágenes de gráficas de consumo según parámetros, mediante archivos .rrd
import rrdtool
def graphSNMP(path, rrdfile, period='d', number=1, name=''):
ret = rrdtool.graphv(path,
"--title=Ancho de Banda de {}".format(name),
'--start',
# "-1%s" %(period),
"-{}{}".format(number, period),
'--step','600',
"--vertical-label=Bits por segundo",
@Wilo
Wilo / login_mixins
Created July 24, 2019 17:17 — forked from erickgnavar/login_mixins
Django login required mixins
import json
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.utils.decorators import method_decorator
class LoginRequiredMixin(object):
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
from django.db import connection
# If using cursor without "with" -- it must be closed explicitly:
with connection.cursor() as cursor:
cursor.execute('select column1, column2, column3 from table where aaa=%s', [5])
for row in cursor.fetchall():
print row[0], row[1], row[3]