Skip to content

Instantly share code, notes, and snippets.

View mberry's full-sized avatar

Mitchell Berry mberry

  • Sydney, Australia
View GitHub Profile
#!/bin/bash
# Install basic kit / configure unattended-upgrades
apt install -y fail2ban git-all unattended-upgrades
apt update
apt -y upgrade
echo -e "APT::Periodic::Update-Package-Lists \"1\";\nAPT::Periodic::Unattended-Upgrade \"1\";\n" > /etc/apt/apt.conf.d/20auto-upgrades
# Alternatively 'dpkg-configure unattended-upgrades' and go through the graphical menu
# Setup non-root user
@mberry
mberry / docker-debian-install.sh
Last active February 4, 2019 04:18
Debian stretch docker install. Fixes the inaccurate steps in the official docs.
#!/bin/bash
# Dependencies
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# GPG Key
echo "Docker GPG Key: 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
#!/bin/bash
apt-key adv --keyserver pool.sks-keyservers.net --recv-keys 0x836CC41976FB442E
echo "deb http://www.tataranovich.com/debian stretch main" >> /etc/apt/source.list
echo "deb-src http://www.tataranovich.com/debian stretch main" >> /etc/apt/source.list
apt install mc
from twitter import *
api = Twitter(auth=OAuth(token, token_secret, consumer_key, consumer_secret))
tweeter_screen_name = "<screen_name not user_name>"
# finds most recent replies, need to parse them for actual tweet made
replies = api.search.tweets(q='to:%s' % tweeter_screen_name, count=100, result_type='recent')['statuses']
@mberry
mberry / loc.js
Created October 5, 2018 07:07
Get lines of code from a github repo
'use strict';
//replace jquery/jquery with the repo you're interested in
fetch('https://api.github.com/repos/numpy/numpy/stats/contributors')
.then(response => response.json())
.then(contributors => contributors
.map(contributor => contributor.weeks
.reduce((lineCount, week) => lineCount + week.a - week.d, 0)))
.then(lineCounts => lineCounts.reduce((lineTotal, lineCount) => lineTotal + lineCount))
.then(lines => window.alert(lines));
function getTasks($path) {
$out = @()
# Get root tasks
$schedule.GetFolder($path).GetTasks(0) | % {
$xml = [xml]$_.xml
$out += New-Object psobject -Property @{
"Name" = $_.Name
"Path" = $_.Path
"LastRunTime" = $_.LastRunTime
::recursively rename specified files in folder
for /R %x in (*.#tiff) do ren "%x" *.tiff
#TODO: Restart if no response
leader=$(factom-cli get heights | grep Leader | cut -c 15-)
current=$(factom-cli get heights | grep Directory | cut -c 23-)
difference=$(($leader - $current))
#echo Current Height: $current
#echo Leader Height: $leader
#echo Difference: $difference
if (($difference > 3))
#post web request
invoke-webrequest -UseBasicParsing -Uri 35.167.205.1:8088/v2 -Method POST -ContentType "application/json" -Body @{"jsonrpc"="2.0", "id"="1", "params"=nil, "method"="heights"}