Skip to content

Instantly share code, notes, and snippets.

@montanaflynn
montanaflynn / pget.go
Last active January 17, 2025 17:07
Bounded Parallel Get Requests in Golang
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index
@yukithm
yukithm / encryption.rb
Created July 12, 2016 08:10
[Ruby] A simple example of AES encryption in Ruby
# encoding: utf-8
require "openssl"
require "base64"
CIPHER_ALGO = "AES-256-CBC"
SALT_SIZE = 8
def encrypt(data, pass)
salt = OpenSSL::Random.random_bytes(SALT_SIZE)
@devynspencer
devynspencer / logstash-json.conf
Last active May 10, 2023 15:10 — forked from untergeek/logstash-json.conf
JSON rsyslog output for Logstash
template(name="ls_json" type="list" option.json="on") {
constant(value="{")
constant(value="\"@timestamp\":\"") property(name="timereported" dateFormat="rfc3339")
constant(value="\",\"@version\":\"1")
constant(value="\",\"message\":\"") property(name="msg")
constant(value="\",\"host\":\"") property(name="hostname")
constant(value="\",\"severity\":\"") property(name="syslogseverity-text")
constant(value="\",\"facility\":\"") property(name="syslogfacility-text")
constant(value="\",\"programname\":\"") property(name="programname")
constant(value="\",\"procid\":\"") property(name="procid")
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@joepie91
joepie91 / vpn.md
Last active March 27, 2025 21:47
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@datakurre
datakurre / .gitignore
Last active December 29, 2022 10:29
Minimal Nix Docker
*.tar.gz
.sentinel.*
@dfletcher
dfletcher / tsws
Last active July 21, 2018 12:47
Totally simple web server using Bash and netcat (nc)
Moved to a proprer repositoy, TSWS is a real boy now!
https://github.com/dfletcher/tsws
PRs welcomed.
@stephancom
stephancom / stripe_customer.rb
Created March 21, 2014 03:54
Stripe Customer rails concern
# _ _
# __| |_ _ _(_)_ __ ___
# (_-< _| '_| | '_ \/ -_)
# /__/\__|_| |_| .__/\___|
# |_|
# __ _ _ __| |_ ___ _ __ ___ _ _
# / _| || (_-< _/ _ \ ' \/ -_) '_|
# \__|\_,_/__/\__\___/_|_|_\___|_|
#
# (c) 2013 stephan.com
@shawnjgoff
shawnjgoff / snmp4jruby_trap_listener.rb
Created December 21, 2013 17:57
Using snmp4jruby to receive traps and informs...
#!/usr/bin/env jruby
require 'snmp4jruby'
class TrapListener
def initialize()
@transport = SNMP4JR::Transport::DefaultUdpTransportMapping.new
@address = SNMP4JR::SMI::GenericAddress.parse("udp:127.0.0.1/1162")
@snmp = SNMP4JR::Snmp.new(@transport)
@callbacks = []
@snmp.addNotificationListener(@address, self)