Skip to content

Instantly share code, notes, and snippets.

View sbuss's full-sized avatar

Steven Buss Bacio sbuss

View GitHub Profile
@sbuss
sbuss / plate_math.py
Created December 6, 2011 05:59
Greedy knapsack for plate math
def greedy(goal_weight):
""" Greedy knapsack solution.
A greedy solution to the constrained knapsack problem that is plate math.
Don't forget to subtract the weight of your bar from goal_weight.
Usage:
Given a 45LB bar:
>> from plate_math import greedy
>> bar_weight = 45

Here's an example of the nonsense that Django does with multiple filter and distinct calls:

class Something(models.Model):
    name = models.CharField(
        _("Name"), max_length=255,
        null=False, blank=True, default="")
    status = models.CharField(
        _("Status of the object."), max_length=255,
@sbuss
sbuss / words
Created January 15, 2014 20:49
Just a dump of /usr/share/dict/words from OSX
This file has been truncated, but you can view the full file.
A
a
aa
aal
aalii
aam
Aani
aardvark
aardwolf
Aaron
@sbuss
sbuss / keybase.md
Created September 17, 2014 01:09
Keybase proof of identity

Keybase proof

I hereby claim:

  • I am sbuss on github.
  • I am sbuss (https://keybase.io/sbuss) on keybase.
  • I have a public key whose fingerprint is 1FB9 2EC1 CF93 DFD6 B47F F583 B1A5 6C22 290D A4C3

To claim this, I am signing this object:

@sbuss
sbuss / gist:21c89abea5e8c7e64f94
Created December 2, 2014 19:38
deis cluster btrfs
sbuss@sbuss-retina:~$ ssh [email protected] sudo btrfs fi show
Label: 'ROOT' uuid: edb391c0-e771-4b7b-a1e2-5f737349794f
Total devices 1 FS bytes used 8.67GiB
devid 1 size 97.68GiB used 21.46GiB path /dev/xvda9
Btrfs v3.14_pre20140414
sbuss@sbuss-retina:~$ ssh [email protected] sudo btrfs fi show
Label: 'ROOT' uuid: edb391c0-e771-4b7b-a1e2-5f737349794f
Total devices 1 FS bytes used 8.56GiB
devid 1 size 97.68GiB used 18.46GiB path /dev/xvda9
core@ip-10-128-1-225 ~ $ deisctl list
UNIT MACHINE LOAD ACTIVE SUB
deis-builder.service b82e7e2e.../10.128.1.227 loaded active running
deis-cache.service 277e4209.../10.128.1.225 loaded active running
deis-controller.service 277e4209.../10.128.1.225 loaded active running
deis-database.service 319fc4ed.../10.128.1.226 loaded active running
deis-logger.service 319fc4ed.../10.128.1.226 loaded active running
deis-logspout.service 277e4209.../10.128.1.225 loaded active running
deis-logspout.service 319fc4ed.../10.128.1.226 loaded active running
deis-logspout.service b82e7e2e.../10.128.1.227 loaded active running
core@ip-10-128-1-225 ~ $ nse deis-store-monitor
root@ip-10-128-1-225:/# ceph -s
libust[47/47]: Warning: HOME environment variable not set. Disabling LTTng-UST per-user tracing. (in setup_local_apps() at lttng-ust-comm.c:305)
cluster 0d5fb541-38ef-4536-a158-8dbc8609e38c
health HEALTH_OK
monmap e3: 3 mons at {ip-10-128-1-225.counsyl.com=10.128.1.225:6789/0,ip-10-128-1-226.counsyl.com=10.128.1.226:6789/0,ip-10-128-1-227.counsyl.com=10.128.1.227:6789/0}, election epoch 20, quorum 0,1,2 ip-10-128-1-225.counsyl.com,ip-10-128-1-226.counsyl.com,ip-10-128-1-227.counsyl.com
mdsmap e13: 1/1/1 up {0=ip-10-128-1-225.counsyl.com=up:active}, 2 up:standby
osdmap e42: 3 osds: 3 up, 3 in
pgmap v175542: 1536 pgs, 12 pools, 1081 MB data, 1437 objects
30761 MB used, 260 GB / 293 GB avail
@sbuss
sbuss / gist:906274f5019931f7cff6
Created January 15, 2015 23:32
deis pull problems
# I have a container called `lambda-ci`, tagged with the current git HEAD commit hash and as 'latest'
$ docker build -t docker-registry.deis.counsyl.com/lambda-ci:`git rev-parse HEAD` .
$ docker tag docker-registry.deis.counsyl.com/lambda-ci:`git rev-parse HEAD` docker-registry.deis.counsyl.com/lambda-ci:latest
# I pushed it to our internal docker repo
$ docker push docker-registry.deis.counsyl.com/lambda-ci
# Normally I should be able to deis pull...
$ deis pull docker-registry.deis.counsyl.com/lambda-ci -a lambda-ci
# but it fails:
@sbuss
sbuss / gist:154fcf744c5297f88111
Created January 15, 2015 23:55
deis pull debug logs latest tag 500
Jan 15 23:53:27 ip-10-128-1-226.counsyl.com sh[24443]: 15/Jan/2015:23:53:27 +0000 DEBUG: args = {'namespace': 'library', 'repository': u'lambda-ci'}
Jan 15 23:53:27 ip-10-128-1-226.counsyl.com sh[24443]: 15/Jan/2015:23:53:27 +0000 DEBUG: [delete_repository] namespace=library; repository=lambda-ci
Jan 15 23:53:27 ip-10-128-1-226.counsyl.com sh[24443]: 15/Jan/2015:23:53:27 +0000 DEBUG: [_resolve_repository_name] image_name=docker-registry.deis.counsyl.com/lambda-ci
Jan 15 23:53:27 ip-10-128-1-226.counsyl.com sh[24443]: 15/Jan/2015:23:53:27 +0000 DEBUG: [_validate_repository_name] repository_name=lambda-ci
Jan 15 23:53:27 ip-10-128-1-226.counsyl.com sh[24443]: 15/Jan/2015:23:53:27 +0000 INFO: Starting new HTTP connection (1): docker-registry.deis.counsyl.com
Jan 15 23:53:31 ip-10-128-1-226.counsyl.com sh[24443]: 15/Jan/2015:23:53:31 +0000 DEBUG: "GET /v1/repositories/lambda-ci/tags HTTP/1.1" 200 190
Jan 15 23:53:31 ip-10-128-1-226.counsyl.com sh[24443]: 15/Jan/2015:23:53:31 +0000 INFO: Starting new HTTP connecti
@sbuss
sbuss / gist:97b86b41014673b5de9b
Last active August 29, 2015 14:17
Effect of __all__
(temp)sbuss@sbuss-counsyl:~/envs/temp/src$ mkdir my_package
(temp)sbuss@sbuss-counsyl:~/envs/temp/src$ touch my_package/__init__.py
(temp)sbuss@sbuss-counsyl:~/envs/temp/src$ cd my_package/
(temp)sbuss@sbuss-counsyl:~/envs/temp/src/my_package$ ls
__init__.py
(temp)sbuss@sbuss-counsyl:~/envs/temp/src/my_package$ mkdir foo
(temp)sbuss@sbuss-counsyl:~/envs/temp/src/my_package$ touch foo/__init__.py
(temp)sbuss@sbuss-counsyl:~/envs/temp/src/my_package$ touch foo/bar.py
(temp)sbuss@sbuss-counsyl:~/envs/temp/src/my_package$ touch baz.py
(temp)sbuss@sbuss-counsyl:~/envs/temp/src/my_package$ mkdir oof