Skip to content

Instantly share code, notes, and snippets.

View john-science's full-sized avatar

John Stilley john-science

View GitHub Profile
@john-science
john-science / latency.txt
Created January 13, 2021 16:11 — forked from jboner/latency.txt
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
@kirkegaard
kirkegaard / tamagotchi.py
Last active April 11, 2024 08:42
a tamagotchi simulator in python
import os
import time
import sched
import threading
import inquirer
class Tamagotchi:
age = 0
bored = 0
@john-science
john-science / freemont_diner_buttermilk_biscuits.md
Last active March 2, 2023 15:01
Fremont Diner Buttermilk Biscuits Recipe

Buttermilk Biscuits

Makes 12 2 ½” biscuits

This is a recipe for fluffy biscuits, not flakey. They are best straight out of the oven with butter or jam. Always make extra, they are great split, buttered, and griddled for breakfast sandwiches. We use a food processor to mix the butter and flour. You can use your hands or a fork but using the food processor helps to keep the butter cold which will help make tender biscuits (and it is much faster & more uniform).

Equipment

  • food processor
  • 2 ½” round biscuit cutter
@magnetikonline
magnetikonline / README.md
Last active February 4, 2024 07:45
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.
@john-science
john-science / smallest_lenses_for_sony_a7.md
Last active August 27, 2019 15:06
The smallest lenses adaptable to the Sony a7 (series)

Smallest Lenses Adaptable to the Sony a7

This has been moved to a blog post.

@john-science
john-science / HelloWorld.java
Last active June 15, 2020 23:31
Emoji in Java
/**
* A quick example of using Emoji in Java.
* compile with: javac HelloWorld.java
* run with: java HelloWorld
*/
public class HelloWorld {
public static void main(String[] args) {
String \u0ca2 = "Hello, World 1";
@pathikrit
pathikrit / SudokuSolver.scala
Last active April 12, 2024 15:00
Sudoku Solver in Scala
val n = 9
val s = Math.sqrt(n).toInt
type Board = IndexedSeq[IndexedSeq[Int]]
def solve(board: Board, cell: Int = 0): Option[Board] = (cell%n, cell/n) match {
case (r, `n`) => Some(board)
case (r, c) if board(r)(c) > 0 => solve(board, cell + 1)
case (r, c) =>
def guess(x: Int) = solve(board.updated(r, board(r).updated(c, x)), cell + 1)
val used = board.indices.flatMap(i => Seq(board(r)(i), board(i)(c), board(s*(r/s) + i/s)(s*(c/s) + i%s)))
@bonzanini
bonzanini / sentiment_classification.py
Last active October 30, 2020 23:58
Sentiment analysis with scikit-learn
# You need to install scikit-learn:
# sudo pip install scikit-learn
#
# Dataset: Polarity dataset v2.0
# http://www.cs.cornell.edu/people/pabo/movie-review-data/
#
# Full discussion:
# https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@jboner
jboner / latency.txt
Last active April 26, 2024 03:40
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