Skip to content

Instantly share code, notes, and snippets.

View clavery's full-sized avatar

Charles Lavery clavery

View GitHub Profile
function download_all_checked(frm){
// if we got this far, we should try to download
// all the checked boxes.
for (var i = 0; i < document.frmbook.elements.length; i++) {
var e = document.frmbook.elements[i];
if( e.name == 'allbox' ){
continue;
}
@clavery
clavery / RPS.js
Last active December 21, 2015 21:39 — forked from joehinkle/RPS.js
// Initializing Variables
var selection = prompt("Do you choose rock, paper or scissors?");
var PLAYS = ['scissors', 'paper', 'rock'];
var mine = PLAYS.indexOf(selection);
if(mine < 0) {
console.log("Bad play!!");
return;
@clavery
clavery / 0spock.js
Last active December 21, 2015 23:39
lizard spock version (second is faster due to not calling array methods)
function compare(me, comp) {
var plays = ["scissors", "paper", "rock", "lizard", "spock"];
var mine = plays.indexOf(me);
var computer = plays.indexOf(comp);
if (mine === computer)
return "You Tie";
{% macro form_field(field) -%}
{% set with_label = kwargs.pop('with_label', False) %}
{% set placeholder = '' %}
{% if not with_label %}
{% set placeholder = field.label.text %}
{% endif %}
<div class="control-group {% if field.errors %}error{% endif %}">
{% if with_label %}
<label for="{{ field.id }}" class="control-label">
{{ field.label.text }}{% if field.flags.required %} *{% endif %}:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql.functions import coalesce
from sqlalchemy.orm import sessionmaker
from sqlalchemy import Column, Integer, String, select
from sqlalchemy import create_engine
from sqlalchemy import func
engine = create_engine('sqlite:///:memory:', echo=True)
Base = declarative_base()
@clavery
clavery / jqueryEventHandlers.js
Created July 5, 2014 19:58
snippet to list event jquery event callbacks attached to a dom element in chrome
Object.prototype.handlers = function() {
var handlers = $.map($._data(this, 'events'), function(events, name) {
var fname = eval("function " + name + "() {}; "+name);
return $.map(events, function(event) {
var h = new fname();
h["handler"] = event.handler;
return h;
})
#!/usr/bin/env sh
## Port map and set static address for Natted VM Fusion box
## Box must be running and this script needs to be run as sudo
## Restart VMware after
##
## sudo sh fusionportmap.sh
VMRUN="/Applications/VMware Fusion.app/Contents/Library/vmrun"
VMS=$("${VMRUN}" list | tail -n +2)
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sort SHit</title>
<meta name="description" content="">
@clavery
clavery / metadata
Created October 20, 2014 03:52
Digital ocean droplet metadata to publish server key fingerprints to SNS topic
#!/bin/bash
apt-get -y update
apt-get install -y awscli
RSA_FINGERPRINT=$(ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub)
ECDSA_FINGERPRINT=$(ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub)
export AWS_DEFAULT_REGION=us-east-1
export AWS_ACCESS_KEY_ID=Fillthisin
@clavery
clavery / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console