Skip to content

Instantly share code, notes, and snippets.

View jelmervdl's full-sized avatar

Jelmer jelmervdl

View GitHub Profile
@jelmervdl
jelmervdl / oembed.php
Created February 7, 2011 18:01
Simple interface for getting oembed data from supported (and unsupported) sites.
<?php
function oembed_get_data($video_url, array $params = array(), &$error = null)
{
$html = @file_get_contents($video_url);
if (!$html)
{
$error = 'Could not download video page';
return false;
@jelmervdl
jelmervdl / Open Terminal.scpt
Created August 31, 2011 11:51
Open Terminal Here
# Get the current application
tell application "System Events" to set current_app to the name of the first process whose frontmost is true
# Try to get the folder to the current open document of this application
# Fall back to the users home if that doesn't work
try
tell application current_app
set current_win to the first window
set path_to_file to the path of the document of current_win
set pwd to "`dirname \"" & path_to_file & "\"`"
@jelmervdl
jelmervdl / gist:1184290
Created August 31, 2011 18:27
cd for Terminal
function cd() {
builtin cd "$1"
echo -ne "\033]0;`pwd`\007"
}
@jelmervdl
jelmervdl / facebook-friends.php
Created January 8, 2012 10:30
Find mutual friends of your friends.
<?php
class FacebookAPI
{
protected $_token;
public function __construct($token)
{
$this->_token = $token;
}
@jelmervdl
jelmervdl / deoosterpoort-to-ical.user.js
Created February 3, 2012 00:56
Userscript that adds iCal links to the De Oosterpoort website
// ==UserScript==
// @name iCal links for De Oosterpoort
// @namespace http://ikhoefgeen.nl/userscripts
// @description Create iCal events directly from De Oosterpoort website
// @include http://www.de-oosterpoort.nl/programma/*
// ==/UserScript==
// Credits:
// Base64 encode / decode
// http://www.webtoolkit.info/
//
@jelmervdl
jelmervdl / deoosterpoort-to-gcal.user.js
Created February 3, 2012 12:36
Userscript that adds Google Calendar links to the De Oosterpoort website
// ==UserScript==
// @name GCal links for De Oosterpoort
// @namespace http://ikhoefgeen.nl/userscripts
// @description Create Google Calendar events directly from De Oosterpoort website
// @include http://www.de-oosterpoort.nl/programma/*
// ==/UserScript==
var DeOosterpoort = {}
DeOosterpoort.findData = function(root)
@jelmervdl
jelmervdl / svcover.user.js
Created February 3, 2012 23:21
Link to the last page of the thread if possible
// ==UserScript==
// @name SV Cover last thread
// @namespace http://ikhoefgeen.nl/userscripts
// @description Programmeurs kunnen geen interfaces maken.
// @include http://www.svcover.nl/*
// ==/UserScript==
function setLastPage(thread_id, page)
{
localStorage['thread-' + thread_id] = page;
@jelmervdl
jelmervdl / page-widget.php
Created February 18, 2012 09:43
Contents of a Page widget for Wordpress
<?php
/*
Plugin Name: Page widget
Description: Use a page as a widget in the sidebar
Author: Jelmer van der Linde
Version: 1.0
Author URI: http://ikhoefgeen.nl
*/
@jelmervdl
jelmervdl / find_char.c
Created February 20, 2012 21:49
Voorbeeldje van C-code waarin pointers worden gebruikt om resultaten terug te geven
#include <stdio.h>
#include <stdlib.h>
void find_char(char what, char *letters, int letters_size, int **positions, int *positions_size)
{
int i;
int hits = 0;
/*tel aantal maal dat letter voorkomt om te bepalen hoeveel posities we moeten reserveren.*/
for (i = 0; i < letters_size; ++i)
@jelmervdl
jelmervdl / sickbeard.user.js
Created February 25, 2012 08:35
Userscript that links Sickbeard file names to the actual files
// ==UserScript==
// @name Sickbeard clickable links
// @description Sick clicketyclick
// @include http://*/home/displayShow?show=*
// @author Jelmer van der Linde, idea by Nino van Hooff
// @version 1.1
// ==/UserScript==
function findBasePath()
{