Skip to content

Instantly share code, notes, and snippets.

/**
* Implementation of hook_block().
*
* Displays the most recent 10 blog titles.
*/
function blog_block($op = 'list', $delta = 0) { global $user; if ($op == 'list') {
$block[0]['info'] = t('Recent blog posts');
return $block;
} else if ($op == 'view') {
if (user_access('access content')) {
require 'kramdown'
module Kramdown::Converter
class Html
def convert_a(el, indent)
res = inner(el, indent)
attr = el.attr.dup
if attr['href'] =~ /^mailto:/
attr['href'] = obfuscate('mailto') << ":" << obfuscate(attr['href'].sub(/^mailto:/, ''))
res = obfuscate(res)
@myles
myles / ted_transcript_extractor.py
Created January 19, 2011 20:54
A simple Python scrape to extract the transcript from a TED talk.
#!/usr/bin/env python
"""
A simple script that extracts transcripts from <http://www.ted.com>
HOWTO:
python ted_tracscript_extractor.py john_hodgman_s_brief_digression.html
or
import sys
import socket
HOST, PORT = "127.0.0.1", 9999
data = " ".join(sys.argv[1:])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
sock.send(data + "\n")
#!/bin/bash
# Notice the '-d'
if [ -d ~/.bin-private ]; then
echo "Your private bin exists."
else
echo "Your private bin doesn't exists."
fi
# Notice the '-f'
$ umount /var
$ lvresize -L +5GB /dev/mapper/RoundTable00-Knight04 # this will resize the LVM 5GBs bigger
$ e2fsck -f /dev/mapper/RoundTable00-Knight04 # this check to make sure there isn't any issues with the partition
$ resize2fs /dev/mapper/RoundTable00-Knight04 7G # this will resize the mount point
$ mount /var
#!/usr/bin/env python
"""
A simple script that downloads the first page wallpapers from Simple
Desktops <http://simpledesktops.com/browse/>.
Copyright (c) 2010, Myles Braithwaite <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@myles
myles / slickmapcss.html
Created May 5, 2010 18:00
SlickMap CSS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
SlickMap CSS
Version 1.2
2010-05-05
Created by Matt Everson of Astuteo, LLC
- http://astuteo.com/slickmap
@myles
myles / gmail_unread_count.py
Created April 15, 2010 13:47
Get the number of thread unread in Gmail.
#!/usr/bin/env python
# encoding: utf-8
# Copyright (c) 2009 Greg Newman
# Copyright (c) 2010 Myles Braithwaite
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
@myles
myles / foursquare.sh
Created March 21, 2010 19:00
A simple shell script to check into a venue in Foursquare.
#!/bin/sh
#
# A simple shell script to check into a venue in Foursquare.
CURL=`which curl`
FOURSQUARE_API="http://api.foursquare.com/v1/checkin"
if test -z "$CURL"; then
echo "curl binary not found"
exit 1