Skip to content

Instantly share code, notes, and snippets.

@bllchmbrs
bllchmbrs / tfpdf.py
Last active December 29, 2021 14:10
TF IDF Explained in Python Along with Scikit-Learn Implementation
from __future__ import division
import string
import math
tokenize = lambda doc: doc.lower().split(" ")
document_0 = "China has a strong economy that is growing at a rapid pace. However politically it differs greatly from the US Economy."
document_1 = "At last, China seems serious about confronting an endemic problem: domestic violence and corruption."
document_2 = "Japan's prime minister, Shinzo Abe, is working towards healing the economic turmoil in his own country for his view on the future of his people."
document_3 = "Vladimir Putin is working hard to fix the economy in Russia as the Ruble has tumbled."
(<|>) :: Parser a -> Parser a -> Parser a
parser1 <|> parser2 = P $ \some -> case parse parser1 some of
[] -> parse parser2 some
result -> result
instance Options MainOptions where
defineOptions =
MainOptions <$> defineOption optionType_bool a_help
<*> defineOption optionType_bool a_version
<*> defineOption optionType_string a_path
where a_help opt = opt { optionLongFlags = ["help"]
, optionShortFlags = ['h']
}
a_version opt = opt { optionLongFlags = ["version"]
, optionShortFlags = ['v']
@KonradIT
KonradIT / readme.md
Last active December 22, 2025 21:59
GoPro Studio for Linux
(defun my-send-to-nrepl ()
(interactive)
(let ((p (point)))
(cider-eval-last-sexp 't)
(goto-char p)
(insert " ;;=> ")))
(defun my-send-to-nrepl2 ()
(interactive)
(let ((p (point)))
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@shreyas-satish
shreyas-satish / CSFeatures.md
Created June 5, 2012 03:51
coffeescript features

CoffeeScript Features

Probably not comprehensive, and in no particular order...

integer literal1Y
feature nameexampleinclude?
string interpolation“a#{b}”Y
assignmenta = bY
single-line comment# commentY
@jboner
jboner / latency.txt
Last active September 15, 2026 19:04
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD