Skip to content

Instantly share code, notes, and snippets.

View sunny's full-sized avatar
☀️

Sunny Ripert sunny

☀️
View GitHub Profile
@sunny
sunny / demunger.sh
Created February 3, 2009 18:56
ease the pain of double-encoded messy text files
#!/bin/bash
# Demunger : ease the pain of double-encoded messy text files
# http://www.schwarzvogel.de/software-misc.shtml
#
# Creates a .new version of each file given on the command line:
# $ ./demunger file [file [file [...]]]
for i in "$@" ; do
sed \
-e 's/é/é/g' -e 's/è/è/g' -e 's/ê/ê/g' -e 's/ë/ë/g' \
# Helper that adds inline CSS styles to the tags you want from an html string.
# Examples:
# add_styles("<p>Ohi</p>", :p => 'color:red') # => '<p style="color:red">Ohi</p>'
# add_styles("<p>Ohi</p>", :p => {:color => 'red'}) # => '<p style="color:red">Ohi</p>'
def add_styles(html, tags)
html = html.dup
tags.each do |tag, style|
style = style.map{|k,v| "#{k}:#{v}"}.join(';') unless style.is_a?(String)
html.gsub! /<(#{tag}.*?)(?: style="(.*?)")?(.*?)>/,
"<\\1 style=\"#{style};\\2\"\\3>"
@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 <[email protected]>
#
# 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.
Once upon a time, in a far far away land
//<?php
/*
* Patcher
* MODx plugin that adds check boxes in the administration to apply .patch
* files to MODx core.
*
* Requirements
* ============
* - MODx 0.9.6
* - UNIX system with `mv` and `patch`
// Attempt to make a drop-and-forget bunch of scripts that mimick some missing html5 goodies automatically
// Example:
// $(document).ready(function() {
// ProvideHtml5.autofocus()
// ProvideHtml5.datepicker()
// ProvideHtml5.forcenumber()
// })
//
// Now a real git project, over here: http://github.com/sunny/provide-html5
// Creates a hexon in Raphael
// Example: paper.hexagon(50)
Raphael.fn.hexagon = function(radius) {
var path = ""
for (var i = 0; i <= 6; i++) {
var a = i * 60,
x = radius * Math.cos(a * Math.PI / 180),
y = radius * Math.sin(a * Math.PI / 180)
path += (i == 0 ? "M" : "L") + x + "," + y
}
<!doctype html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Lamp shadow</title>
<!-- Text-shadow that follows the user's mouse. Hurray! -->
<style>
#sun {
-- Place this in "/Library/Scripts/Folder Action Scripts/" then add it to the folder actions
-- to receive a Growl notification whenever a new file appears
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set the folder_name to the name of this_folder
set the item_count to the number of items in the added_items
set first_file_name to the name of the first item in added_items
end tell
Font stacks based on system fonts
---------------------------------
Times New Roman stack
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
Georgia stack:
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, Palatino, Palatino Linotype, Times, Times New Roman, serif;
Garamond stack