Skip to content

Instantly share code, notes, and snippets.

View hugowetterberg's full-sized avatar

Hugo Wetterberg hugowetterberg

View GitHub Profile
@hugowetterberg
hugowetterberg / parsing_headers.php
Created April 16, 2009 12:12
Parsing headers, with focus on Content-* headers
<?php
/**
* Parsing headers with code adapted from the user contributed notes at
* http://php.net/manual/en/function.http-parse-headers.php
*
* @author Hugo Wetterberg, Good Old
*/
/*
// Sample usage

Usage

$ gist 100434 intelligent-backlink

Checks out the gist 100434 in the folder intelligent-backlink

If someone has forked your repo you can add them as remote when you're inside the gist dir like this:

$ gist 103116 pelle

<?php
if (!empty($_FILES['file'])) {
$file = $_FILES['file'];
$result = $rest->post($oa->resourceUri("image"), array(
'title' => $formData['upload_title'],
'license' => array($formData['license'] => TRUE),
));
try {
// Move the uploaded file so that we get a proper name
// In closure: initial_sw
google.maps.event.addListener(map, "click", function(event) {
if (!initial_sw) {
initial_sw = map.get_bounds().getSouthWest();
}
var sw = map.get_bounds().getSouthWest(),
pos = new google.maps.LatLng(
event.latLng.lat() - (initial_sw.lat()-sw.lat()),
event.latLng.lng() - (initial_sw.lng()-sw.lng()));
@hugowetterberg
hugowetterberg / install.log.textile
Created June 3, 2009 09:45
List of stuff to install on a new dev machine

Apps

@hugowetterberg
hugowetterberg / snippet.js
Created June 9, 2009 14:41
Time format interpreter
(function(){
var tsplit = /[^\d]/, pad_time = function (time) {
if (time<10 && time.length<2) {
return '0' + time.toString();
}
else {
return time;
}
},
normalize_time = function (inp) {
; $Id$
name = Loype
description = Runningstuff
core = 6.x
<?php
// Add the css file as you would have added a normal
// css file in template.php, but pass the path
// through cssdry_stylesheet().
if (module_exists('cssdry')) {
drupal_add_css(cssdry_stylesheet(drupal_get_path('theme', 'a_theme') .'/css/style.css'), 'theme');
}
#!/usr/bin/env php
<?php
$content = file_get_contents($argv[1]);
function invert_color($matches) {
$r = 255 - intval(substr($matches[1], 0, 2), 16);
$g = 255 - intval(substr($matches[1], 2, 2), 16);
$b = 255 - intval(substr($matches[1], 4, 2), 16);
$a = isset($matches[2]) ? $matches[2] : '';