Skip to content

Instantly share code, notes, and snippets.

View JensRantil's full-sized avatar

Jens Rantil JensRantil

View GitHub Profile
@liquidgecka
liquidgecka / cron_helper.sh
Last active September 28, 2023 15:35
Cron helper
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]... COMMAND
Execute the given command in a way that works safely with cron. This should
typically be used inside of a cron job definition like so:
* * * * * $(which "$0") [OPTION]... COMMAND
Arguments:
@cholmboe
cholmboe / b
Last active September 7, 2023 08:12
A script to search and open chrome bookmarks from your terminal
#!/bin/sh
#
# Search and open chrome bookmarks from your terminal.
#
# Open interactive search:
# $ b
#
# Open first fuzzy matching bookmark:
# $ b <query string>
#
@renoirb
renoirb / init.yml
Last active March 30, 2023 03:15
How to install Oracle Java from ppa webupd8team/java using Salt stack, in ONE state file
#
# How to install automatically Oracle Java 7 under Salt Stack
#
# Thanks Oracle for complicating things :(
#
# 1. Create a java/ folder in your salt master
# 2. Paste this file in init.sls
# 3. salt '*' state.sls java
#
# Source:
@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:

@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
@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))
@boredzo
boredzo / YYYY.md
Created October 26, 2015 14:41
Unicode date formats, YYYY?!
@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:

@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.
@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/