Skip to content

Instantly share code, notes, and snippets.

View kenbolton's full-sized avatar

Ken Bolton kenbolton

  • BScientific
  • Beacon, NY
View GitHub Profile
@kenbolton
kenbolton / amphetamine.md
Created June 11, 2019 15:56 — forked from heptal/amphetamine.md
Hammerspoon replacement for Caffeine

Amphetamine

Simple toggleable menubar replacement for Caffeine in Hammerspoon, utilizing ASCIImage (for vector) to create the amphetamine icons. Motivated by the official Caffeine app's icon looking bad on Retina

Get latest version here: amphetamine.lua

Save as amphetamine.lua in ~/.hammerspoon/ and put amphetamine = require "amphetamine" in your init.lua

@kenbolton
kenbolton / spacemacs-cheshe.org
Last active April 5, 2018 15:26 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • `SPC q q` - quit
  • `SPC w /` - split window vertically
  • `SPC w` - - split window horizontally
  • `SPC 1` - switch to window 1
  • `SPC 2` - switch to window 2
  • `SPC w c` - delete current window
  • `SPC TAB` - switch to previous buffer
  • `SPC b b` - switch buffers

Keybase proof

I hereby claim:

  • I am kenbolton on github.
  • I am kenbolton (https://keybase.io/kenbolton) on keybase.
  • I have a public key whose fingerprint is F43F 3EA4 4440 2A44 8E43 E7C9 AD7E 8178 CD53 B45A

To claim this, I am signing this object:

@kenbolton
kenbolton / admin.py
Last active December 19, 2015 02:48
Remove 'in_menus' from Mezzanine's `Page` instance admin. Insert '_order' at the beginning of the list of fields.
from copy import deepcopy
from django.contrib import admin
from mezzanine.pages.admin import PageAdmin
from mezzanine.pages.models import Page
fieldsets = deepcopy(PageAdmin.fieldsets)
fieldsets[0][1]["fields"].remove('in_menus')
fieldsets[0][1]["fields"].insert(0, '_order')
def main():
list_of_primes = [2]
while len(list_of_primes) < 1000:
if list_of_primes[-1] % 2 == 0:
value = list_of_primes[-1] + 1
else:
value += 2
is_prime = True
for i in list_of_primes:
if i > value * 0.5:
@kenbolton
kenbolton / kv_bencher.py
Last active December 14, 2015 17:29 — forked from mikeyk/gist:1329319
Python script to test Redis set/get, hashed sets, memcached, and PostgreSQL hstore for memory consumption.
#! /usr/bin/env python
import redis
import random
import pylibmc
import psycopg2
import sys
from time import clock
r = redis.Redis(host='localhost', port=6379)
@kenbolton
kenbolton / profiles.models.py
Created February 13, 2013 18:34
Django-Social-Auth and Mezzanine/Cartridge integration from spring 2012. It looks like `mezzanine.accounts`, but the integration with that app is likely incomplete.
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import post_save
from mezzanine.core.fields import RichTextField
from cartridge.shop.models import Product
from social_auth.signals import pre_update
from social_auth.backends.google import GoogleOAuth2Backend
@kenbolton
kenbolton / fabfile.py
Last active December 12, 2015 01:08
Some tentative Mezzanine fabfile.py additions.
@task
@log_call
def download_media():
media = 'media.tar.gz'
run("tar -czvf %s/%s -C %s/static/media/" % (env.proj_path, media,
env.proj_path))
get('%s/%s' % (env.proj_path, media), media)
@task
@log_call
@kenbolton
kenbolton / Vagrantfile
Created January 14, 2013 23:36
This is the base Vagrantfile for my Django work. I don't know how I came to this, but it works. I first run `vagrant box add precise64 http://files.vagrantup.com/precise64.box` and `vagrant init precise64`, drop in this Vagrantfile, then `vagrant up`. Read the current Vagrant documentation, as the values in this gist may no longer be valid!
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.network :hostonly, "192.168.124.10"
end
@kenbolton
kenbolton / gist:4226648
Created December 6, 2012 18:09
checkbox toggle
$(function() {
// Create filter actions.
var checkbox = $('input[name=joins-leaves]')
$('label[for=joins-leaves]').toggle( function () {
$('.joins, .leaves').css({'display': 'none'});
checkbox.prop('checked', true);
}, function () {
$(".joins, .leaves").css({'display': 'table-row'});
checkbox.prop('checked', false);
});