Skip to content

Instantly share code, notes, and snippets.

# munge PATH
pathmunge() {
case ":${PATH}:" in *:"$1":*) return 0 ;; esac
[ "$2" = after ] && PATH=$PATH:$1 || PATH=$1:$PATH
}
@rtfb
rtfb / custom-html.go
Last active September 1, 2018 02:25
Demonstrates a simple usage of AST in Blackfriday v2
package main
import (
"bytes"
"fmt"
bf "gopkg.in/russross/blackfriday.v2"
)
func main() {
@lsowen
lsowen / check_sig.go
Last active November 23, 2023 23:31
GPG Signature Verification in go (with golang.org/x/crypto/openpgp)
package main
import (
"fmt"
"golang.org/x/crypto/openpgp"
"os"
)
func main() {
keyRingReader, err := os.Open("signer-pubkey.asc.txt")
@roktas
roktas / main.go
Last active August 29, 2015 14:27 — forked from TheHippo/main.go
Benchmarking Go Mutex overhead
package main
import (
"fmt"
"sync"
)
type unlocked struct {
i int
}
@mxlje
mxlje / ssl.md
Last active January 10, 2022 02:03
SSL Certificate Commands

These commands are needed every time you want to generate a new certificate signing request to give to an authority in order for them to generate and sign a certificate for you.

https://letsencrypt.org/ solves a lot of the pain involved with SSL certs, but sometimes you still need to go the "old school" route. I constantly forget how this stuff works, so I collected the most important commands (and what they do) here for easy copy & paste.

Generate new private key

@roktas
roktas / README.md
Last active September 15, 2015 10:10
NYP 2015 final sorusu

Kullanıcıya görüntülenen iletilerin İngilizce olduğu olağan bir Ruby yazılımı düşünün. Örneğin böyle bir yazılımda kullanıcıya görüntülenen bir hoşgeldin iletisi aşağıdakine benzer bir şekilde gerçeklenir:

puts "Welcome!"
=> Welcome!

Türk kullanıcılar gözönüne alınarak yazılımın aynı iletileri Türkçe olarak görüntülemesi için tr adında bir çeviri modülü geliştirileceğini varsayalım. Bu modül kullanıldığında yazılımdaki İngilizce ileti görüntüleyen tüm satırlarda

@roktas
roktas / denizli.rb
Last active March 10, 2016 11:44
Test üreteci
#!/usr/bin/env ruby
require 'yaml'
require 'forwardable'
module MultipleChoice
module Choice
CHOICES = (:a..:e).to_a
refine Symbol do
@progrium
progrium / bash.sh
Created February 17, 2015 14:19
Comparing natural brevity and concise expressiveness between Go and shell/Bash for certain tasks using each tool's "standard" library.
curl -s "$url" | tar -zxC "$dest"
@einthusan
einthusan / go1.4arc65-ubuntu.sh
Last active July 10, 2018 23:43
Install Golang 1.4.1 on Ubuntu 14.04 AWS EC2
#!/bin/sh
# OPTIONAL FLAGS:
#
# -geoip true
# this will install maxmind geoip and auto update crontab file
#
# -cloudwatch true
# this will install aws cloud watch metrics and send them to aws dashboard
#
#!/usr/bin/env bash
size=1024 # MB
mount_point=$HOME/tmp
name=$(basename "$mount_point")
usage() {
echo "usage: $(basename "$0") [mount | umount | remount | check | orphan]" \
"(default: mount)" >&2
}