Skip to content

Instantly share code, notes, and snippets.

View jpillora's full-sized avatar
👶

Jaime Pillora jpillora

👶
View GitHub Profile
@jpillora
jpillora / determ_crypto_reader.go
Last active August 29, 2015 14:25
Deterministic crypto/rand Reader
// WARNING: This is a bad idea.
// Instead, use a Deterministic random bit generator specified in NIST SP 800-90A
// Unverified Go implementation from the TOR project:
// https://gist.github.com/jpillora/ed5cf69af7d35f9bb5f1
@jpillora
jpillora / csrand.go
Last active April 12, 2016 23:46
Hash DRBG implementation in Go (Golang) from the TOR project
/*
* Copyright (c) 2014, Yawning Angel <yawning at torproject dot org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
@jpillora
jpillora / myprog.plist
Last active August 29, 2015 14:26
Sample launchd startup plist (for starting Mac OSX terminal programs at boot)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- put this file in /Library/LaunchDaemons/ for root prgrams and ~/Library/LaunchAgents/ for user programs -->
<plist version="1.0">
<dict>
<key>Label</key>
<string>myprog</string>
<key>WorkingDirectory</key>
<string>/tmp/</string>
<key>Program</key>
@jpillora
jpillora / nginx-gitlab.conf
Created August 21, 2015 01:36
Gitlab go get via SSH
server {
listen {PUBLIC-GITLAB-HTTP-PORT}; #e.g. 80
server_name {PUBLIC-GITLAB-HOST}; #e.g. git.mycompany.com
# add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
location / {
## Hack to implement && - Concat two strings and compare result
if ($args ~* "^go-get=1") {
set $condition goget;
}
@jpillora
jpillora / tinc-install.sh
Last active March 2, 2021 09:56
Install and run tinc-1.1pre11 on Raspberry Pi 2 (Raspberrian)
# install tinc
apt-get update && echo "===> update deps" &&
apt-get install -y make libssl-dev zlib1g-dev liblzo2-dev libreadline-dev libncurses5-dev && echo "===> got deps" &&
curl http://www.tinc-vpn.org/packages/tinc-1.1pre11.tar.gz | tar xzvf - && echo "===> got tinc src" &&
cd tinc-1.1pre11 &&
./configure && echo "===> configured tinc" &&
make &&
make install && echo "===> installed tinc" &&
tinc --version # tinc version 1.1pre11 (built Nov 12 2015 16:25:28, protocol 17.4)
@jpillora
jpillora / 0_reuse_code.js
Created February 1, 2016 04:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
package main
import (
"encoding/binary"
"log"
"strconv"
)
func main() {
msg := "01011100000010101000000010011010000000100110100000001001101000000010011000101111100000001001100010111000101111001011111000000010011010000000100110100000001001100010111000101110001000001000000010011001011100010111001000000010011000101110010111000000101010000000100110100000001001101000000010011000101110001011100010111110000000100110001011100010111100101111100000001001101000000010011010000000100110100000001001100010000010000000100110001011100101110001011100100000001001100010111001011100000010101000000010011000101110001011100010111110110100101011110010111110000000100110001011100010111110110100101011110101110010000000100110100000001001101000000010011000101110001011100010111110101111001000000110000001011100100000001001100010111001011100101011110110000001011100000010100010111000101110001011110010111000101111100000001001100010111110000000100110001011100010111110000000100110001011100010111100101110011111000101111110000000100110100000
@jpillora
jpillora / index.html
Created February 21, 2016 07:20
Complete server-send events (event source) example in Go (golang)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>event source test</title>
</head>
<body>
<div id="events">
</div>
@jpillora
jpillora / eventsource.go
Created February 22, 2016 01:37
another event source golang example
package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/NYTimes/gziphandler"
"github.com/donovanhide/eventsource"
@jpillora
jpillora / Dockerfile
Created March 11, 2016 05:08
small generic Go (golang) docker file (~11MB)
FROM alpine
MAINTAINER [email protected]
#configure go path
ENV GOPATH /root/go
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
#package
ENV PACKAGE github.com/jpillora/ssh-tron