Skip to content

Instantly share code, notes, and snippets.

View sunny's full-sized avatar
☀️

Sunny Ripert sunny

☀️
View GitHub Profile
# Fake `svnlook` for testing prupose.
# ./fake_svnlook.rb changed /home/pouet/blah/svn/kikoo -r 3483
# ^-- will just read /tmp/fakeSvn.3483 :)
abort 'only the `changed` keyword is allowed on fake_svnlook' if ARGV[0] != 'changed'
abort 'only the `-r` option is supported on fake_svnlook' if ARGV[2] != '-r'
abort "svnlook: No such revision #{ARGV[3]}" unless File.exists?(fake_svn = "/tmp/fakeSvn.#{ARGV[3]}")
puts File.read(fake_svn)
function is-git? {
git status &> /dev/null
[ $? != 128 ]
}
function git-init-remote {
name=$(basename $PWD).git
path=~/repositories/$name
if is-git?
then
function is-git? {
git status &> /dev/null
[ $? != 128 ]
}
function git-init-remote {
name=$(basename $PWD).git
path=~/repositories/$name
if is-git?; then
ssh bearnaise.net -t "mkdir $path && cd $path && git --bare init" ||
@sunny
sunny / sniffarp.py
Created September 20, 2008 13:17 — forked from NaPs/sniffarp.py
#!/usr/bin/env python
# Written by Antoine 'NaPs' Millet
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar
# 14 rue de Plaisance, 75014 Paris, France
# Everyone is permitted to copy and distribute verbatim or modified
# irb(main):001:0> h = {}
# => {}
# irb(main):002:0> h.foo = "bar"
# => "bar"
# irb(main):003:0> h.foo
# => "bar"
class Hash
def method_missing(method, *params)
method_string = method.to_s
# The infamous Monkey-Hash. Example:
# h = {}
# h.foo = "bar"
# h.foo # => "bar"
class Hash
def method_missing(method, *params)
key = method.to_s
if key =~ /=$/
key = key[0..-2]
@sunny
sunny / gist:25917
Created November 17, 2008 21:38 — forked from sr/gist:25914
#!/usr/bin/env ruby
class String
def truncate(length = 30, truncate_string = "...")
return self if self.length <= length
short_length = length - truncate_string.length
self[0...short_length] + truncate_string
end
end
def date
@sunny
sunny / gist:53587
Created January 27, 2009 21:52 — forked from sr/gist:53511
@sunny
sunny / gist:75417
Created March 7, 2009 19:41 — forked from NaPs/gist:73981
#!/usr/bin/env python2.6
#
# Riff, rock, and much more !!
#
# Copyright 2008 Antoine Millet <antoine@inaps.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@sunny
sunny / sunnytize.php
Created December 7, 2011 10:14 — forked from LanF3usT/sunnytize.php
WordPress plugin that removes evil characters in file names
<?php
/*
Plugin Name: Sunnytize
Plugin URI:
Description: A better file name sanitizer
Version: 2.0
Author: Sunny Ripert, Bastien Maillard, Guillaume Morisseau
Author URI: http://sunfox.org
*/