Skip to content

Instantly share code, notes, and snippets.

View bradclawsie's full-sized avatar

Brad Clawsie bradclawsie

View GitHub Profile
@bradclawsie
bradclawsie / tmux.conf
Created December 5, 2010 06:36
tmux conf
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-interval 60
set-option -g status-left "#($HOME/bin/imapbiff.pl)"
set-option -g status-right "#(/bin/date +\"%R %F\")"
@bradclawsie
bradclawsie / biff.el
Created December 5, 2010 06:43
biff for gnus
;; biff
(defvar foundnewmbox "")
(defun fmbiff ()
(interactive)
(save-excursion
(set-buffer "*Group*")
(beginning-of-buffer)
(defvar foundanymbox nil)
(cond ((re-search-forward "INBOX.ALL" nil t)
(setq foundanymbox t))
@bradclawsie
bradclawsie / nginx ssl
Last active September 25, 2015 17:18
nginx ssl hardening highlights
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:AES256-CGM-SHA256:ECDHE-RSA-AES256-SHA256:RC4:HIGH:!aNULL:!MD5:-LOW:-SSLv2:-EXP;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains";
@bradclawsie
bradclawsie / pw.hs
Created May 9, 2011 06:03
haskell pw prompt
module Main where
import System.IO
import Data.Char
import System.Console.ANSI
-- ord val of 10 is return key
getPW = getPW' "" where
getPW' s = getChar >>= \x ->
if ((ord x) == 10) then return s
else cursorBackward 1 >> putStr "*" >> getPW' (s ++ [x])
@bradclawsie
bradclawsie / simpleaes.hs
Created May 13, 2011 18:39
minimal simpleAES example
module Main (main) where
import Codec.Crypto.SimpleAES
import Data.ByteString.Lazy as L
import Data.ByteString.Lazy.Char8 as L8
import Data.ByteString.Char8 as B8
main = do
let lstr = L.concat [L8.pack "hi there"]
pw = B8.pack "abc123abc1234567"
lencode2 <- encryptMsg CBC pw lstr
@bradclawsie
bradclawsie / getpw.pl
Created July 11, 2011 05:50
getpw.pl
#!/usr/bin/env perl
use v5.14;
use warnings;
use strict;
# this is my password file. yours may be different
my $pwfile = $ENV{'HOME'} . '/git/docs/pw/pw.txt.asc';
die $pwfile . ' not readable?' unless (-r $pwfile);
# search term required
@bradclawsie
bradclawsie / rmtrail.el
Created July 12, 2011 20:17
remove all newlines after text in elisp
(defun php-delete-trailing-blank-lines ()
"Deletes all blank lines at the end of the file."
(interactive)
(save-excursion
(save-restriction
(widen)
(goto-char (point-max))
(delete-blank-lines)
(let ((trailnewlines (abs (skip-chars-backward "\n\t"))))
(if (> trailnewlines 0)
@bradclawsie
bradclawsie / dotemacs-php.el
Created July 12, 2011 20:29
hooking into the php mode in emacs
;; php
(load "~/.el/lang/php-mode.el")
(defun my-php-mode-hook ()
(c-set-offset 'substatement-open 0)
(c-set-offset 'statement-case-open 0)
(c-set-offset 'case-label '+)
(setq tab-width 4)
(setq c-basic-offset 4)
(setq c-auto-newline nil)
(setq indent-tabs-mode nil)
@bradclawsie
bradclawsie / .csirc
Created August 15, 2011 04:52
.csirc
(use readline regex)
(current-input-port (make-gnu-readline-port))
(gnu-history-install-file-manager (string-append (or (get-environment-variable "HOME") ".") "/.csi.history"))
@bradclawsie
bradclawsie / ubs.hs
Created September 10, 2011 06:28
haskell code to find all such four-digit numbers (except 0000)
module Main where
import Char
f a1 a2 b1 b2 =
(a1 == (((a2 + b2 - b1) / 10.0) + b1 - a2) * (-1.0)) &&
(a2 == ((a2 - a1 - b1) * 10.0) - b2 + b1) &&
(b1 == (((a2 - a1 - b1) * 10.0) - a2 - b2) * (-1.0)) &&
(b2 == ((a2 - a1 - b1) * 10) - a2 + b1)
-- first line transforms 1978 -> [1.0,9.0,7.0,8.0]