Skip to content

Instantly share code, notes, and snippets.

@vcastellm
vcastellm / haproxy.lua
Last active January 8, 2022 17:22
Heka haproxy lua decoder
local dt = require "date_time"
local ip = require "ip_address"
local l = require 'lpeg'
local syslog = require "syslog"
l.locale(l)
local msg = {
Timestamp = nil,
Hostname = nil,
Payload = nil,
@chiedo
chiedo / boot2docker-nfs-osx.md
Last active October 4, 2019 20:32
Configuring boot2docker to use NFS on an OSX machine

Configuring Boot2Docker to use NFS on an OSX based machine

  • To improve the speed of Boot2Docker drastically, you will want to set it up to use NFS.
  • You will need to do the following once on your host machine:
    • Add this to /etc/exports on your mac

      # BOOT2-DOCKER-BEGIN
      /Users 192.168.59.103 -alldirs -mapall=501:20
      # BOOT2-DOCKER-END
      
@sailor
sailor / Vagrantfile
Created March 25, 2015 13:09
Vagrantfile for Rails development environment
VAGRANTFILE_API_VERSION = '2'
$install = <<SCRIPT
curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname -s`-`uname -m` > /usr/local/bin/fig
chmod +x /usr/local/bin/fig
SCRIPT
$build = <<SCRIPT
cd /vagrant
fig build
@ngauthier
ngauthier / timeout_and_tick.go
Created February 10, 2015 18:14
Golang timeout and tick loop
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
@denji
denji / golang-tls.md
Last active April 29, 2024 03:39 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@Jupiterrr
Jupiterrr / sync.sh
Last active August 29, 2015 14:11
This script syncs the current directory to /home/docker/share on a boot2docker vm.
#!/bin/bash
set -u # prevent unbound variables
set -e # terminate on error
SSH_PORT=$(boot2docker config 2>&1 | awk '/SSHPort/ {print $3}')
# install rsync
boot2docker ssh tce-load -wi rsync
@schnoddelbotz
schnoddelbotz / call-x.pl
Last active August 29, 2015 14:08
Place a call from terminal using your iPhone - by providing contact's (partial) name (works for local/OnMyMac Contacts.app/AddressBook records only)
#!/usr/bin/perl
# call-x
# no beauty but some joy:
# use osx address book from terminal for (i)phone dialing purposes.
#
# usage:
# $ call-x your-pal's-name...or-partial-number...
#
# In response to the wonderful link max shared with me:
@jbardin
jbardin / proxy_copy.go
Last active June 28, 2023 22:12
Go TCP Proxy pattern
package proxy
import (
"io"
"log"
"net"
)
func Proxy(srvConn, cliConn *net.TCPConn) {
// channels to wait on the close event for each connection
@vkryukov
vkryukov / gist:4d53f84080bf088f087b
Created June 30, 2014 20:27
go.enmime library example
package main
import (
"bytes"
"fmt"
"log"
"net/mail"
enmime "github.com/jhillyerd/go.enmime"
)
@Integralist
Integralist / Hash Keys to Symbols.rb
Last active September 2, 2020 08:50
Convert Ruby Hash keys into symbols
hash = { 'foo' => 'bar' }
# Version 1
hash = Hash[hash.map { |k, v| [k.to_sym, v] }]
# Version 2
hash = hash.reduce({}) do |memo, (k, v)|
memo.tap { |m| m[k.to_sym] = v }
end