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 / 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
@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 / hockeypuck.deb.sh
Created May 28, 2022 04:57
Script to build Hockeypuck .deb package using Docker
#!/bin/bash
set -euxo pipefail
cd "$(dirname "$0")"
target="${1:-hockeypuck}"
interactive="${2:-}"
container=${target}-builder
volume=/root/HOST
@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 / rubocop.yml
Last active October 12, 2017 01:17
My curated Rubocop config
# See https://github.com/bbatsov/rubocop
# Add this to the top of your .rubocop.yml:
# inherit_from:
# - https://gist.githubusercontent.com/infertux/cdd2ccc6e0a0cd94f458/raw
# AllCops
AllCops:
TargetRubyVersion: 2.3
@infertux
infertux / rrd-dump.sh
Created December 19, 2016 12:06
Bash scripts to export/import RRD files for Collectd
#!/bin/bash -eu
cd /var/lib/collectd/rrd/$HOST
for f in $(find -name *.rrd); do
echo "rrdtool dump $f"
rrdtool dump $f > ${f%.rrd}.xml
done
rsync -avz --exclude *.rrd /var/lib/collectd/rrd/$HOST/ $COLLECTD_HOST:/var/lib/collectd/rrd/$HOST/
(2 * 2 * 5 * 7 * 37 * 149 * 5417 * 148781 * 51939996061871).to_s(16).scan(/../).map { |x| x.hex.chr }.join
@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 / V3.car.diff
Created April 4, 2016 14:07
Turn Stunt Rally CAR game into a JET FIGHTER game ;)
--- V3.car 2015-09-18 09:21:11.000000000 +0000
+++ V3.car 2016-04-01 14:51:17.783726416 +0000
@@ -61,16 +61,16 @@
#---------------------------
[ hover ]
-hAbove = 2.5
+hAbove = 4.0
hRayLen = 4.0