Skip to content

Instantly share code, notes, and snippets.

@kini
kini / baserep.hs
Created April 14, 2013 05:27
A function for computing non-integer representations ( http://en.wikipedia.org/wiki/Non-integer_representation )
-- | baserep base num digits = (mantissa, exponent)
baserep :: (RealFrac a) => a -> a -> Int -> ([Int], Int)
baserep _ _ 0 = ([], 0)
baserep base num digits
| num < 0 = undefined
| num >= base = let (x, y) = baserep base (num / base) digits in (x, y+1)
| otherwise = let d = fromIntegral (floor num)
(x, y) = baserep base ((num - fromIntegral d) * base) (digits - 1)
in (d : x, y)
@kini
kini / gist:5852091
Created June 24, 2013 18:00
shell log for releasing sagenb 0.10.7 (for @novoselt)
### Do the version bump in the repository
cd ~/src/sagenb/
git remote update # sync with github
git checkout master
git pull --ff-only # this branch is set to track upstream/master
# edit ./Changes and ./setup.py
git status
git commit -am 'Version bump to 0.10.7'
# before actually finalizing this, need to test
@kini
kini / caa-helper.sh
Created December 8, 2013 06:05
A helper script for uploading cover art sets to the Cover Art Archive on musicbrainz, in combination with @96187 's cover-art-bot tool.
#!/bin/bash
########################################################################
# A small script to help upload cover art sets to CAA, for example
# from VGMDB. Put this script in a staging directory, which will
# contain a subdirectory for each release you will be adding cover
# art sets for. Then copy or download all the cover art into the
# staging directory and run this script with [a URL ending in] a
# release MBID as an argument.
@kini
kini / lab2.org
Last active February 11, 2016 04:47

Bomb Lab: Defusing a Binary Bomb

Introduction

  • Assigned: Sep. 28
  • Due: Oct. 12

Note: Keshav Kini (krkini@utexas.edu) is the lead TA for this lab assignment.

@kini
kini / bash_aliases.sh
Last active June 7, 2016 12:47
better random numbers for bash
random () {
# note: $RANDOM only gives 15 bits of entropy, and the apparently
# commonly used $RANDOM$RANDOM is non-uniform as it misses such
# numbers as 4294967295. This command will grab 4 bytes from
# /dev/urandom, interpret them as a 4-byte unsigned integer, and
# format them in decimal representation. It can be used as a
# replacement for $RANDOM when you want a full 32 bits of entropy.
od -An -t u4 -N4 < /dev/urandom | tr -d '[[:space:]]'
}
export -f random
@kini
kini / permute.c
Last active June 13, 2016 20:24
Heap's algorithm for iterating over permutations of n
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
bool print_permutation(unsigned int n,
unsigned int permutation[n],
unsigned int count[n]) {
printf("Permutation: [");
for (unsigned int i = 0; i < n; i++) {
@kini
kini / foo.bib
Last active November 21, 2016 18:12
minimal org-ref example
@article{greenwade93,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1993",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@kini
kini / acl2-cert-dimmer-for-comint.el
Last active May 23, 2018 17:24
An Emacs snippet for ACL2 certification in shell buffers
;; ACL2 certification dimmer function
(defun acl2-cert-dimmer-for-comint (str)
"When cert.pl says it has certified something, go back and
dim the text where it said it was making that thing. This way
you can easily tell at a glance what books are still certifying."
(let ((pos-in-str nil)
;; This is broken; comint-last-input-end isn't really the
;; end of the last input. I should probably search to the
;; previous prompt, or something.
(beginning-of-output comint-last-input-end))
@kini
kini / .editorconfig
Last active July 19, 2020 10:29
Example of behavior with "unset" values in .editorconfig
[foo*]
indent_size = 2
[foobar*]
indent_size = unset