Skip to content

Instantly share code, notes, and snippets.

@avisagie
avisagie / .bashrc
Created August 4, 2018 10:08
Add this to your ~/.bashrc under git bash for Windows to get ssh-agent working fairly smoothly. It only starts one ssh-agent and you only need to type your private key password once.
if ps | grep ssh-agent &> /dev/null
then
. ~/.ssh-agent
else
ssh-agent > ~/.ssh-agent
. ~/.ssh-agent
ssh-add
fi
@avisagie
avisagie / gist:1af2f24e1aa1d5beb9b0
Created July 14, 2015 17:52
uuid ranges in Java using BigInteger
import java.math.BigInteger;
public class TryBigInt {
public static void main(String[] args) {
BigInteger start = new BigInteger("00000000000000000000000000000000", 16);
BigInteger end = new BigInteger("ffffffffffffffffffffffffffffffff", 16);
final long numRanges = 11;
BigInteger jump = (end.subtract(start)).divide(BigInteger.valueOf(numRanges));
package asv.tryspark;
import com.google.gson.Gson;
import static spark.Spark.*;
/**
* Created by albert on 2015/07/11.
*/
public class Main {
@avisagie
avisagie / gist:e788a49ba66ca9761f63
Created May 26, 2015 06:05
Test java closing mapped files and GC
package com.company;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
/**
* Opens a file, maps a chunk, closes. Expect to see many open filehandles until it GCs.
@avisagie
avisagie / namedpipe.go
Created September 7, 2013 08:32
Messing around with fifos
package main
import (
"fmt"
"io"
"os"
"time"
)
func reader(f *os.File, data chan<- string, quit chan<- bool) {