Skip to content

Instantly share code, notes, and snippets.

View hugowetterberg's full-sized avatar

Hugo Wetterberg hugowetterberg

View GitHub Profile
; $Id$
name = Loype
description = Runningstuff
core = 6.x
@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) {
@hugowetterberg
hugowetterberg / install.log.textile
Created June 3, 2009 09:45
List of stuff to install on a new dev machine

Apps

// 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()));
<?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

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

@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
@hugowetterberg
hugowetterberg / sample_output.txt
Created April 8, 2009 16:06
Shell script for checking git submodule status
sites/default/modules/rest_server:
ahead of origin/master by 14 commit(s)
sites/default/modules/services_oauth:
behind origin/master by 1 commit(s)
sites/default/modules/oauth_common:
ahead of origin/master by 3 commit(s)
/**
* Access checking for comments
*/
function _comment_resource_access($op='view', $args=array()) {
if (user_access('administer comments')) {
return TRUE;
}
if ($op=='create') {
$comment = (object)$args[0];