Skip to content

Instantly share code, notes, and snippets.

View berkes's full-sized avatar

Bèr Kessels berkes

View GitHub Profile
@berkes
berkes / template.php
Created October 26, 2010 09:42
Drupal template helpers to render values.
<?php
/**
* Renders a value cleaned. Simply pulls value through check_plain.
*
* Example usage:
* @code
* r('foo'); //=> "Foo"
* r('<script alert(infected)>Foo'); //=> "Foo"
* r("<em>123</em>"); //=> 123
* @endcode
@berkes
berkes / views-view-grid.tpl.php
Created September 30, 2010 22:03
grid style Drupal view, but use 960.gs instead of tables.
<?php
/**
* @file views-view-grid.tpl.php
* Default simple view template to display a rows in a grid.
*
* - $rows contains a nested array of rows. Each row contains an array of
* columns.
*
* @ingroup views_templates
*/
<?php
/*
* menu callback to render the tagadelic title
*
* Args:
* @param $vocs. An array of vocabulary IDs
*/
function tagadelic_page_title_callback((array) $vocs) {
$title = '';
Sep 4 13:36:30 yasmine NetworkManager: <info> Activation (ttyACM0) starting connection 'Vodafone Business 1'
Sep 4 13:36:30 yasmine NetworkManager: <info> (ttyACM0): device state change: 3 -> 4 (reason 0)
Sep 4 13:36:30 yasmine NetworkManager: <info> Activation (ttyACM0) Stage 1 of 5 (Device Prepare) scheduled...
Sep 4 13:36:30 yasmine NetworkManager: <info> Activation (ttyACM0) Stage 1 of 5 (Device Prepare) started...
Sep 4 13:36:30 yasmine NetworkManager: <info> (ttyACM0): device state change: 4 -> 6 (reason 0)
Sep 4 13:36:30 yasmine NetworkManager: <info> Activation (ttyACM0) Stage 1 of 5 (Device Prepare) complete.
Sep 4 13:36:30 yasmine NetworkManager: <info> Activation (ttyACM0) Stage 1 of 5 (Device Prepare) scheduled...
Sep 4 13:36:30 yasmine NetworkManager: <info> Activation (ttyACM0) Stage 1 of 5 (Device Prepare) started...
Sep 4 13:36:30 yasmine NetworkManager: <info> (ttyACM0): device state change: 6 -> 4 (reason 0)
Sep 4 13:36:30 yasmine NetworkManager: <info> Activation (ttyACM
@berkes
berkes / Drupal Hook_cron design pattern
Created August 5, 2010 09:11
Drupal Hook_cron design pattern
/**
* Implementation of hook_cron().
*/
function example_cron() {
static $is_running;
$time = time();
//Call is_active. IF so, stor in variable.
if (!$is_running && _example_cron_may_run($time, variable_get('example_alive_last_ran', 0), variable_get('example_refresh_interval', 648000))) {
$is_running = TRUE;
@berkes
berkes / Auto Unfollow people who foursquare
Created July 28, 2010 10:31
Auto Unfollow people who update twitter from foursquare
# Gem by John Nunemaker http://twitter.rubyforge.org/ | http://github.com/jnunemaker/twitter
require 'twitter'
# yea, I know, should be oauth, but hey, this is just a script you run locally. So, whatever.
httpauth = Twitter::HTTPAuth.new('username', 'pasword')
client = Twitter::Base.new(httpauth)
# This selects only twenty last tweets. Play with the query for
# http://rdoc.info/rdoc/jnunemaker/twitter/blob/d2432da5a54fc9b788258ff9adfc93b379624957/Twitter/Base.html#friends_timeline-instance_method to receive more tweets
foursquares = client.friends_timeline.select {|t| t.source =~ /foursquare\.com/ }