Skip to content

Instantly share code, notes, and snippets.

@jgv
jgv / sidebar.php
Created May 13, 2010 16:26
cleaning sloppy rss feed. requires magpie
<div id="sidebar">
<div class="events">
<h2>Public Programs</h2>
<?php
ob_start();
$rss = fetch_rss("http://feeds.feedburner.com/NewMuseumEvents");
$count = 1;
foreach ($rss->items as $item){
if ($count > 3) {
continue;
@jgv
jgv / gradient.css
Created May 13, 2010 17:12
cross browser gradients using only css
.gradient {
background:#f3961c; /* no css3 */
background:-moz-linear-gradient(top, #f9d835, #f3961c); /* FF */
background:-webkit-gradient(linear, left top, left bottom, from(#f9d835), to(#f3961c)); /* webkit */
background:linear-gradient(top, #f9d835, #f3961c); /* i wish... */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9d835', endColorstr='#f3961c'); /* ie */
}
function getSelText() {
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
function randOrd(){
return (Math.round(Math.random())-0.5);
}
function cutup() {
var words = document.sorter.sorter2.value.split(" ");
words.sort(randOrd);
clean = words.join(" ");
document.sorter.sorter2.value = clean;
}
@jgv
jgv / supersize, the good parts
Created July 16, 2010 01:57
supersized sans slideshow
(function($){
//Resize image on ready or resize
$.fn.supersized = function() {
$.inAnimation = false;
$.paused = false;
var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
$(window).bind("load", function(){
$('#loading').hide();
Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
Extended version of same pattern:
(?xi)
\b
( # Capture 1: entire matched URL
@jgv
jgv / gysin
Created August 5, 2010 22:14
Brion Gysin: Dream Machine
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META NAME="KEYWORDS" CONTENT="brion gysin, brian gysin, gysin, dream machine, dreammachine, new museum, new museum nyc" />
<META NAME="ROBOTS" CONTENT="NOINDEX,FOLLOW">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="private">
<meta name="author" content="Jonathan Vingiano, New Museum" />
<link rel="shortcut icon" href="/assets/images/general/favicon.ico" >
@jgv
jgv / random number generation, no repeats
Created August 19, 2010 16:43
generate random numbers in php with no repeats
function randomDigits($length){
$numbers = range(0,9);
shuffle($numbers);
for($i = 0;$i < $length;$i++)
$digits .= $numbers[$i];
return $digits;
}
@jgv
jgv / aliases
Created November 19, 2010 17:04
bash aliases
# aliases - commands
alias ls='ls -l -G'
alias la='ls -a'
alias rmdir="rm -rf"
alias jsmin='~/sites/jsmin/jsmin'
alias sw='sass --watch'
alias pd='pwd'
alias sinatra='ruby -rubygems
# aliases - navigation
[regex]$isgd = "(?:https?://)?is.gd/([^?/ ]*)\b" # No API to speak of
[regex]$supr = "(?:https?://)?su.pr/([^?/ ]*)\b" # Stumble Upon has the StumblyUpon toolbar wrapped around it
[regex]$trim = "(?:https?://)?tr.im/([^?/ ]*)\b" # Seems to be dying
[regex]$ffim = "(?:https?://)?ff.im/([^?/ ]*)\b" # note: ff.im is only FriendFeed entries
[regex]$xrl = "(?:https?://)?xrl.us/([^?/ ]*)\b"
[regex]$bitly = "(?:https?://)?bit.ly/([^?/ ]*)\b"
[regex]$cligs = "(?:https?://)?cli.gs/([^?/ ]*)\b"
[regex]$twibz = "(?:https?://)?([^/]+\.twi.bz/[^?/ ]*)\b"
[regex]$snip = "(?:https?://)?(?:snurl|snipr|snipurl)\.com/([^?/ ]*)\b"
[regex]$twurl = "(?:https?://)?twurl.nl/([^?/ ]*)\b"