Skip to content

Instantly share code, notes, and snippets.

@mveytsman
mveytsman / generate_ca.rb
Created July 24, 2012 03:39
This script generates an SSL CA certificate that can be used to sign other certificates
## Usage: generate_ca.rb NAME
##
## This script generates an SSL CA certificate that can be used to sign
## other certificates. The certificate is saved to NAME.pem, and the
## key is saved to NAME.key
require 'openssl'
if ARGV.length != 1
puts "Usage: generate_ca.rb NAME"
@mveytsman
mveytsman / forge_cert.rb
Created July 24, 2012 03:53
Generate a SSL certificate signed by a custom CA with the same subject (common name, organization name, etc..) as the target cert.
## Usage: forge_cert.rb CA.pem CA.key target.pem
##
## Generate an SSL certificate signed by a custom CA with the same
## subject (common name, organization name, etc..) as the target cert.
## This is useful when you need to man-in-the-middle an ssl connection
## and want to use custom certificates with an existing tool or roll
## your own.
##
## Certificate is written to standard out in PEM format.
@mveytsman
mveytsman / keybase.md
Created March 6, 2014 02:38
I'm on keybase!

Keybase proof

I hereby claim:

  • I am mveytsman on github.
  • I am mveytsman (https://keybase.io/mveytsman) on keybase.
  • I have a public key whose fingerprint is 9C97 0545 A994 453D 4044 75C4 D773 5456 46C9 1E49

To claim this, I am signing this object:

#!/bin/bash
### Setup a wifi Access Point on Ubuntu 12.04 (or its derivatives).
### make sure that this script is executed from root
if [ $(whoami) != 'root' ]
then
echo "
This script should be executed as root or with sudo:
sudo $0
"
@mveytsman
mveytsman / phonebook.rb
Created June 20, 2014 17:57
Hacker School Phonebook
#!/usr/bin/env ruby
require 'thor'
class PhoneBookCLI < Thor
no_commands do
def wrap_errors(&block)
begin
instance_eval &block
rescue Exception => e
say "#{e.message}", :red
exit
@mveytsman
mveytsman / binary_search_tree.rs
Created June 21, 2014 03:36
binary search tree in rust
enum BinaryTree {
Node(int, Box<BinaryTree>, Box<BinaryTree>),
Leaf
}
fn insert(tree:Box<BinaryTree>, value:int) -> Box<BinaryTree> {
return box match (*tree) {
Leaf => Node(value, box Leaf, box Leaf),
Node(i, left, right) => if value < i {
Node(i, insert(left, value), right)
@mveytsman
mveytsman / expression-problem.clj
Last active November 24, 2015 12:45
expression problem in clojure
(ns expression-problem)
;; Shapes have area
(defprotocol Areable
(area [this]))
;; We have circles
(defrecord Circle [radius])
;; Circles have area
@mveytsman
mveytsman / gist:c03eceb1b02e1eeb3903
Last active August 29, 2015 14:11
Sierpinsky Triangle
(defn sierpinsky [n]
(if (= 0 n)
["*"]
(let [down (sierpinsky (- n 1))
space (apply str (repeat (Math/pow 2 (- n 1)) " "))]
(concat (map #(apply str space % space) down)
(map #(clojure.string/join " " (repeat 2 %)) down)))))
(map println (sierpinsky 4))
@mveytsman
mveytsman / portscanyourself.sh
Last active January 18, 2017 20:55
Check that your firewall is doing what it should be. Post to slack if it's not.
#!/bin/sh
# This is a script that checks to see if the open ports on a host are what you expect them to be.
# If your firewall isn't doing what it's supposed to, it will post a message to Slack to alert you.
# Intended to be run as a cron job.
#
# Requires nmap to be installed
#
# Invoke as
# ./portscanyourself example.com 80 443
# To alert you if any ports other than 80 and 443 are listening on a host