Skip to content

Instantly share code, notes, and snippets.

@nik-johnson-net
nik-johnson-net / http.job.hcl.erb
Created January 16, 2025 18:27
erb template for nginx nomad job that is an ingress proxy for consul connect
<% require 'set' %>
<% require 'yaml' %>
<% @config = YAML.load_file(config) %>
job "<%= @config['job'] %>" {
datacenters = [
<% @config['datacenters'].each do |datacenter| %>
"<%= datacenter %>",
<% end %>
]
In [1]: class Foo(object):
...: def curry(self, x):
...: return x
In [2]: f = Foo()
In [3]: def callee(func, arg):
...: return func(arg)
In [4]: callee(f.curry, "1")
Out[4]: '1'
@nik-johnson-net
nik-johnson-net / exfil.py
Created September 7, 2016 21:37
Simple exfil endpoint.
import SimpleHTTPServer
import SocketServer
PORT = 1238
class SimpleHTTPRequestHandler(SimpleHTTPServer.BaseHTTPServer.BaseHTTPRequestHandler):
def do_PUT(self):
data = self.rfile.read()
with open('recv.pcap', 'w+') as f:
f.write(data)
import pdb
import sys
import time
def main():
now = time.time()
num = int(sys.argv[1])
for i in xrange(0, num):
exec("name%d = 0" % i)
end = time.time()
@nik-johnson-net
nik-johnson-net / workspace-update
Created March 24, 2016 16:25
Script used to update various repositories in $HOME/workspace/
#!/bin/bash
GIT_SERVER="git.example.com"
SVN_SERVER="svn.example.com"
RETURN_OK=0
RETURN_SKIP=1
RETURN_ERROR=2
# ############# #
@nik-johnson-net
nik-johnson-net / variadic.cpp
Created March 4, 2015 03:56
Variadic Inheritance
#include <iostream>
class Hello {
public:
virtual std::string hello() =0;
};
template <typename... Extensions>
class MyClass : public Extensions... {
};
@nik-johnson-net
nik-johnson-net / pagerduty.pl
Created December 1, 2014 18:22
Rewrite pagerduty alerts for irssi
use Irssi;
use POSIX;
use vars qw($VERSION %IRSSI);
use HTML::Parser;
use warnings;
use strict;
my $VERSION = "0.01";
my %IRSSI = (
@nik-johnson-net
nik-johnson-net / term.rb
Created March 28, 2012 18:19 — forked from eric-wood/term.rb
Write a line the full width of the terminal which updates as the terminal resizes
prev_cols = 0
puts ""
loop do
cols = `tput cols`.chomp.to_i
if prev_cols <= cols
print "\e[1A\e[2K"
print "="*prev_cols
puts "\r"
prev_cols += 1