Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active July 23, 2024 14:12
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
@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
@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 +@
(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)))
@KonradIT
KonradIT / readme.md
Last active July 11, 2024 20:46
GoPro Studio for Linux
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']
(<|>) :: Parser a -> Parser a -> Parser a
parser1 <|> parser2 = P $ \some -> case parse parser1 some of
[] -> parse parser2 some
result -> result
@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."
@JoshCheek
JoshCheek / rails_sib.rb
Last active February 1, 2018 16:57
Rails app in 1 file, running with Seeing Is Believing
gem 'rails', '4.2.1' # prob works on others, too, but this is the one I figured it out on
require "rails"
require 'active_record'
require 'action_controller/railtie'
require 'action_view/railtie'
# ===== Configuration =====
Rails.logger = ActiveRecord::Base.logger = Logger.new $stdout
ActiveSupport::LogSubscriber.colorize_logging = false
@kosmikus
kosmikus / TinyServant.hs
Created November 1, 2015 20:30
Implementation of a small Servant-like DSL
{-# LANGUAGE DataKinds, PolyKinds, TypeOperators #-}
{-# LANGUAGE TypeFamilies, FlexibleInstances, ScopedTypeVariables #-}
{-# LANGUAGE InstanceSigs #-}
module TinyServant where
import Control.Applicative
import GHC.TypeLits
import Text.Read
import Data.Time