Skip to content

Instantly share code, notes, and snippets.

View donatello's full-sized avatar

Aditya Manthramurthy donatello

  • Bay Area, California
  • 20:51 (UTC -07:00)
View GitHub Profile
@donatello
donatello / DivisorsHaskell.hs
Created August 21, 2012 10:38
Haskell implementations to find the divisors of a number
import Data.Int (Int64)
divisors :: Int64 -> [Int64]
divisors k = divisors' 2 k
where
divisors' n k | n*n > k = [k]
| n*n == k = [n, k]
| k `mod` n == 0 = (n:(k `div` n):result)
| otherwise = result
where result = divisors' (n+1) k
@donatello
donatello / prog.hs
Created November 18, 2012 10:33
GADTs to generate custom XML
{-# LANGUAGE GADTs #-}
import Text.XML.Light
mkElt :: String -> (Attributes, Body) -> Element
mkElt name (attribs, body) = Element {
elName = unqual name,
elAttribs = map (\(k, v) -> Attr (unqual k) v) attribs,
elContent = [Text (CData CDataRaw body Nothing)],
elLine = Nothing
@donatello
donatello / basepkgs.sls
Last active August 29, 2015 13:57
Salt State Ordering from Top File - Bug 1
#/srv/salt-state/basepkgs.sls
basepackages:
pkg.latest:
- pkgs:
- apt-transport-https
- bc
- debconf-utils
- emacs-goodies-el
- emacs23-nox
- htop
@donatello
donatello / lowstate output
Created April 1, 2014 08:16
Salt State Ordering from Top File - Bug 2
# salt-call state.show_lowstate
[INFO ] The `lspci` binary is not available on the system. GPU grains will not be available.
[WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
[INFO ] The `lspci` binary is not available on the system. GPU grains will not be available.
[WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
[INFO ] Loading fresh modules for state activity
local:
----------
- __env__:
base
@donatello
donatello / client.py
Last active June 7, 2018 13:38
Gevent + Request Session object Thread Safety Test
import gevent
from gevent.monkey import patch_all
patch_all()
import requests
import json
s = requests.Session()
def make_request(s, d):

Keybase proof

I hereby claim:

  • I am donatello on github.
  • I am donatello (https://keybase.io/donatello) on keybase.
  • I have a public key whose fingerprint is 8EC7 3E41 447A CC5B 4966 BC07 B24F 1635 C23D 9B5A

To claim this, I am signing this object:

@donatello
donatello / postgresql-inspect-table-sizes.txt
Created February 12, 2015 12:41
Postgresql - inspect DB table/index sizes
-- Display table and index sizes
SELECT
table_name,
pg_size_pretty(table_size) AS table_size,
pg_size_pretty(indexes_size) AS indexes_size,
pg_size_pretty(total_size) AS total_size
FROM (
SELECT
table_name,
pg_table_size(table_name) AS table_size,
@donatello
donatello / newgoenv.sh
Last active October 16, 2017 05:31
Create a new custom Go environment in a specified directory
#!/bin/bash
GODOWNLOAD=go1.9.1.linux-amd64.tar.gz
GOURL=https://storage.googleapis.com/golang/$GODOWNLOAD
INSTALL_ARG=$1
if [ -z $INSTALL_ARG ]; then
echo "Please specify an install location on the command line."
exit 1
@donatello
donatello / minio-kafka-notification-dev.org
Created December 13, 2016 13:40
How to develop/test Minio event notifications to Kafka

How to develop/test Minio event notifications to Kafka

It is most convenient to use Docker to do this.

A Kafka setup is required (and this requires a Zookeeper setup). A Kafka consumer is needed to check the events sent to Kafka. I used kafkacat.

Kafka Setup in Docker