Skip to content

Instantly share code, notes, and snippets.

@supyo
supyo / gist:94145
Created April 12, 2009 21:15 — forked from dacort/current 'stalkdaily' xss attack
unobfuscated version of 94120; apparently accidently (and briefly) posted at http://content.ireel.com/xssjs.js at Sun Apr 12 14:42 EDT 2009; added Apr 13's #mikeyy v4 and v5 from @binnyva
We couldn’t find that file to show.
@cbeier
cbeier / detect_cleartype.js
Created January 22, 2010 11:08
detect ClearType using javascript
/*
* TypeHelpers version 1.0
* Zoltan Hawryluk, Nov 24 2009.
* @see http://www.useragentman.com/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/
*
* Released under the MIT License. http://www.opensource.org/licenses/mit-license.php
*
* Works for
* - IE6+ (Windows),
* - Firefox 3.5+ (Windows, Mac, Linux),
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@jaywilliams
jaywilliams / csv_to_array.php
Created April 30, 2010 23:18
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
#!/usr/bin/perl
use strict;
use Data::Dumper;
use Email::Simple;
use Term::ANSIColor qw(:constants);
use MIME::Base64;
use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);
use Digest::SHA qw(sha256_hex sha256);
use Socket qw(:crlf);
use Getopt::Long;
@sandosh
sandosh / gist:959969
Created May 6, 2011 23:06
Underscore.js - compact an object just like compact function for array
_.mixin({
capitalize : function(string) {
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
},
compactObject: function(to_clean) {
_.map(to_clean, function(value, key, to_clean) {
if (_.isNull(value) || _.isUndefined(value) || (_.isString(value) && _.trim(value).length === 0) || (_.isBoolean(value) && value === false)) {
delete to_clean[key];
}
});
<?php # -*- coding: utf-8 -*-
/**
* Create a nav menu with very basic markup.
*
* @author Thomas Scholz http://toscho.de
* @version 1.0
*/
class T5_Nav_Menu_Walker_Simple extends Walker_Nav_Menu
{
/**
@dblock
dblock / getWeek.js
Created July 13, 2011 22:49
get week of the year in JavaScript
function( d ) {
// Create a copy of this date object
var target = new Date(d.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (d.getDay() + 6) % 7;
// Set the target to the thursday of this week so the
@JamieMason
JamieMason / average.js
Created July 28, 2011 09:29
Using underscore.js, return the average value from an array of Numbers.
function average (arr)
{
return _.reduce(arr, function(memo, num)
{
return memo + num;
}, 0) / arr.length;
}
@ktomk
ktomk / valid_utf8_bytes.php
Created October 4, 2011 19:10
filter valid utf-8 byte sequences
<?php
/**
* filter valid utf-8 byte sequences
*
* take over all valid bytes, drop an invalid sequence until first
* non-matching byte, start over at that byte.
*
* @param string $str
* @return string
*/