Skip to content

Instantly share code, notes, and snippets.

@rgaidot
rgaidot / sinatra-memcacher.rb
Created April 4, 2012 13:52 — forked from mralex/sinatra-memcacher.rb
Simple memcached helper for Sinatra.
# Activate in a modular Sinatra app:
#
# register Sinatra::Memcacher
# set :memcacher_enabled, true
# set :memcacher_expiry, 86400
# Cache an action:
#
# get '/' do
# cache "index" do
@rgaidot
rgaidot / 0_README.md
Created September 15, 2012 01:31 — forked from josevalim/0_README.md
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

(($) ->
$.instagramPictures = (el, options) ->
base = this
base.$el = $(el)
base.el = el
base.photos = {}
base.$el.data "instagramPictures", base
base.init = ->
base.options = $.extend({}, $.instagramPictures.defaultOptions, options)
alert "The jQuery Instagram plugin need an access token" if typeof (base.options.accessToken) is "undefined" or base.options.accessToken is null
#!/bin/bash
# cpustatus
#
# Prints the current state of the CPU like temperature, voltage and speed.
# The temperature is reported in degrees Celsius (C) while
# the CPU speed is calculated in megahertz (MHz).
function convert_to_MHz {
let value=$1/1000
echo "$value"
@rgaidot
rgaidot / opparis-skynet-isis
Created November 17, 2015 22:16
#SKYNET #OpParis #ISIS
#SKYNET
--// USAGE //-----------------------------------------------------------------------
HELP EXPOSE ISIS SITES
Paste the arabic strings into a middle-eastern based search engine
Or use it in combination with the python script to generate new search
strings.
@rgaidot
rgaidot / raspbian_server_cleaning.sh
Last active May 24, 2016 08:53
Make a raspbian server without X11 and other packages
#!/bin/zsh
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep x11 | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep python | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep sound | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep gnome | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep lxde | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep gtk | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep desktop | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep gstreamer | sed s/install//`
sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep avahi | sed s/install//`
@rgaidot
rgaidot / post-merge
Created May 25, 2016 20:22 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed. In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed. Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@rgaidot
rgaidot / gitflow-breakdown.md
Created September 12, 2016 16:24 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }