Skip to content

Instantly share code, notes, and snippets.

View veryhappythings's full-sized avatar
👋
Hello!

Mac Chapman veryhappythings

👋
Hello!
View GitHub Profile
@veryhappythings
veryhappythings / vault_decrypter.py
Created November 29, 2018 16:09
Ansible vault decrypter - supports partially encrypted files
import argparse
import getpass
import yaml
from ansible.parsing.utils.yaml import from_yaml
from ansible.parsing.vault import VaultSecret
def main(input_filename, secret, output_filename):
result = from_yaml(
open(input_filename),
@veryhappythings
veryhappythings / circleci_queued_builds.py
Last active July 19, 2018 14:11
Python 3 gist to grab the number of currently running builds in our CircleCI
from collections import defaultdict
import datetime
from circleci.api import Api
TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
circleci = Api("<your api key>")
build_summaries = circleci.get_project_build_summary(
@veryhappythings
veryhappythings / Vagrantfile
Created October 20, 2017 14:34
Vagrantfile for packaging python libs as debs
# -*- mode: ruby -*-
# vi: set ft=ruby :
INSTALL = <<END
sudo apt-get update
sudo apt-get install -y python2.7 dh-virtualenv dpkg-dev debhelper
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python2.7 get-pip.py
sudo pip2 install virtualenv make-deb
#! /usr/bin/env python
import json
import urllib
import requests
api_token = "PLEASE INSERT API TOKEN"
slack = "PLEASE INSERT NAME OF SLACK"

Keybase proof

I hereby claim:

  • I am veryhappythings on github.
  • I am veryhappythings (https://keybase.io/veryhappythings) on keybase.
  • I have a public key whose fingerprint is F973 959C 5198 B379 56D1 F649 A90F 4B11 482B 2036

To claim this, I am signing this object:

import readchar
tape = bytearray([0])
data_pointer = 0
loop_buffer = ''
def state():
print ''.join(['{0:03} '.format(i) for i in tape])
for i in range(data_pointer):
print ' '*3,
curl http://python-distribute.org/distribute_setup.py | sudo python
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
sudo pip install virtualenv
@veryhappythings
veryhappythings / gist:1567277
Created January 5, 2012 21:05
Why can't you puts a hash directly?
[serious_business (master)↑⚡] ➔ irb
1.9.3p0 :001 > puts {3 => 4}
SyntaxError: (irb):1: syntax error, unexpected tASSOC, expecting '}'
puts {3 => 4}
^
from /Users/mac/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
1.9.3p0 :002 > p {3 => 4}
SyntaxError: (irb):2: syntax error, unexpected tASSOC, expecting '}'
p {3 => 4}
^
class User(Base):
# ...
addresses = relationship(Address)
class Address(Base):
contents = Column(String)
>>> jack.addresses
[<Address(u'jack@google.com')>, <Address(u'j25@yahoo.com')>]
>>> jack.addresses.filter(Address.contents === u'jack@google.com2').all()
class User(Base):
# ...
addresses = relationship(Address, lazy='dynamic')
class Address(Base):
contents = Column(String)
>>> jack.addresses
[<Address(u'jack@google.com')>, <Address(u'j25@yahoo.com')>]
>>> jack.addresses.filter(Address.contents === u'jack@google.com2').all()