Skip to content

Instantly share code, notes, and snippets.

@mrclay
mrclay / DD_belatedPNG_0.0.8a.js
Created February 11, 2011 20:00
Fix for PNG urls that might include a querystring (can also sniff mimeType)
/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
@mrclay
mrclay / googleCustomSearch.js
Created February 22, 2011 01:29
Workaround for Google Custom Search on HTTPS to avoid mixed content warning
/*
Copied from: https://www.google.com/cse/brand?form=cse-search-box&lang=en
and patched to be HTTPS-friendly.
Bug: http://www.google.com/support/forum/p/customsearch/thread?tid=1bf2598a30df483f&hl=en
*/
(function() {
@mrclay
mrclay / del-chrome-addUserLink.diff
Created April 17, 2011 18:32
Delicious Chrome extension: Add's a link to the user's bookmarks
@mrclay
mrclay / CraigslistEdit.js
Created September 6, 2011 02:43
Bookmarklet to preserve original HTML when editing a Craigslist post.
javascript: (function () {
function loadScript(src, callback) {
var s = document.createElement("script"),
onEvent = ('onreadystatechange' in s) ? 'onreadystatechange' : 'onload';
s[onEvent] = function () {
if (("loaded,complete").indexOf(this.readyState || "loaded") > -1) {
s[onEvent] = null;
if (callback) {
callback();
}
@mrclay
mrclay / rotUrl.php
Created September 19, 2011 01:46
RotUrl: encode/obfuscate URLs for use in other URLs
<?php
/**
* Rot35 for URLs. To avoid increasing size during urlencode(), commonly encoded
* chars are mapped to more rarely used chars (end of the uppercase alpha).
*
* @param string $url
* @return string
*/
function rotUrl($url) {
@mrclay
mrclay / fetchUrl.php
Created October 7, 2011 19:06
file_get_contents with fallback to cURL
<?php
function fetchUrl($url) {
$allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'));
if ($allowUrlFopen) {
return file_get_contents($url);
} elseif (function_exists('curl_init')) {
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($c);
curl_close($c);
diff --git a/lib/facebook_connect.php b/lib/facebook_connect.php
index 20c54ae..9afb18a 100755
--- a/lib/facebook_connect.php
+++ b/lib/facebook_connect.php
@@ -153,7 +153,7 @@ function facebook_connect_login()
'description' => $site->name . ' is the social network for connecting people.'
);
- $status = $facebook->api('/me/feed', 'POST', $params);
+ //$status = $facebook->api('/me/feed', 'POST', $params);
@mrclay
mrclay / UFCOE.parseUri.js
Created February 16, 2012 21:01
Parse a URI using the browser's DOM
(function (w, d) {
var a, k = 'protocol hostname host pathname port search hash href'.split(' ');
w.UFCOE = w.UFCOE || {};
/**
* Parse a URI, returning an object similar to Location
*
* Usage: UFCOE.parseUri("hello?search#hash").search -> "?search"
*
* @param String url
* @return Object
@mrclay
mrclay / fetch-ssl-cert.php
Created February 20, 2012 20:19
Fetch SSL cert data from a host and (crudely) validate it based on time/domain
<?php
/**
* Fetch SSL cert data from a host and (crudely) validate it based on time/domain
*
* @param string $host
* @param int $timeout in seconds
* @param int $port
* @param array $sslStreamContextOptions
* @param int $socketClientErrNum
@mrclay
mrclay / Moodle_EnrolDupeRemover.php
Created February 24, 2012 16:51
Delete duplicate enrol plugins caused by Moodle bug MDL-29414
<?php
/**
* Report and delete duplicate enrol plugins from courses, which arise by
* Moodle bug http://tracker.moodle.org/browse/MDL-29414
*/
class Moodle_EnrolDupeRemover {
/**
* @var Zend_Db_Adapter_Abstract