Skip to content

Instantly share code, notes, and snippets.

View carnotweat's full-sized avatar

sameer gupta carnotweat

View GitHub Profile
// Why write this..
public static <T, V> Map<T, List<V>> defaultdict_list() {
return new MapMaker().makeComputingMap(new Function<T, List<V>>() {
@Override public List<V> apply(T unusedCrap) {
return Lists.newArrayList();
}
});
}
# When you just want this (Python)
@carnotweat
carnotweat / fib.py
Created December 10, 2011 11:26
euler
fib1
=========
`def fib(a=0, b=1):
while True:
yield a
a, b = b, a + b
@masak
masak / explanation.md
Last active October 2, 2024 09:32
How is git commit sha1 formed

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <[email protected]>
Date:   Sun Apr 15 16:35:03 2012 +0200

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@alexott
alexott / minimial-cedet-config.el
Created October 22, 2012 07:30
Working configuration for CEDET from bzr & GNU Emacs (with working C++ & Java name completion)
;;; minimial-cedet-config.el --- Working configuration for CEDET from bzr
;; Copyright (C) Alex Ott
;;
;; Author: Alex Ott <[email protected]>
;; Keywords: cedet, C++, Java
;; Requirements: CEDET from bzr (http://cedet.sourceforge.net/bzr-repo.shtml)
;; Do checkout of fresh CEDET, and use this config (don't forget to change path below)
#!/usr/bin/env bash
SED_SCRIPT=`echo '{\
s/_\\$/$/g;\
s/\\$BP\\$/\&/g;\
s/\\$SP\\$/\@/g;\
s/\\$LT\\$/</g;\
s/\\$GT\\$/>/g;\
s/\\$LP\\$/(/g;\
s/\\$RP\\$/)/g;\
s/\\$RF\\$/\\&/g;\
@swlaschin
swlaschin / ConstrainedTypesExamples.fsx
Last active November 5, 2024 23:28
Examples of creating constrained types in F#
// General hints on defining types with constraints or invariants
//
// Just as in C#, use a private constructor
// and expose "factory" methods that enforce the constraints
//
// In F#, only classes can have private constructors with public members.
//
// If you want to use the record and DU types, the whole type becomes
// private, which means that you also need to provide:
// * a constructor function ("create").
;; Bootstrap packages.
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(package-initialize)
(if (not (package-installed-p 'use-package))
(progn
anonymous
anonymous / Porson font.md
Created July 8, 2017 20:49
Porson font

File: Download Porson font   Porson is a typeface in the Greek alphabet based on the handwriting of the English classicist Richard Porson, who, as his biographer writes, "excelled in writing sources for foreign language fonts. download SPIonic and other greek, hebrew, navajo, and foreign language fonts Porson Free Icon. Svg Vector Icons : Use of these fonts onany platform other than that for which it was originallyintended is not recommended and invalidates any OpenType fonts can include an expanded character set and layout features, providing broader linguistic support and more precise typographic control. Download Porson Greek OUP Two, font family Porson Greek OUP Two by with Regular weight and style, download file name is porson-greek-oup-two.ttf ----- GFS Porson for LaTeX

@chandraratnam
chandraratnam / mutt_mbsync_multipleaccounts.md
Last active October 18, 2024 00:17
Mutt + isync mbsync + gmail + multiple accounts.

Mutt + isync multiple accounts Unfinished

This is the setup that I use for mutt, I have two google domain account (read as gmail) and an institution where I work and study account. This means I have two gmail accounts and one outlook 365 account that i want to sync and read via mutt.

I want to store all my email locally as I travel a lot and will be in countries without easy internet access. For this I use mbsync (iSync). As it can handle multiple account types easily and efficently.

The setup works this way

[Remote Mail Servers] <= mbsync => [Local Mail Folders]

@AndrasKovacs
AndrasKovacs / Ordinals.agda
Last active July 27, 2024 06:34
Large countable ordinals and numbers in Agda
{-# OPTIONS --postfix-projections --without-K --safe #-}
{-
Large countable ordinals in Agda. For examples, see the bottom of this file.
Checked with Agda 2.6.0.1.
Countable ordinals are useful in "big number" contests, because they
can be directly converted into fast-growing ℕ → ℕ functions via the
fast-growing hierarchy: