Skip to content

Instantly share code, notes, and snippets.

View jeetsukumaran's full-sized avatar

Jeet Sukumaran jeetsukumaran

View GitHub Profile
@jeetsukumaran
jeetsukumaran / custom_iterator.cpp
Created February 18, 2010 02:33
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>
@jeetsukumaran
jeetsukumaran / rijndael.py
Created October 17, 2011 02:54
Pure-Python implementation of Rijndael (AES) cipher.
#############################################################################
# Original code ported from the Java reference code by Bram Cohen, April 2001,
# with the following statement:
#
# this code is public domain, unless someone makes
# an intellectual property claim against the reference
# code, in which case it can be made public domain by
# deleting all the comments and renaming all the variables
#
class Rijndael(object):
@jeetsukumaran
jeetsukumaran / build-gcc.sh
Last active January 17, 2024 13:29
Build and Install GCC Suite from Scratch
#! /bin/bash
GCC_VERSION="5.2.0"
WORKDIR="$HOME/src/"
INSTALLDIR="/platform"
## NOTE: XCode must be installed (through App Store) and the following run to install command-line tools.
## THIS IS IMPORTANT! Among other things, it creates '/usr/include' and installs the system header files.
# xcode-select --install
var utility = require(app.vault.adapter.basePath + "/__annex__/resources/obsidian/scripts/javascript/utility.js")
function formatContributorList(dv, plan) {
let contributors = dv.pages()
.where((p) => p.file.etags.includes(plan.workplanTag))
.where((p) => p.file.path !== plan.file.path)
.sort((p) => p["content-brief"] + p.title + p.file.name)
.map((p) => {
let contributor = [];
let display = p["production-brief"] ?? p["content-brief"] ?? p.title ?? p.file.name;
@jeetsukumaran
jeetsukumaran / noteweights.dataview.js
Created April 30, 2023 08:17
"Lightning rods of thought using Dataview" -- Filter paths in links as well
function runQuery(options) {
options = options || {}
// const excludePatterns = options.excludePatterns ?? []
// const includePatterns = options.includePatterns ?? []
const excludePaths = options.excludePaths ?? []
const includePaths = options.includePaths ?? []
const limit = options.limit ?? 50
const allPages = dv.pages()
let sourcePages = null
if (includePaths.length) {
@jeetsukumaran
jeetsukumaran / pandoc.md
Created February 27, 2023 05:20 — forked from brabect1/pandoc.md
Converting Markdown to PDF with Pandoc. #markup #markdown #pandoc

Converting Markups to PDF with Pandoc

Install packaged versions of Pandoc and TexLive

wget https://mirrors.creativecommons.org/presskit/icons/cc.png

sudo apt-get install \
    pandoc \

texlive-latex-extra texlive-fonts-recommended \

@jeetsukumaran
jeetsukumaran / bu
Last active August 30, 2022 20:32
Script to drive Restic
#!/usr/bin/env bash
#
# bu: Backup data to repository.
#
# Type 'bu --help' for help on actions and options.
#
# Configuration of 'bu' is done via environmental variables which can be set by user
# in a particular session or saved to a file and read by 'bu'.
#
# Examples of backup configuration files:
#! /usr/bin/env python
###############################################################################
##
## Copyright 2012 Jeet Sukumaran.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Fountion; either version 3 of the License, or
## (at your option) any ler version.
@jeetsukumaran
jeetsukumaran / d.py
Created January 3, 2022 08:28
Simple Bare-Bones Data-as-Attributes Classes
# "heavy" approach (can be useful if you want to derive
# and add simple behavior, e.g. validation etc.)
class Attributes:
def __init__(self, **kwargs):
# Alternatively:
# self.__dict__.update(kwargs)
for k, v in kwargs.items():
setattr(self, k, v)
# or otherwise: