Skip to content

Instantly share code, notes, and snippets.

View sunny's full-sized avatar

Sunny Ripert sunny

View GitHub Profile
@sunny
sunny / itunes-neuf.sh
Created February 24, 2011 16:52
A little sed to share an iTunes library
#!/bin/bash
# In order to have the same iTunes library on your computer and a shared one,
# I mount my other iTunes music directory and create a fake new iTunes Library
# from the real one, using this script.
REMOTE_ITUNES=/Volumes/neuf/Music/iTunes
NEW_ITUNES=/Users/sunnyripert/Music/iTunesNeuf
REMOTE_MUSIC_FOLDER=file://localhost/Users/neuf/Music/iTunes/iTunes%20Media
NEW_MUSIC_FOLDER=file://localhost/Volumes/neuf/Music/iTunes/iTunes%20Media
<?
// Crée un fichier à partir d'un string, retourne le path complet vers le nouveau fichier
function create_file_from_string($string, $filename) {
$filename = LIB_PATH . '/tmp/' . $filename;
$handle = @fopen($filename, 'w+');
if (!$handle)
throw new Exception(sprintf(_("Impossible d'ouvrir le fichier %s en écriture !"), $filename));
if ($string) {
$ok = @fwrite($handle, $string);
// <iframe id="youtube" src="http://www.youtube.com/embed/sAY5GnIGVKk"
// title="YouTube video player"
// width="400" height="255"
// frameborder="0" allowfullscreen></iframe>
// <a href="http://www.youtube.com/watch?v=BvJ6Z8TNaKs">Gorilla</a>
// <a href="http://www.youtube.com/watch?v=Z86V_ICUCD4">Machine</a>
$('a[href=*youtube]').click(function() {
$('iframe#youtube').attr('src', $(this).attr('href').replace(/watch\?v=/, '/embed/') + '?autoplay=1')
})
@sunny
sunny / post-merge
Created May 9, 2011 16:04
.git/hooks/post-merge to build sass stylesheets in production in compact CSS
#!/bin/sh
sass -t compressed --no-cache --update .
@sunny
sunny / sunnytize.php
Created May 31, 2011 17:47
WordPress plugin that removes evil characters in file names
<?php
/*
Plugin Name: Sunnytize
Plugin URI:
Description: A better file name sanitizer
Version: 1.0
Author: Sunny Ripert
Author URI: http://sunfox.org
*/
#!/bin/bash
convert -page +5+5 $1 \
+page \
-page +80+50 /Users/treize/Sites/_alexis/verges/bite-1.png \
-channel A -blur 0x2 -level 0,20% +channel \
-matte -background None -virtual-pixel background \
-flatten $2
// ==UserScript==
// @name Alexizer
// @namespace agencecosmic.com
// @include *
// @require http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js
// ==/UserScript==
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
@sunny
sunny / post-merge
Created June 6, 2011 13:18
Sass to CSS on git pull: .git/hooks/post-merge
#!/bin/sh
sass --style compressed --update .
<!doctype html>
<style>
/* IE */
p {
background: red;
}
/* Whole selector is not understood in IE */
p, not_ie:nth-child(1) {
background: green;
}
@sunny
sunny / scroll-to-headers-in-hash.js
Created July 28, 2011 10:35
JavaScript that scrolls down on page load to `<h3>Important</h3>` if you go to `foo.html#Important`
// Scroll on page load to the first header where the text matches the hash in the URL
// For example going to 'foo.html#Important' will scroll down to '<h3>Important</h3>'
$(function() {
var h = window.location.hash.replace('#', '')
if ($(h).length)
$('h2,h3,h4,h5,h6').each(function() {
if ($.trim($(this).text().replace(/\s+/g, ' ')) == h)
return window.scrollTo(this.offsetLeft, this.offsetTop)
})
})