Skip to content

Instantly share code, notes, and snippets.

@indraniel
indraniel / colors.nim
Created January 25, 2019 16:36 — forked from jabbalaci/colors.nim
A small program to make using 256 colors in Nim less painful.
import strformat
import tables
# A small program to make using 256 colors in Nim less painful.
# Original ZSH version from:
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
# Nim rewrite by Laszlo Szathmary <jabba.laci@gmail.com>
# thanks to narimiran and kickeroo for making the code more idiomatic Nim code
@indraniel
indraniel / bash-array-c-style-iteration.sh
Created August 20, 2015 17:16
A C-style loop iteration in bash
#!/bin/bash
declare -a arr=("echo 'hi'" "echo 'hello'")
for (( i = 0; i < ${#arr[@]} ; i++ )); do
printf "\n**** Running: ${arr[$i]} *****\n\n"
# Run each command in array
eval "${arr[$i]}"
done
@indraniel
indraniel / sort-list-of-dictionaries.py
Created September 23, 2015 20:29
python: approaches to sort a list of dictionaries
#!/usr/bin/python
from __future__ import print_function
# from https://wiki.python.org/moin/SortingListsOfDictionaries
def multikeysort(items, columns):
from operator import itemgetter
comparers = [ ((itemgetter(col[1:].strip()), -1) if col.startswith('-') else (itemgetter(col.strip()), 1)) for col in columns]
def comparer(left, right):
for fn, mult in comparers:
@indraniel
indraniel / Makefile
Last active June 11, 2022 20:25
A template to start a common-lisp project inside a separate "virtual environment"
.PHONY: init-project repl deps
#https://stackoverflow.com/a/23324703 (gets the absolute directory of the Makefile)
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
QUICKLISP_DIR := $(ROOT_DIR)/quicklisp
UTILS_DIR := $(QUICKLISP_DIR)/utils
SBCL := $(HOME)/sw/cl/sbcl/2.0.3/bin/sbcl
SWANK_HOST := "127.0.0.1"
@indraniel
indraniel / gcp-price-list.json
Created June 13, 2018 15:08
Old style google cloud platform (GCP) JSON price list . Modern times now use the GCP billing API
{
"comment": "If you've gotten here by mistake, this is the JSON data used by our pricing calculator. It is helpful for developers. Go to https://cloud.google.com/products/calculator/ to get back to our web calculator.",
"version": "v1.13",
"updated": "01-August-2017",
"gcp_price_list": {
"sustained_use_base": 0.25,
"sustained_use_tiers": {
"0.25": 1.0,
"0.50": 0.8,
"0.75": 0.6,
@indraniel
indraniel / chromecast-scheduler.py
Created December 29, 2017 16:59
Example sending a list of local videos to chromecast
#!/usr/bin/env python
# Based on: https://github.com/piedar/pychromecast/blob/cast/cast.py
# https://github.com/balloob/pychromecast/issues/8
# https://github.com/balloob/pychromecast/issues/154
# https://en.wikipedia.org/wiki/Multicast_DNS
# Copyright 2015 Benn Snyder <benn.snyder@gmail.com>
# Released under MIT license
#
@indraniel
indraniel / read-file.scm
Created July 17, 2017 16:49
An example file reading script with chicken scheme
#!/usr/bin/env csi -ss
;; An example file reading script with chicken scheme
(use extras)
(define (read-it file)
(let ((fh (open-input-file file)))
(let loop((c (read-line fh)))
(if (eof-object? c)
@indraniel
indraniel / style_guide.md
Created September 10, 2021 15:45 — forked from scottfrazer/style_guide.md
WDL Best Practices / Style Guide

"My First WDL" Template

task name {
  String in
  command {
    echo '${in}'
  }
  output {
 String out = read_string(stdout())
@indraniel
indraniel / tumblr-download.go
Last active September 5, 2021 06:36
A golang program to download pictures from a tumblr blog page
/*
This is a go program to download pictures from a tumblr blog page.
To Build:
go build -o tumblr-download tumblr-download.go
To Run:
# download the photos on the first page of tumblr blog
@indraniel
indraniel / 1_google_cloud_storage_backup_tutorial.md
Created September 8, 2018 15:09 — forked from rnwolf/1_google_cloud_storage_backup_tutorial.md
Tutorial shows how to make backups to Google Cloud Storage.

Google Cloud Storage backup tutorial

Introduction

This tutorial shows how to make backups to Google Cloud Storage. The backups are:

  • automatic
  • stored off site
  • incremental