Skip to content

Instantly share code, notes, and snippets.

Bryan Berry bryanwb

Block or report user

Report or block bryanwb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 3box-verification
3Box is a social profiles network for web3. This post links my 3Box profile to my Github account!
✅ did:muport:QmaNJF7dWyYKsFfqTTEmavMBd9RHFuPWuaArrcN4RuseWF ✅
Create your profile today to start building social connection and trust online.
bryanwb /
Last active Nov 14, 2016
parse the ouput of the condor_status command
from fn.monad import Option
from toolz.itertoolz import get
example1 = '''Name OpSys Arch State Activity LoadAv Mem ActvtyTime
gce-xxxxx LINUX X86_64 Unclaimed Idle 0.010 3700 0+00:00:02
gce-xxxx LINUX X86_64 Unclaimed Idle 0.000 3700 0+00:00:02
Total Owner Claimed Unclaimed Matched Preempting Backfill
X86_64/LINUX 2 0 0 2 0 0 0
View my-test.el
;; use-region-p returns nil even though it is mocked using cl-flet
;; why?
(defun bwb-gitlab--get-line-nums ()
"Return line number(s) if applicable.
If region selected, returns range in url form"
(if (null (use-region-p))
(message "use-region-p is nil"))
(cond ((not (gitlab--viewing-filep)) "")
View term-custom.el
(defun term-toggle-mode ()
(if (term-in-line-mode)
(add-hook 'term-mode-hook
(lambda ()
(defmacro term-in-char-mode () '(eq (current-local-map) term-raw-map))
View pytest fixtures within fixtures
import pytest
def fixture1():
return dict()
def fixture2(fixture1):
return id(fixture1)
bryanwb /
Created Nov 24, 2015
how to write python unit tests for an ansible module?
def method1():
def method2()
# import module snippets
from ansible.module_utils.basic import *
bryanwb /
Last active Oct 3, 2015
Ze Admin: a tool for collecting shell(ish) scripts

Some ideas

If you're like me, you have to write a fair number of shell scripts as part of your daily work as a developer or sysadmin. It is tempting to write those scripts in Bash but you think better of it, as Bash is a fucking mess that is completely unmanageable once the script is longer than one hundred lines. Further, managing command-line flags to bash scripts is a nightmare. You could write those scripts in a higher-level language like Python or Ruby but something still isn't right. Your scripts have zero type safety and debugging them is a chore for finding even minor typos.

Just as important, I want to organize my scripts logically as subcommands. Once I have written scripts, it can be very hard for me to find them again later and even recall how they work. I need an organizing structure for these scripts.

bryanwb / bad.yml
Last active Sep 3, 2015
modifying a dictionary in a loop
View bad.yml
# this fails on the "set" tag
- set_fact: instances="{%- set instances = dict() %}
{%- for group in group_names %}
{%- for host in groups[group] %}
{%- if hostvars[host].get('InstanceId', None) %}
{%- if hostvars[host].get('Platform', None) == 'windows' %}
{%- set tmp = instances.setdefault(host, hostvars[host]['InstanceId']) %}
{%- endif %}
{%- endif %}
{%- endfor %}
bryanwb / err.msg
Created Aug 18, 2015
error message for go vet
View err.msg
hitman@Bryans-MacBook-Pro:~/pr/sellsword$ go vet
vet: error walking tree: stat ../go/src/ no such file or directory
vet: error walking tree: stat ../go/src/ no such file or directory
vet: error walking tree: stat ../go/src/ no such file or directory
vet: ../go/src/ open ../go/src/ no such file or directory
vet: no files checked
exit status 1
bryanwb / vpc.yml
Created Jul 9, 2015
how to DRY this up?
View vpc.yml
- command: "aws ec2 describe-subnets --filters Name=tag:Tier,Values=pub Name=vpc-id,Values={{aws_vpc_id}}"
register: awscli
- set_fact:
pub_subnets: "{{awscli.stdout | from_json}}"
- set_fact:
pub_subnet: "{{pub_subnets['Subnets']|first}}"
- set_fact:
pub_subnet_id: "{{pub_subnet['SubnetId']}}"
You can’t perform that action at this time.