Skip to content

Instantly share code, notes, and snippets.

<?php
// Simple tool to create customizable letter/web page.
// Think mail-merge or mad libs
// Requires a web server-writable directory called data in the same directory is this file
ob_start();
if( !empty( $_POST['cmd'] ) ){
// use name field to save data
$xmlData = new SimpleXMLElement('<data/>');
foreach( $_POST as $field => $val ){
if( strstr( $field, 'data-' ) ){
<html>
<head>
<title>HTML5/canvas clock</title>
<style>
body{
margin: 0;
background: #030;
}
canvas p{
text-align: center;
@hungrymedia
hungrymedia / gist:3981890
Created October 30, 2012 17:59
Snip: HTML
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8 ie7" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9 ie8" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@hungrymedia
hungrymedia / Ben Folds Five Poster - Cityscape Generator
Last active December 14, 2015 18:59 — forked from brendandawes/Ben Folds Five Poster - Cityscape Generator.pde
Adapted from Brendan Dawes' cityscape generator shown at OFFF Cincinnati. I instantly saw the buildings as frequency meters, so set about making them behave as such. My first foray into audio analysis with Processing. Video demo: https://vimeo.com/61520834
// Ben Folds Five Poster - Cityscape Generator by Brendan Dawes
// http://brendandawes.com/projects/benfoldsfive/
// Adapted an animated by Warren Harrison (hungry-media.com)
// Any music.mp3 file in the same folder as the .pde will work, but I used
// a Ben Folds song in the spirit of the original: http://goo.gl/BEBn5
// Requires library from http://toxiclibs.org
import toxi.color.*;
@hungrymedia
hungrymedia / restart_rails.py
Last active December 16, 2015 23:19
Sublime Text 'restart rails' plugin
# mild modification of http://git.io/7oalcQ
# save in ~/Library/Application Support/Sublime Text 2/Packages/User/
import sublime, sublime_plugin
import os, time
class Restart_railsCommand(sublime_plugin.TextCommand):
"""Touch tmp/restart.txt file in the rails project to restart app"""
def run(self, edit):
@hungrymedia
hungrymedia / Ruby RGB color math
Last active December 17, 2015 13:49
Snip: Ruby RGB color math
def hover_color(original_hex, percent)
rgb = original_hex.scan /[^#]{2}/
rgb_l = '#'
rgb.each do |h|
dec = (h.to_i(16) * percent).round
component = dec > 255 ? 255 : dec
rgb_l << component.to_s(16).center(2,'0')
end
rgb_l
end
execute pathogen#infect()
colorscheme railscasts
set number
set list
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set colorcolumn=80
set noswapfile

Keybase proof

I hereby claim:

  • I am hungrymedia on github.
  • I am wph (https://keybase.io/wph) on keybase.
  • I have a public key whose fingerprint is F585 9C05 B1C7 8101 66BF 4171 60F2 63BD 1089 BC39

To claim this, I am signing this object:

@hungrymedia
hungrymedia / GCal.html
Created February 7, 2020 16:56
Load and display a public Google Calendar via Javascript
<!DOCTYPE html>
<html>
<head>
<title>Public GCal Test</title>
<script
src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2/moment.min.js"></script>
<script src="https://apis.google.com/js/api.js"></script>
</head>
<body>