Skip to content

Instantly share code, notes, and snippets.

View hospadar's full-sized avatar

Luke Hospadaruk hospadar

View GitHub Profile

Setting up dnsmasq on ubuntu

This refers to ubuntu 18.04

By default, Ubuntu is using network-manager to manage network connections, and systemd-resolved is managing dns resolution

We're going to:

  1. Disable systemd-resolved all together
  2. Set up network-manager to run its own dnsmasq and point /etc/resolv.conf at its dnsmasq instance
{:user {:dependencies [[proto-repl "0.3.1"]
[com.bhauman/rebel-readline "0.1.4"]
[org.clojure/tools.nrepl "0.2.13"]
[com.gfredericks/debug-repl "0.0.10"]]
:aliases {"rebel" ["trampoline" "run" "-m" "rebel-readline.main"]}
:repl-options {:nrepl-middleware [com.gfredericks.debug-repl/wrap-debug-repl]}
:injections [(require 'clojure.pprint)]}}
@hospadar
hospadar / s3cat.py
Last active April 4, 2019 17:26
s3cat implementation in python
#!/usr/bin/env python3
"""
Yet-another s3cat implementation.
streams files out of s3.
Requires boto3
> pip3 install boto3
Will use whatever your default credentials are locally (i.e. whatever you set up for awscli)
@hospadar
hospadar / update-freedns.sh
Created October 18, 2018 16:11
freedns dynamic dns update script
#!/bin/bash
#Handy update script for auto-updating your IP4 and IP6 dynamic DNS name if you use freedns.afriad.org.
#Probably other providers could be used as well if you modify the update URLs slightly
#uses opendns.com's magic resolver to try and figure out actual public-facing IP addresses
set -e
#To set up:
#go create an A record (for IP4) and a AAAA record (for IP6) for the same dynamic domain name
#replace the <angle bracketed sections> with the appropriate dynamic dns name and update URLs
MY_DOMAIN=<your freedns dynamic domain name>
@hospadar
hospadar / config.fish
Last active April 10, 2019 16:48
ultimate_prompt.fish
#version of my ultimate prompt for the fish shell. MUCH easier to read!
function find_git_branch
# Based on: http://stackoverflow.com/a/13003854/170413
set -l git_branch (git rev-parse --abbrev-ref HEAD 2> /dev/null)
if [ -z "$git_branch" ]
echo -n ""
else
if [ "$git_branch" = "HEAD" ]
@hospadar
hospadar / s3rmulti.py
Created February 9, 2017 20:40
Delete lots of s3 files all at once using bulk requests
#/bin/env python3
from argparse import ArgumentParser
import boto3, time, sys, random
import urllib.parse as p
batch_size = 1000
def rm_files(uri_list, total_num):
client = boto3.client('s3')
c = 0
(def operators [= < > <= >= not= + - * / mod and or not])
(def functions [filter select])
;not yet
;(def more_functions [select-distinct inner-join left-join group-by aggregate])
;not yet
;(def agg_func [min max sum count ])
@hospadar
hospadar / fake-object.clj
Last active November 21, 2016 17:44
Clojure macro to create fake java objects
;Useful macro for creating objects that can be called like java objects.
;Handy for testing clojure functions that use java objects directly.
;Allows you easily create mock objects that can be passed into clojure functions
;EX: you have a clojure function that takes a curator LeaderLatch - the only functions you actually call are start(), hasLeadership(), and close()
;It would be a major hassle to implement a leader-latch subclass just to test that the function doesn't do any work unless it hasLeadership.
;You could implement a quick fake leader latch like:
;(fake-object
; (close [this] (comment "no-op"))
@hospadar
hospadar / .pylintrc
Created April 15, 2015 15:52
.pylintrc
#My pylintrc for use with atom.io's linter-pylint
[MESSAGES CONTROL]
disable=W0311,W1201,W0702,W0611
@hospadar
hospadar / ultimate_prompt.sh
Last active March 15, 2018 18:00
Luke's Ultimate Prompt v3
#Luke's Ultimate Prompt
#displays shortened time, username, shortened absolute path, git branch status colored red if dirty, colored smiley face indicating return code of previous command
#also includes a colored mortal kombat PS2 for those long commands.
#Written by Luke Hospadaruk with lots of help from the internet
find_git_branch() {
# Based on: http://stackoverflow.com/a/13003854/170413
local branch
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then
if [[ "$branch" == "HEAD" ]]; then
echo -n ' detached*'