Skip to content

Instantly share code, notes, and snippets.

View omundy's full-sized avatar

Owen Mundy omundy

View GitHub Profile
@omundy
omundy / scraper_bbc_find-replace.php
Created May 16, 2011 11:20
Basic scraping demo with "find-replace" parsing
<?php
/* Basic scraping demo with "find-replace" parsing
* Owen Mundy Copyright 2011 GNU/GPL */
$url = "http://www.bbc.co.uk/news/"; // 0. url to start with
$contents = file_get_contents($url); // 1. get contents of page in a string
// 2. search and replace contents
@omundy
omundy / scraper_weather_regex.php
Created May 16, 2011 12:01
Advanced scraping demo with "regex" parsing
<?php
/* Advanced scraping demo with "regex" parsing. Retrieves current
* weather in any city and colors the background accordingly.
* The math below for normalization could use some work.
* Owen Mundy Copyright 2011 GNU/GPL */
?>
<html>
@jamiew
jamiew / google_twunter_lol
Created July 28, 2011 20:34
All the dirty words from Google's "what do you love" project: http://www.wdyl.com/
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,
@omundy
omundy / hello.pde
Created September 11, 2011 02:52
Hello World file for Processing or Processing.js
// Hello World file for Processing or Processing.js
void setup(){
size(1000,700);
background(255);
}
void draw(){
stroke(random(255),random(255), random(255));
line(random(width),random(height), random(width),random(height));
println("Hello World!");
}
@rclark
rclark / L.TopoJSON.js
Last active December 7, 2022 00:23
TopoJSON-aware Leaflet layer
/*
You'll need something like this in your HTML:
<script src="http://d3js.org/topojson.v1.min.js"></script>
*/
L.TopoJSON = L.GeoJSON.extend({
addData: function(jsonData) {
if (jsonData.type === "Topology") {
for (key in jsonData.objects) {
geojson = topojson.feature(jsonData, jsonData.objects[key]);
@nikmartin
nikmartin / A: Secure Sessions Howto
Last active April 28, 2024 05:17
Secure sessions with Node.js, Express.js, and NginX as an SSL Proxy
Secure sessions are easy, but not very well documented.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT]
Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now.
@mabdrabo
mabdrabo / sound_recorder.py
Created January 28, 2014 23:05
Simple script to record sound from the microphone, dependencies: easy_install pyaudio
import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "file.wav"
@drmikecrowe
drmikecrowe / app.js
Last active October 27, 2021 04:28
Sharing constants between node.js app and web app
//** In web app **//
var current = constants.STATE_WAITING;
@bzgeb
bzgeb / Metronome.cs
Created April 16, 2015 00:41
Pretty solid metronome for Unity
using UnityEngine;
using System.Collections;
public class Metronome : MonoBehaviour
{
public double bpm = 140.0F;
double nextTick = 0.0F; // The next tick in dspTime
double sampleRate = 0.0F;
bool ticked = false;
@Vestride
Vestride / encoding-video.md
Last active May 17, 2024 06:55
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus