Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
@slattery
slattery / google.feature
Last active September 10, 2015 12:09 — forked from kbingman/google.feature
A basic test runner to use Yadda with the Nightwatch selenium testing framework.
Feature: Google Demo
Scenario: Google home page
When I open http://google.com
and I should see #viewport
kFSEventStreamCreateFlagNone = 0x00000000
kFSEventStreamCreateFlagUseCFTypes = 0x00000001
kFSEventStreamCreateFlagNoDefer = 0x00000002
kFSEventStreamCreateFlagWatchRoot = 0x00000004
kFSEventStreamCreateFlagIgnoreSelf = 0x00000008
kFSEventStreamCreateFlagFileEvents = 0x00000010
@slattery
slattery / vmtouchpoll
Created December 15, 2015 15:50 — forked from vi/vmtouchpoll
Keep files locked in memory by periodically restarting vmtouch
#!/bin/bash
# vmtouchpoll: Keep some files locked in memory (including new files, dropping deleted files)
# Usage: vmtouchpoll '/path/to/some/files/*.idx'
# Works by periodically restarting vmtouch with a new set of files
# Implemented by Vitaly "_Vi" Shukela in 2015, License=MIT
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
@slattery
slattery / firstboot.sh.erb
Created December 16, 2015 14:19 — forked from mtak/firstboot.sh.erb
Generator for Debian preseed files
#!/bin/sh
# set hostname
echo <%= hostname %> > /etc/hostname
/etc/init.d/hostname.sh
# Set up networking
cat > /etc/network/interfaces << EOF
# The loopback network interface
auto lo
@slattery
slattery / curltest.c
Created December 28, 2015 01:04 — forked from aaronhurt/curltest.c
example code using libcurl and json-c to post and parse a return from http://jsonplaceholder.typicode.com
/**
* example C code using libcurl and json-c
* to post and return a payload using
* http://jsonplaceholder.typicode.com
*
* Requirements:
*
* json-c - https://github.com/json-c/json-c
* libcurl - http://curl.haxx.se/libcurl/c
*
@slattery
slattery / json_parser.c
Created December 28, 2015 01:23 — forked from alan-mushi/json_parser.c
Examples for the json-c tutorial.
/*
* A simple example of json string parsing with json-c.
*
* clang -Wall -g -I/usr/include/json-c/ -o json_parser json_parser.c -ljson-c
*/
#include <json.h>
#include <stdio.h>
int main() {
struct json_object *jobj;
@slattery
slattery / match.c
Created December 28, 2015 01:44 — forked from ianmackinnon/match.c
C Regex multiple matches and groups example
# gcc -Wall -o match match.c && ./match
#
#include <stdio.h>
#include <string.h>
#include <regex.h>
@slattery
slattery / README.md
Created January 8, 2016 17:27 — forked from mwise/README.md
Git hook to prevent merging staging branch into master branch

To use this hook:

  • add the prepare-commit-msg file at .git/hooks/prepare-commit-msg and edit as needed
  • make it executable: chmod +x .git/hooks/prepare-commit-msg
  • disable fast-forward merges: git config branch.master.mergeoptions "--no-ff"
  • that's it!

NOTE: after a failed merge from a forbidden branch, the working tree will still be in a MERGING state. To discard the local working copy state, run: git reset --merge

@slattery
slattery / gist:455ba2daec5950dd8a3d
Created January 8, 2016 17:29
Block specific git commands
function git() {
blocked=(merge pull)
if [ -n "$1" ]; then
for b in "${blocked[@]}"; do
if [ "$1" == "$b" ]; then
printf "\"It is easier to prevent bad habits than to break them.\"\n—Benjamin Franklin\n"
return
fi
done
fi