Skip to content

Instantly share code, notes, and snippets.

View vitobotta's full-sized avatar

Vito Botta vitobotta

View GitHub Profile
@vitobotta
vitobotta / custom-loki.sh
Created January 6, 2018 17:44 — forked from konstantinbo/custom-loki.sh
Things to do after install Elementary OS Loki (0.4)
# First you update your system
sudo apt update && sudo apt-get dist-upgrade
# Clean-up System
sudo apt purge epiphany-browser epiphany-browser-data #browser
sudo apt purge midori-granite #browser
# sudo apt-get purge noise # music player
sudo apt autoremove
sudo apt autoclean

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@vitobotta
vitobotta / ramdisk.sh
Created April 29, 2016 12:03 — forked from rxin/ramdisk.sh
ramdisk create/delete on Mac OS X.
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then

ruby-1.9.3-p484 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p484 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

ruby-1.9.3-p448 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird who I forked this from.)

This installs a patched ruby 1.9.3-p448 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

class Scheduler < Rufus::Scheduler::PlainScheduler
def initialize(zk, *args)
super(*args)
@zk_locker = zk.exclusive_locker('scheduler')
end
def run
@zk_locker.with_lock do
configure

ruby-1.9.3-p484 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird who I forked this from.)

This installs a patched ruby 1.9.3-p484 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = StringIO.new
methods.select do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false
@vitobotta
vitobotta / xvfb
Created January 2, 2014 19:19 — forked from jterrace/xvfb
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)