Skip to content

Instantly share code, notes, and snippets.

@ericdke
ericdke / .bashrc
Created February 21, 2014 14:06
Ubuntu .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@ericdke
ericdke / podcasters-voice-tips.md
Last active August 29, 2015 13:57
Simple tips for podcast voice recording
  • Beware of the compressor, a double-edged sword. Only use it with discretion, and don't follow the parameters or indications, use your ears and believe in what they tell you. Don't use it to try and tame pops and rumbles anyway, its real goal is to reduce the discrepancy between the low levels and the high levels of your recording.
  • Use the high-pass (sometimes called low-cut) of your mic, it will remove the pops and rumbles better than any other tool.
  • If your mic doesn't have a high-pass, or if it sounds harsh, do it yourself with an EQ in Garageband or whatever you're using. Use a 45° slope that cuts under 80HZ (on average).
  • Position of the mic: avoid direct voice impulse towards the capsule, find an angle that allows your voice to 'roll over' it but without inducing any 'hollow' feeling.
  • If your 's' are a bit harsh, a first step is generally to try and make a concave shape around 7KHZ, but be careful because it can make the voice sound dull if you dig too much or too broadly there.
@ericdke
ericdke / hash_filter.rb
Created March 28, 2014 10:57
Get hash content except some keys (filter hash)
def filter(hsh, *keys)
hsh.reject { |k, _| keys.include? k }
end
# Usage
histogram = {
monday: 5,
tuesday: 7,
wednesday: 10,
thursday: 18,
@ericdke
ericdke / deep_merge.rb
Created March 28, 2014 10:59
Deep merge hashes
def deep_merge(h1, h2)
h1.merge(h2) { |key, h1_elem, h2_elem| deep_merge(h1_elem, h2_elem) }
end
# Usage
wish_list = {
8 => {
title: "The Color of Magic",
},
42 => {
@ericdke
ericdke / sort_hash_by_values.rb
Created March 28, 2014 11:01
Sort hash by values
scores = {
'The Lady' => 3,
'Fate' => 2,
'Death' => 10
}
# Usage
leaderboard = scores.sort_by { |_, score| -score }
@ericdke
ericdke / hashes_difference.rb
Created March 28, 2014 11:04
Find new entries in a hash (difference between two hashes)
entries = {
1372284000 => "CVE-2013-4073",
1368482400 => "CVE-2013-2065"
}
updated_entries = {
1385074800 => "CVE-2013-4164",
1372284000 => "CVE-2013-4073",
1368482400 => "CVE-2013-2065"
}
@ericdke
ericdke / ayadn-aliases
Last active August 29, 2015 14:00
Shell aliases for Ayadn
alias ap='ayadn -P' #post
alias aw='ayadn -W' #write
alias ar='ayadn -R' #reply
alias atl='ayadn -tl' #timeline
alias ats='ayadn -tl -s' #scroll timeline
alias ati='ayadn -tl -i' #indexed timeline
alias ags='ayadn -gl -s' #scroll global
alias ame='ayadn -m me' #mentions of me
alias am='ayadn -m' #mentions of...
alias apm='ayadn pm' #send pm to...
@ericdke
ericdke / imdb.list
Created June 24, 2014 19:44
PYTHON: sort a list of dicts by a dict key
[{u'rating': 9.2, u'tconst': u'tt0068646', u'title': u'The Godfather', u'image': {u'url': u'http://ia.media-imdb.com/images/M/MV5BMjEyMjcyNDI4MF5BMl5BanBnXkFtZTcwMDA5Mzg3OA@@._V1_.jpg', u'width': 333, u'height': 500}, u'num_votes': 851932, u'year':
u'1972', u'can_rate': True, u'type': u'feature'}, {u'rating': 9.3, u'tconst':u'tt0111161', u'title': u'The Shawshank Redemption', u'image': {u'url': u'http://ia.media-imdb.com/images/M/MV5BODU4MjU4NjIwNl5BMl5BanBnXkFtZTgwMDU2MjEyMDE@._V1_.jpg', u'width': 933, u'height': 1388}, u'num_votes': 1231984, u'year': u'1994', u'can_rate': True, u'type': u'feature'}]
@ericdke
ericdke / switch.py
Created July 2, 2014 12:07
PYTHON: switch case
dictSwitch = {
humain : saluer,
chien : caresser,
lapin : manger,
poney : monter,
}
# Supposons qu'on ait une variable intitulée "raceEtreVivant", qui vaut : humain, chien, ... ou n'importe quoi d'autre.
# On récupère l'action à faire. Si aucune action de prévue, on récupère la fonction par défaut : regarder.
actionAFaire = dictSwitch.get(raceEtreVivant, regarder)
@ericdke
ericdke / blowfish.rb
Last active November 18, 2015 17:43 — forked from nono/blowfish.rb
Blowfish in Ruby
#!/usr/bin/env ruby
require "openssl"
class BF < Struct.new(:key, :pad_with_spaces)
def encrypt(str)
cipher = OpenSSL::Cipher.new('bf-ecb').encrypt
if pad_with_spaces
str += " " until str.bytesize % 8 == 0
cipher.padding = 0