View git2go-checkout-branch.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"log" | |
"github.com/libgit2/git2go" | |
) | |
func checkoutBranch(repo *git.Repository, branchName string) error { | |
checkoutOpts := &git.CheckoutOpts{ |
View bbcfoodscraper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Given a load of HTML pages from the BBC Food website, this script will | |
# scrape the recipes from the HTML and output them in structured JSON format. | |
import argparse | |
import sys | |
import os | |
import json | |
import base64 | |
from bs4 import BeautifulSoup |
View primary_ip.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
def linux_get_primary_ip4(): | |
grains = {} | |
try: | |
defroute_device = subprocess.check_output("ip route | grep default | grep -Eo 'dev\s+\w+' | awk '{print $2}'", shell=True).strip() | |
devip = subprocess.check_output("ip a s {0} | grep -E 'inet\s' | cut -d'/' -f1 | awk '{{print $2}}'".format(defroute_device), shell=True).strip() | |
except subprocess.CalledProcessError as e: |
View bacula_b64decode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a Python implementation of the Perl code from the following link | |
# http://bacula.10910.n7.nabble.com/The-File-LStat-field-td3960.html | |
# Bacula uses a custom base64 implementation to encode file stats | |
# This should allow us to decode the values in the lstat field in the Bacula DB | |
B64_VALS = { | |
'+': 62, '/': 63, '1': 53, '0': 52, '3': 55, '2': 54, '5': 57, | |
'4': 56, '7': 59, '6': 58, '9': 61, '8': 60, 'A': 0, 'C': 2, | |
'B': 1, 'E': 4, 'D': 3, 'G': 6, 'F': 5, 'I': 8, 'H': 7, 'K': 10, | |
'J': 9, 'M': 12, 'L': 11, 'O': 14, 'N': 13, 'Q': 16, 'P': 15, |