Skip to content

Instantly share code, notes, and snippets.

@jonbretman
jonbretman / type.js
Last active January 16, 2024 01:16
Simple type checking in JavaScript.
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements
@EronHennessey
EronHennessey / check4siteupdate.py
Created October 15, 2013 18:21
A Python script that checks the last-modified date of a URL against the last-modified date of a previous look at it. If the last-modified date has changed, it emails the designated address, saying so. This could be used as a cron job to periodically check for updates of any page on the internet.
# check for an update on a web-page, and email the user
import httplib
import sys
import pickle
from datetime import datetime
import smtplib
from email.mime.text import MIMEText
import yaml
def email_user(cur_data, email_from, email_to):
@josephwegner
josephwegner / what.md
Created October 5, 2013 19:52
Designing DownJS

DownJS

is an easy to use repository for all of your frontend javascript. I wrote that description about a year ago. As I dug into the idea, I abandonded it. Whie my intentions were good at the time, my technical plan was bad. I was planning on loading all of those scripts separately into the page. While they would be on a CDN, loading a bunch of script files separately is a bad practice - the more HTTP requests your page makes, the slower it's going to be. The best practice is to minify and concatenate all of your javascript so they can be served in one request. To avoid supporting bad web development practices, I abandoned DownJS

Today, however, there are numerous tools that can very easily solve this problem. Not only are the technical requirements of DownJS now very possible, but there have been many great examples of The Right Way to do package management. Now is the time for DownJS to take off.

The Right Way

On the technical side, DownJS would do a simple concatenatio

# Rain1 by Thomas R. "TomK32" Koll
#
# draws raindrops as bezier shapes and moves them downwards
#
# available key commands:
# + make raindrops heavier/bigger
# - make raindrops smaller
# a more raindrops
# s less raindrops
# <SPACE>
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active March 4, 2025 16:05
A badass list of frontend development resources I collected over time.
@jessitron
jessitron / ExplicitErrorReturning
Created June 15, 2013 17:58
This is in response to a giant twitter thread. Thanks to @CraigBuchek, @brianbuttonxp, @adkron, @heathborders, and @marioaquino for the discussion. Post is at blog.jessitron.com, titled "What's dirtier than comments? Exceptions!"
case class Error(message:String)
case class AuthLevel(value: Int)
object AuthLevel {
val GUEST = AuthLevel(0)
}
class SettingGetter {
def get_setting(settingName: String): Either[Error, String] = Right("Fred")
@rjw57
rjw57 / cat-position-data.json
Last active December 18, 2015 12:10
Extracted data from BBC's "Secret life of cats" http://www.bbc.co.uk/news/science-environment-22567526 JSON file gives timestamped pixel locations in map images. Map images copied from BBC website.
{
"cats": [
{
"videoLabel": "Ginger confronts a rival",
"name": "Ginger",
"metersToShow": 60,
"color": "#0D7C35",
"videoLocation": [
74.44,
250.92
@andrew
andrew / tokbox.html
Created June 14, 2013 11:00
TokBox example html page for recording and saving a video and then playing it back
<!DOCTYPE html>
<html>
<head>
<title>OpenTok API Sample &#8212; Stand-Alone Archives</title>
<link href="/css/demos.css" type="text/css" rel="stylesheet" >
<script src="http://static.opentok.com/v1.1/js/TB.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var recorderManager;
var recorder;
var player;
@lotas
lotas / fill_table.py
Created June 14, 2013 10:57
>python fill_table.py database table_name 20 [ Really dump script to fill the void of mysql tables. Will create 20 records with in *database.table_name* table with random data (depending on column type) ]
import re
import sys
import random
import string
import numpy as np
import MySQLdb
import MySQLdb.cursors
DB_HOST = "localhost"
DB_USER = "root"
@rmbl
rmbl / backtrace.php
Created June 14, 2013 10:53
Backtrace on fatal_error in PHP
<?php
function shutdown() {
$error = error_get_last();
if ($error['type'] === E_ERROR) {
// fatal error has occured
$trace = array_reverse($GLOBALS['dbg_stack']);
array_pop($trace);
if(php_sapi_name() == 'cli') {
echo 'Backtrace for: \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line'] . ':' . "\n";
foreach($trace as $item)