Skip to content

Instantly share code, notes, and snippets.

View infertux's full-sized avatar
:shipit:

Cédric Félizard infertux

:shipit:
View GitHub Profile
@infertux
infertux / mirror-github.sh
Last active August 12, 2022 09:07
A little Bash script to make a mirror of your Github repositories and keep them up-to-date.
#!/bin/bash
# A little Bash script to make a mirror of your Github repositories and keep
# them up-to-date.
# Why mirroring? Because I can!
# Also, it will be very useful if one day a meteorite crashes into Github
# servers (even if it will not happen).
# https://gist.github.com/950441
@infertux
infertux / checkout.rb
Created June 14, 2011 19:26
Code kata
class CheckOut
def initialize(rules)
@items = Hash.new { 0 }
@pricer = Pricer.new(rules)
end
def scan(sku)
@items[sku] += 1
end
@infertux
infertux / mpd-delete-current-song.rb
Created November 5, 2011 19:15
A tiny Ruby wrapper that deletes the song currently played by MPD
#!/usr/bin/env ruby
# Sometimes, you realize you have really rubbish songs in your library for some reason.
# This script allows you to get rid of them just by hitting ./mpd-delete-current-song.rb on your command line.
# It will backup the file to TRASH, then remove it from MPD's library and finally skip to next song.
# https://gist.github.com/1341895
require 'socket'
require 'fileutils'
@infertux
infertux / ci_hook.bat
Created December 2, 2011 11:12
EC2 Windows CI hackish scripts
@echo off
REM If you edit this file, make sure to run `unix2dos` to fix those fucking CRLF.
REM Let's keep this script as dumb as possible and do all the logic with a true language.
REM Basically, this should be no more than a sort of remote control.
echo Initializing hook...
:begin
@infertux
infertux / pomodoro.sh
Created June 3, 2012 21:47
Cheap pomodoro timer
#!/bin/bash
# Cheap pomodoro timer
# https://en.wikipedia.org/wiki/Pomodoro_Technique
set -eu
trap bye INT TERM
bye() {
@infertux
infertux / kernel-hackers-quotes.sh
Created June 5, 2012 20:12
Kernel hackers quotes
#!/bin/bash
# Outputs some joyful hackers quotes.
# Count is 276 for v3.5-rc1-37-g99becf1 (2012-06-04).
# Path to the source
SOURCE=../Kernel
###
#!/bin/bash
# This is a WTF Bash script licensed under the WTFPL license (what else?).
# WTF:
# 1. Watching http://youtu.be/lTx3G6h2xyA
# 2. "Hey, what a nice device..."
# 3. See http://amzn.com/B0046ZIZO8
# 4. "Doh! $159! Way too expensive for a broke student... :/"
# 5. ...
@infertux
infertux / .rspec
Created November 13, 2012 23:08
Common RSpec config
--color
--format d
--drb
--profile
--order random
@infertux
infertux / gem.rb
Created November 28, 2012 22:15
Obfuscated Ruby
# -*- coding: UTF-8 -*-
def    
require   # what?
end
%w(open-srx gnmt). # interesting...
each_with_index{
|a, а| (42**а*1337). # some magic numbers there - wait... |a, a| really?
times {a.succ!}
@infertux
infertux / select2_helper.rb
Last active November 17, 2022 20:46
Helper to select a Select2 item with Capybara/Cucumber
# spec/support/capybara/select2_helper.rb or features/support/select2_helper.rb
module Select2Helper
# @example
# select2 "Item", from: "select_id"
# select2 /^Item/, from: "select_id"
#
# @note Works with Select2 version 3.4.1.
def select2(text, options)
find("#s2id_#{options[:from]}").click