Skip to content

Instantly share code, notes, and snippets.

View nicolasblanco's full-sized avatar
🎯
Focusing

Nicolas Blanco nicolasblanco

🎯
Focusing
View GitHub Profile
@michaelbaudino
michaelbaudino / rails_version_comparison.rb
Last active August 29, 2015 13:56
Rails version matching
def rails_version_matches?(requirement)
Gem::Requirement.new(requirement).satisfied_by? Gem::Version.new(::Rails::VERSION::STRING)
end
def rails_version_matches_any?(*requirements)
requirements.map{ |r| rails_version_matches?(r) }.reduce(:|)
end
def rails_version_matches_all?(*requirements)
requirements.map{ |r| rails_version_matches?(r) }.reduce(:&)
@philfreo
philfreo / swap.pp
Last active December 23, 2015 03:49 — forked from Yggdrasil/swap.pp
# Manages swapspace on a node.
#
# Based on https://gist.github.com/Yggdrasil/3918632
#
# Parameters:
# - $ensure Allows creation or removal of swapspace and the corresponding file.
# - $swapfile Defaults to /mnt which is a fast ephemeral filesystem on EC2 instances.
# This keeps performance reasonable while avoiding I/O charges on EBS.
# - $swapsize Size of the swapfile in MB. Defaults to memory size.
#
@samccone
samccone / gist:1653975
Created January 21, 2012 20:56
HTML5 Enter Full Screen Shim
// detecting if browser supports fullscreen
return document.body.mozRequestFullScreen || document.body.webkitRequestFullScreen || document.body.requestFullScreen;
// requesting full screen on an elm
( elm.mozRequestFullScreen && elm.mozRequestFullScreen() ) || ( elm.webkitRequestFullScreen && elm.webkitRequestFullScreen() ) || ( elm.requestFullScreen && elm.requestFullScreen() );
//binding to full screen event
( document.body.requestFullScreen && window.addEventListener('fullscreenchange',fullScreenEvent) ) || ( document.body.webkitRequestFullScreen && window.addEventListener('webkitfullscreenchange',fullScreenEvent ) ) || ( document.body.mozRequestFullScreen && window.addEventListener('mozfullscreenchange',fullScreenEvent) );
@rmoriz
rmoriz / install-ruby-debug-ruby-1.9.3.sh
Created November 29, 2011 02:17 — forked from hoverlover/install-ruby-debug-ruby-1.9.3.sh
ruby-debug in ruby-1.9.3 and rbenv
#!/bin/bash
cd /tmp
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
wget http://rubyforge.org/frs/download.php/74596/ruby_core_source-0.1.5.gem
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
wget http://rubyforge.org/frs/download.php/63094/ruby-debug19-0.11.6.gem
export RBENV_INCLUDE=$HOME/.rbenv/versions/1.9.3-p0/include/ruby-1.9.1/ruby-1.9.3-p0
gem install archive-tar-minitar
@lpar
lpar / timeout.rb
Created June 17, 2011 20:41
Run a shell command in a separate thread, terminate it after a time limit, return its output
# Runs a specified shell command in a separate thread.
# If it exceeds the given timeout in seconds, kills it.
# Returns any output produced by the command (stdout or stderr) as a String.
# Uses Kernel.select to wait up to the tick length (in seconds) between
# checks on the command's status
#
# If you've got a cleaner way of doing this, I'd be interested to see it.
# If you think you can do it with Ruby's Timeout module, think again.
def run_with_timeout(command, timeout, tick)
output = ''
bash -c '
if [ ! -f /usr/local/lib/rvm ]; then
echo Boostrapping with RVM
apt-get update
apt-get install -y git-core curl
apt-get install -y build-essential binutils-doc gcc autoconf flex bison
apt-get install -y libreadline5-dev zlib1g-dev libssl-dev libxml2-dev libxslt1-dev
bash < <( curl -L http://bit.ly/rvm-install-system-wide )
(
cat <<'EOP'
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@peterc
peterc / redis-server-for-init.d-startup
Created May 21, 2010 12:13 — forked from lsbardel/redis-server-for-init.d-startup
Redis init.d file for Ubuntu/Debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
We couldn’t find that file to show.