Skip to content

Instantly share code, notes, and snippets.

language filename
hy
learn-hy.hy
;; this gives an gentle introduction to hy for a quick trial head to
;; try-hy.appspot.com
;;
@theanalyst
theanalyst / learn-hy.hy
Last active January 2, 2016 21:59
learn hy in x minutes
;; this gives an gentle introduction to hy for a quick trial head to
;; try-hy.appspot.com
;;
; Semicolon comments, like other LISPS
;; s-expression basics
; lisp programs are made of symbolic expressions or sexps which
; resemble
(some-function args)
@theanalyst
theanalyst / fibs.c
Last active November 23, 2018 14:02
Hy, Python & C play nicely with each other
#include "fibs.h"
long fib(int n)
{
if (n == 0)
return 1;
else if (n == 1)
return 1;
else
return fib(n-1) + fib(n-2);
@theanalyst
theanalyst / source.hy
Last active August 29, 2015 13:58
Getting source of a function in hy.. WIP
(import re
linecache
inspect
[hy.lex.lexer [lexer]]
[itertools [count]])
(defmacro getstartlines [f]
"Gets the starting lines for a given function"
(if-python2 `(. ~f func-code co-firstlineno)
@theanalyst
theanalyst / codegen.py
Last active October 19, 2018 18:38
The beginnings of a py2hy code generator
import ast
from functools import partial, wraps
DEFAULT_INDENTATION = 2
def enclose(parens,newline=False):
def decorate(func):
@wraps(func)
def wrapper(self,*args,**kwargs):
@theanalyst
theanalyst / rgw-storage.md
Last active September 11, 2017 20:18
RadosGW storage mechanism

Object storage

S3/Swift like systems have the concept of objects & buckets (or Containers). These objects are often striped into multiple RadosGW objects.

How objects are cut:

An object is split into a 'head' part and a logical 'tail' part. The head will never be more than a predefined chunk size (default is

@theanalyst
theanalyst / Dockerfile
Created October 14, 2014 12:57
ceph make check dockerfile
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
autoconf \
automake \
autotools-dev \
ccache \
libbz2-dev \
@theanalyst
theanalyst / vagrant-failure.log
Last active August 29, 2015 14:14
vagrant failure
Bringing machine 'default' up with 'kvm' provider...
==> default: Importing base box 'precise64'...
==> default: Assigning a new mac address to the VM.
==> default: Preparing network interfaces based on configuration...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 192.168.123.99:22
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Host unreachable. Retrying...
(defun send-region-as-email (start end)
"A hacky function to send a region as mail
Assumes the region follows the below format
To: <recepient>
Subject: <subject>
<mail body>"
(interactive (if (use-region-p)
(list (region-beginning) (region-end))
(list nil nil)))
(let* ((selection (buffer-substring-no-properties start end))