Skip to content

Instantly share code, notes, and snippets.

View JensRantil's full-sized avatar

Jens Rantil JensRantil

View GitHub Profile
@tmaiaroto
tmaiaroto / pre-commit
Last active July 30, 2016 22:29
A Go Commit Hook for Less Future Headaches
#!/bin/bash
#
# Check a "few" things to help write more maintainable Go code.
#
# OK, it's fairly comprehensive. So simply remove or comment out
# anything you don't want.
#
# Don't forget to install (go get) each of these tools.
# More info at the URLs provided.
#
@kintarowins
kintarowins / rebalance.sh
Created August 22, 2012 23:07 — forked from gjcourt/rebalance.sh
Cassandra node rebalancing script
#!/bin/sh
#this looks up the nodes from the ring and rebalances them automatically
hosts = `/usr/bin/nodetool ring |grep Normal |awk '{print $1}' |xargs echo`
RING_SIZE=$(echo "2^127" | bc)
HOST_NUM=$(echo $hosts | wc -w)
INDEX=0
@emilisto
emilisto / ec2_tags.py
Last active March 15, 2019 17:07
Grain for Salt that exposes all EC2 instance tags in grains['tags'], free for all to use and distribute. Tweet me @svammel if you have questions.
"""
ec2_tags - Exports all EC2 tags in a 'tags' grain
For Salt (http://saltstack.org)
Author: Emil Stenqvist <emsten@gmail.com>
Usage:
1. Put ec2_tags.py in roots/_grains/
@tmcgrath
tmcgrath / Spark aggregateByKey
Created December 2, 2014 14:41
Spark aggregateByKey example
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 1.1.0
/_/
Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65)
Type in expressions to have them evaluated.
Type :help for more information.
@wallyqs
wallyqs / nkeys-to-trusted-operator.md
Last active November 25, 2019 20:37
Mixing NKEYS and Trusted Operator setup in NATS v2

Mixing both nkeys static config and trusted operator setup (decentralized auth model) is possible but needs some preparation in order to be able to do it.

The way this can be done is by first preparing a basic trusted operator setup that could be used in the future, and then base from that configuration to create the NKEYS static config using the same shared public nkeys for the accounts and then use clustering routes to bridge the two different auth setups during the transition.

For example, creating the following initial setup using NSC:

@boredzo
boredzo / YYYY.md
Created October 26, 2015 14:41
Unicode date formats, YYYY?!
@marmbrus
marmbrus / gist:15e72f7bc22337cf6653
Created November 27, 2014 03:10
Parallel list files on S3 with Spark
import org.apache.hadoop.fs.{FileSystem, Path}
import org.apache.hadoop.conf.Configuration
case class S3File(path: String, isDir: Boolean, size: Long) {
def children = listFiles(path)
}
def listFiles(path: String): Seq[S3File] = {
val fs = FileSystem.get(new java.net.URI(path), new Configuration())
fs.listStatus(new Path(path)).map(s => S3File(s.getPath.toString, s.isDir, s.getLen))
@artfulhacker
artfulhacker / gist:a6eb800e58f2eb6f9231
Created August 5, 2014 00:50
Military/Government IP Blocks
<?php
// Group detection by IP address
//
// [Region Abbreviation, Military/Government]
// Force Varnish to NEVER Cache this page
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// JSON Headers
@kennethreitz
kennethreitz / pr.md
Created September 12, 2012 20:56 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: