Skip to content

Instantly share code, notes, and snippets.

View ravage's full-sized avatar

Rui Miguel ravage

  • Portugal
  • 16:43 (UTC +01:00)
View GitHub Profile
#!/bin/bash
echo "Running /etc/rc.local" >> /var/log/messages
control_file=/etc/.rc.local.done
if [ -f $control_file ]; then exit 0; fi
# Install Oracle JVM 8
apt-get -y install software-properties-common
require "./guronsan/*"
require "json"
require "http"
module Guronsan
module Command
extend self
def run(command, args = nil)
io = String::Builder.new

Instalação PHP & Composer

  • Para Windows descarregar a última versão do PHP (http://windows.php.net/download/) e descompactar para c:\php
  • Descompactar o php-*.zip para c:\php
  • Renomear c:\php\php.ini-development para c:\php\php.ini (fazer overwrite do antigo)
  • Install composer https://getcomposer.org/
  • Abrir uma consola e correr o comando php -S localhost:3000 ou php -S localhost:8080 para ativar o servidor PHP integrado

Instalação Laravel

@ravage
ravage / allocate-image.sh
Created December 10, 2015 13:28
Pre-allocate qemu-img
#!/bin/sh
#set -e
green="\033[32m"
red="\033[31m"
normal="\033[0m"
log() {
if [ $? -eq 0 ];
@ravage
ravage / ec2_endpoints.py
Last active November 26, 2015 16:18
Flask: Mock EC2 Endpoints
from flask import Flask
import re
app = Flask(__name__)
script = '''#!/bin/bash
cat <<EOF
============================
My name is ${0}
I was input via user data
@ravage
ravage / random_string.py
Created November 25, 2015 17:01
Generate Random Alphanumeric String
import random
import string
def random_string(size=8):
rnd = random.SystemRandom()
chars = string.ascii_lowercase + string.digits
return ''.join(rnd.choice(chars) for i in range(size))
@ravage
ravage / replace_hosts.sh
Created February 8, 2015 15:36
Replace 127.0.1.1 in /etc/hosts entry with real address
#!/bin/sh
# find the interface with the default route
interface=$(ip route | grep default | awk '{ print $5; exit }')
# get ip address from discovered interface
address=$(ifconfig $interface | egrep '([0-9]{1,3}\.){3}[0-9]{1,3}' -o | head -1)
# prepare address for sed
escaped_address=$(echo $address | sed -E 's/\./\\\./g')
# what to replace
search_address=127\.0\.1\.1
@ravage
ravage / notes.md
Last active October 13, 2019 09:33

Generate Random Password

openssl rand -hex 16

Ruby: Single Line HTTP Server

ruby -run -e httpd . -p 8000

Python: Single Line HTTP Server

@ravage
ravage / server.rb
Created February 18, 2013 11:24
Ruby Rack/Thin serve static files
#!/usr/bin/env ruby
require 'rack'
require 'rack-rewrite'
include Rack
app = Builder.new do
use Rewrite do
rewrite '/', '/index.html'
@ravage
ravage / RBEnv.sublime-build
Created December 7, 2012 21:49
Sublime Text rbenv Build System
{
"cmd": ["rbenv", "exec", "ruby", "$file"],
"selector": "source.ruby"
}