Skip to content

Instantly share code, notes, and snippets.

@sasha1sum
sasha1sum / comb.hs
Last active December 15, 2015 22:39
foldleach and comb
module Main where
-- fold an operation down a list of lists
foldleach :: (a -> b -> a) -> a -> [[b]] -> [a]
foldleach f b xs = map (foldl f b) xs
foldl1each :: (a -> a -> a) -> [[a]] -> [a]
foldl1each f xs = map (foldl1 f) xs
-- find combinations from list
@sasha1sum
sasha1sum / title.rb
Last active December 18, 2015 00:18
Script to take a package name and return it's title from play.google.com. Also a script which takes a filename with a list of packages and uninstalls them.
#!/usr/bin/ruby
require 'nokogiri'
require 'open-uri'
class PlayEntry
def initialize(package)
@package = package
url = "https://play.google.com/store/apps/details?id=#{package}"
@sasha1sum
sasha1sum / beep-if-low.rb
Created October 26, 2013 19:54
Simple ruby script to print an audible bell when the battery is low on linux.
#!/usr/bin/ruby
$threshold = 20
/Discharging, (\d+)/.match(`acpi`) do |v|
print "\a" if v[1].to_i < $threshold
end
@sasha1sum
sasha1sum / Natural.hs
Last active June 2, 2016 15:17
Natural.hs: For fun wrote up a definition for natural numbers using recursive types.
module Natural where
data Natural = Zero | Inc Natural
instance Eq Natural where
(==) Zero Zero = True
(==) (Inc a) (Inc b) = a == b
(==) a b = False
instance Ord Natural where
@sasha1sum
sasha1sum / README.md
Created May 24, 2016 19:16
Cloudformation and code to create an AWS Lambda to start a jenkins job on github push (via SNS)

Github/Jenkins Hook with AWS Lambda

Setup

  • Run github_hook_cf.py to generate the cloudformation template (requires troposphere).
  • Run the cloudformation template in desired region
  • Once complete, take the values of the outputs and register in Github (Settings -> Webhooks & services -> Amazon SNS), this can be done on a repo or organization level
  • Add the created SNS topic to the generated lambdas event source1
  • Go to the Advanced Settings settings in the lambda configuration and add it to the VPC if needed.2
@sasha1sum
sasha1sum / Makefile
Last active August 23, 2019 09:40
Example of running .NET executables with AWS Lambda and Mono
S3_BUCKET = YOUR_BUCKET
S3_PREFIX = YOUR_PATH
all: build
upload: reverse_cat.zip reverse_cat_cf_template.json
aws s3 cp reverse_cat.zip s3://$(S3_BUCKET)/$(S3_PREFIX)/reverse_cat.zip
aws s3 cp reverse_cat.zip s3://$(S3_BUCKET)/$(S3_PREFIX)/reverse_cat_cf_template.json
build: reverse_cat.zip
@sasha1sum
sasha1sum / vimrc
Created October 14, 2016 17:58
My vimrc 2016-10-14
set autochdir
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugins
Plugin 'gmarik/Vundle.vim'
Plugin 'PProvost/vim-ps1'
@sasha1sum
sasha1sum / checksum.sh
Last active November 21, 2016 17:36
checksum.sh
#!/bin/bash
for f in *; do
echo $f
pv $f | md5sum - | sed "s/-$/$f/" >> checksum.md5
done

Keybase proof

I hereby claim:

  • I am alecgoebel on github.
  • I am agoebel (https://keybase.io/agoebel) on keybase.
  • I have a public key whose fingerprint is C87E E1CA E4CC F114 6E35 D9D0 0DD5 482C C714 8C4D

To claim this, I am signing this object:

@sasha1sum
sasha1sum / ppap.hs
Last active December 9, 2016 17:47
module PPAP where
-- Objects are either a unit of something (Thing) or some combination (Union)
data Object = Thing String
| Union Object Object
instance Show Object where
show (Thing name) = name
show (Union a b) = show a ++ "-" ++ show b