Skip to content

Instantly share code, notes, and snippets.

Jens Rantil JensRantil

Block or report user

Report or block JensRantil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gzip_strace.txt
$ gzip hej
fstat(3, {st_mode=S_IFREG|0664, st_size=27, ...}) = 0
rt_sigprocmask(SIG_BLOCK, [HUP INT PIPE TERM XCPU XFSZ], [], 8) = 0
open("hej.gz", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
read(3, "dsfkjfh'\nsdf\nsdf\nf\ndsf\nsdf\n", 65536) = 27
read(3, "", 65509) = 0
write(4, "\37\213\10\10f\215sX\0\3hej\0K)N\313\316J\313P\347*NI\3\3434\256\224b"..., 43) = 43
JensRantil / elasticsearch-shutdown.conf
Created Jan 4, 2017
Elasticsearch upstart sample for safe shutdown (for unattended security updates etc.)
View elasticsearch-shutdown.conf
description "Elastic Search"
pre-stop script
while true
curl -s localhost:9200/_cluster/health?pretty | grep status | grep green > /dev/null
#echo $exitcode
if [ $exitcode -ne 0 ]
View .gitconfig
# Beautiful logs
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
View apt-config_dump.output
APT "";
APT::Architecture "amd64";
APT::Build-Essential "";
APT::Build-Essential:: "build-essential";
APT::Install-Recommends "1";
APT::Install-Suggests "0";
APT::NeverAutoRemove "";
APT::NeverAutoRemove:: "^firmware-linux.*";
APT::NeverAutoRemove:: "^linux-firmware$";
APT::NeverAutoRemove:: "^kfreebsd-image.*";
JensRantil /
Last active Jun 30, 2016
Consul semaphore implementation in shell script. Unfinished.
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
JensRantil / tell-me-when-elasticsearch-is-done.go
Created Jun 2, 2016
Script that runs in the background and tells you when ElasticSearch migration/cluster has stabilised. Requires the "say" command that exists on MaxOSX.
View tell-me-when-elasticsearch-is-done.go
package main
import (
JensRantil /
Last active May 22, 2016
Create an observable that fetches smaller batches of users based on prefix
class UserLister {
public Observable<User> streamAll(int batchSize) {
final int prefixLength = estimatePrefixLength(batchSize);
Preconditions.checkState(prefixLength > 0);
log.debug("Estimated prefix length: " + prefixLength);
return Observable.from(RepositoryUtils.hexPrefixes(prefixLength)).flatMapIterable(new Function1<String, List<User>>() {
public List<User> call(String prefix) {
JensRantil /
Created May 21, 2016
Example of an `OperatorObserveOn` alternative. Not sure it works, though.
package my.application;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import rx.Observable.Operator;
import rx.Subscriber;
import my.application.ExecutorServiceUtils;
import my.application.User;
public class ExecutorOperator implements Operator<User, User> {
View snapci_build_output.txt
$ git clone git@localhost:JensRantil/ .
/opt/local/gnocci/vendor/cache/mixlib-shellout-e30a3b6a9e49/lib/mixlib/shellout/unix.rb:277: warning: Insecure world writable dir /opt/local/rbenv/shims in PATH, mode 040777
Cloning into '.'...
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Command git clone git@localhost:JensRantil/ . exited successfully with status 0. Took 0.87956 seconds.$ git checkout develop
/opt/local/gnocci/vendor/cache/mixlib-shellout-e30a3b6a9e49/lib/mixlib/shellout/unix.rb:277: warning: Insecure world writable dir /opt/local/rbenv/shims in PATH, mode 040777
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.
Command git checkout develop exited successfully with status 0. Took 0.02847 seconds.$ git reset --hard 734e9670a4e0be86b38ebbe391bb54e8b52dbbbd
/opt/local/gnocci/vendor/cache/mixlib-shellout-e30a3b6a9e49/lib/mixlib/shellout/unix.rb:277: warning: Insecure world writable dir /opt/local/rbenv/shims in PATH, m
JensRantil /
Last active Apr 7, 2016
Pseudo code for layered architecture.
public class MainContainer {
public static void main(String[] args) {
// Frameworks and drivers
DatabaseDriver jdbcDatabaseDriver = new MysqlDatabaseDriver();
// Interface adapters
UserRepository userRepository = new UserMySQLRepository(jdbcDatabaseDriver);
// Use cases.
UserBusinessUseCases userBusinessCases = new UserBusinessCases(userRepository);
You can’t perform that action at this time.