Skip to content

Instantly share code, notes, and snippets.

@markhuge
markhuge / gist:64d6f5094763e2a759dac489a9b3aeb5
Created February 17, 2022 07:22 — forked from lonnen/gist:3101795
git grep and git blame. two great tastes that taste great together
# from i8ramin - http://getintothis.com/blog/2012/04/02/git-grep-and-blame-bash-function/
# runs git grep on a pattern, and then uses git blame to who did it
ggb() {
git grep -n $1 | while IFS=: read i j k; do git blame -L $j,$j $i | cat; done
}
# small modification for git egrep bash
geb() {
git grep -E -n $1 | while IFS=: read i j k; do git blame -L $j,$j $i | cat; done
}
@markhuge
markhuge / gist:4669438
Created January 30, 2013 00:24
Bulk Jenkins git repo configuration through Groovy interface.
// Loop through Jenkins projects, adding a git repo for any project without a repo defined.
def projects = hudson.model.Hudson.instance;
projects.getItems(hudson.model.Project).each {
proj ->
if (proj.getScm().type == "hudson.scm.NullSCM") {
proj.scm = new hudson.plugins.git.GitSCM("git://path/to/your/repo.git");
println("Project: " + proj.displayName + " SCM: " + proj.getScm().type);
}
}
@markhuge
markhuge / gist:4724990
Last active February 14, 2019 07:11
Using regex capture groups in Sublime Text 2 search and replace

I copied my .csshrc to a new machine, and needed to add a domain suffix to the hostnames of 20+ VMs in my cluster config. All of my hostnames end in at least 2 digits (foo-bar-baz-01), so I:

  1. Search for instances of 2 digits followed by whitespace.
  2. Preserve the digits in a capture group.
  3. Append the suffix to the capture group (\1)

Append domain suffix where none exists:

Search: ([0-9]{2})\s Replace: \1.my.domain.suffix

@markhuge
markhuge / bottle-jsonp.py
Created March 2, 2013 21:56
Dynamically Serving JSONP with bottle.py
# This will return either JSON or JSONP depending on the existence of a callback.
def jsonp(request, dictionary):
if (request.query.callback):
return "%s(%s)" % (request.query.callback, dictionary)
return dictionary
@route('/something')
def something():
return jsonp(dict(success="It worked"))
#!/usr/bin/env bash
#### StatsD data generator ####
STATSD_PORT=8125
STATSD_HOST=127.0.0.1
METRICS=("someService" "otherService" "foo.bar")
function generate_data {
@markhuge
markhuge / dress.cpp
Last active November 3, 2016 18:19
In case I die: Cynthia's staff
#include "FastLED.h"
#define LED_PIN 1
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS 35
CRGB leds[NUM_LEDS];
#define MASTER_BRIGHTNESS 255
#include <Adafruit_NeoPixel.h>
#define PIN 2
#define Pixels 25
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
@markhuge
markhuge / README.md
Last active July 16, 2016 01:55
Generate random password with openssl

For the pedants (which I can totally be at times):

Base64 uses a reduced character set, so we're generating a less computationally complex string for something like hashcat to chew on, than say, the full ascii character set. Base64 also typically ends with = or == making the pattern even more predictable.

It's still better than hex, and orders of magnitude better than your initials + your grandma's birthday.

This was fucking annoying.

  1. Create GPT on device
  2. Create new partition
  3. Set type as ef00 (EFI)
  4. Write partition table
  5. mkfs.vfat -F32 /dev/< device >
  6. mount Windows10.iso to dir
  7. mount usb drive to dir
  8. copy files from ISO to USB drive
@markhuge
markhuge / tmux-cheatsheet.markdown
Created May 24, 2016 18:17 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname