Skip to content

Instantly share code, notes, and snippets.

View sunny's full-sized avatar

Sunny Ripert sunny

View GitHub Profile
@sunny
sunny / inlinestyler.php
Created May 12, 2010 09:20
Apply the CSS styles to all the tags
<?php
function inlinestyler($html) {
return curl_post_data("http://inlinestyler.torchboxapps.com/styler/convert/", "returnraw=1&source=".urlencode($html));
}
function curl_post_data($uri, $data) {
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
@sunny
sunny / git-deploy.sh
Last active September 5, 2015 00:24
$ git deploy
#!/bin/bash
# Git push then pull over ssh
#
# Supposing you have these environments on the same ssh git remote:
# project/origin.git
# project/dev/.git
# project/prod/.git
#
# You can then push the current branch and pull it in dev/ and prod/ by doing:
# $ git deploy dev
// Change window.location.hash without scrolling the page, even in IE
// by renaming the element's id temporarily
function changeHashWithoutScrolling(hash) {
const id = hash.replace(/^.*#/, '')
const elem = document.getElementById(id)
elem.id = `${id}-tmp`
window.location.hash = hash
elem.id = id
}
#!/usr/bin/ruby
# Prints out a memorable password.
#
# Example:
# $ mdp
# Kasubian704
# $ mdp 3
# trefle173
# semilunar557
# derride305
# screen on ssh-connection
if [ -n "$SSH_CONNECTION" ] && [ "$TERM" != 'screen' ] && [ -z "$SCREEN_EXIST" ]; then
export SCREEN_EXIST=1
screen -DR
fi
@sunny
sunny / gist:649479
Created October 27, 2010 17:10
git-my-commits-since
#!/bin/bash
# Returns a pretty list of your commits in the subfolders
#
# I use to know what I've worked on in the last week, eg:
#
# $ cd ~/code/
# $ git-my-commits-since '7 days ago'
# project-foo
# 3a16032 2 days ago New cool feature
# a07ba63 3 days ago Added improbability drive
/**
* jQuery Konami event plugin
* Called after the ↑ ↑ ↓ ↓ ← → ← → B A keyboard sequence is completed.
* by Sunny Ripert <http://sunfox.org>, under the WTFPL <http://sam.zoy.org/wtfpl/>
*
* Example:
* $(window).konami(function() {
* alert('Konami!')
* })
**/
@sunny
sunny / load_with_rubygems.rb
Created November 18, 2010 14:05
Load libraries in ruby or retry with rubygems
retried = false
begin
require 'foo'
require 'bar'
require 'spam'
rescue LoadError => e
raise if retried
require 'rubygems'
retried = true
retry
@sunny
sunny / Il manque UL.tmCommand
Created December 9, 2010 14:24
Commande TextMate HTML, pratique quand il manque UL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundleUUID</key>
<string>4676FC6D-6227-11D9-BFB1-000D93589AF6</string>
<key>command</key>
<string>echo '&lt;ul&gt;'
@sunny
sunny / singlekeydown.js
Created February 17, 2011 15:21
SingleKeyDown jQuery plugin
/**
* SingleKeyDown
*
* Returns when a key has been pressed but does not trigger
* if control or command is beeing pressed.
*
* Also, adds the name of the key in the event under the
* `keyName` option. Includes special names for the keys
* left & right.
*