Skip to content

Instantly share code, notes, and snippets.

Avatar

Ken Bolton kenbolton

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

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

View spacemacs-cheshe.org

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
View keybase.md

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 Dec 19, 2015
Remove 'in_menus' from Mezzanine's `Page` instance admin. Insert '_order' at the beginning of the list of fields.
View admin.py
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')
View gist:5710648
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 Dec 14, 2015 — forked from mikeyk/gist:1329319
Python script to test Redis set/get, hashed sets, memcached, and PostgreSQL hstore for memory consumption.
View kv_bencher.py
#! /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 Feb 13, 2013
Django-Social-Auth and Mezzanine/Cartridge integration from spring 2012. It looks like `mezzanine.accounts`, but the integration with that app is likely incomplete.
View profiles.models.py
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 Dec 12, 2015
Some tentative Mezzanine fabfile.py additions.
View fabfile.py
@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 Jan 14, 2013
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!
View Vagrantfile
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.network :hostonly, "192.168.124.10"
end
View gist:4226648
$(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);
});