Skip to content

Instantly share code, notes, and snippets.

View toolness's full-sized avatar

Atul Varma toolness

View GitHub Profile
@toolness
toolness / gencert.py
Last active June 22, 2023 11:52
Python script to create server SSL certs and sign them with a custom CA.
#! /usr/bin/python
"""
This simple script makes it easy to create server certificates
that are signed by your own Certificate Authority.
Mostly, this script just automates the workflow explained
in http://www.tc.umn.edu/~brams006/selfsign.html.
Before using this script, you'll need to create a private
@toolness
toolness / gist:3365671
Created August 16, 2012 02:14
CSS testing script for refactorings
(function(jQuery) {
var $ = jQuery;
function test(name, selectors, css) {
console.log("CSS test: " + name);
selectors.forEach(function(selector) {
var passed = 0;
var elements = $(selector);
if (!elements.length)
return console.error(" FAIL - nothing matches " + selector);
$ ./test/smoke_test.py
15Running smoke test on localhost.
16
17Setting up sample 'tinysmoke' repository.
18
@toolness
toolness / gist:3788091
Created September 26, 2012 13:38
Attempt at a Django-style model representation of what's needed for Thimble-badges integration.
from django.db import models
from django.contrib.auth.models import User
class Behavior(models.Model):
"""
Represents a type of user behavior, such as logging in, publishing, or
creating an HTML tag.
"""
short_name = models.CharField(max_length=50, unique=True)
@toolness
toolness / gist:4071475
Created November 14, 2012 10:43
shell syntax highlighting test
# Initialize the virtual environment.
$ source .virtualenv/bin/activate
# Install heroku-specific dependencies.
$ pip install -r requirements.txt
# Heroku requires pushing master, so make a branch.
$ git checkout -b master development
$ heroku create
$ heroku addons:add cleardb:ignite
$ git push heroku master
$ heroku run python manage.py syncdb
@toolness
toolness / app.js
Last active December 11, 2015 16:39
Simple express server that exposes a Transifex project's resources as a requirejs i18n bundle.
const PORT = process.env['PORT'] || 3000;
const PROJECT = process.env['TRANSIFEX_PROJECT'] || 'friendlycode';
const USERPASS = process.env['TRANSIFEX_USERPASS'] || '';
const ROOT_LOCALE = process.env['TRANSIFEX_ROOT_LOCALE'] || 'en';
const AUTH_HEADER = 'Basic ' + new Buffer(USERPASS).toString('base64');
const BASE_TRANSIFEX_URL = 'https://www.transifex.com/api/2/project/' +
PROJECT;
const REVIEWED_RE = /^\/reviewed\/(.*)$/;
const TOPLEVEL_RE = /^\/(.*)\/nls\/([A-Za-z0-9\-_]+)\.js$/;
const LOCALE_RE = /^\/(.*)\/nls\/([a-z\-]+)\/([A-Za-z0-9\-_]+)\.js$/;
@toolness
toolness / gist:4698951
Created February 2, 2013 19:41
Jessica B. Ipsum
<!DOCTYPE html>
<meta charset="utf-8">
<title>Jessica B. Ipsum</title>
<style>
#myinput {
background: pink;
}
</style>
<h1>Vocabulary</h1>
<ul id="vocabulary">
@toolness
toolness / gist:4758182
Created February 11, 2013 22:24
a weird generic migration api
var upgrayedd = require('../index');
var test = require('tap').test;
test('error thrown on setVersion() failure', function(t) {
upgrayedd.migrate({
toVersion: 4,
storage: {
getVersion: function(cb) { cb(null, 1); },
setVersion: function(v, cb) { cb("SETVERSION FAIL"); }
},
@toolness
toolness / gist:4758190
Created February 11, 2013 22:24
funky migration js api
var upgrayedd = require('../index');
var test = require('tap').test;
test('error thrown on setVersion() failure', function(t) {
upgrayedd.migrate({
toVersion: 4,
storage: {
getVersion: function(cb) { cb(null, 1); },
setVersion: function(v, cb) { cb("SETVERSION FAIL"); }
},
@toolness
toolness / badgebakery.py
Created April 6, 2013 14:59
Simple Python module for baking of badges, and retrieval of assertion URLs from baked badges.
"""
This small module makes it easy to bake PNG images with links to
Open Badge assertions. It also allows for easy retrieval of the link
from baked PNGs.
For more information on badge baking, see:
https://github.com/mozilla/openbadges/wiki/Badge-Baking
Note that this module requires the PyPNG module: