Skip to content

Instantly share code, notes, and snippets.

View maciej's full-sized avatar

Maciej Biłas maciej

View GitHub Profile
@jimschubert
jimschubert / Markdown-JavaScript.markdown.js
Last active September 24, 2023 13:31
DataGrip (IntelliJ) output SQL results to Markdown
if (!String.prototype.repeat) {
// polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
String.prototype.repeat = function(count) {
'use strict';
if (this == null) {
throw new TypeError('can\'t convert ' + this + ' to object');
}
var str = '' + this;
count = +count;
if (count != count) {
@acolyer
acolyer / service-checklist.md
Last active January 30, 2024 17:39
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@jboner
jboner / latency.txt
Last active May 5, 2024 03: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
@maciej
maciej / init-scala.sh
Last active November 20, 2021 19:54
Bootstrap a Scala project (with SBT + IDEA)
#!/bin/bash
PROJECT_NAME="$1"
SCALA_VERSION="2.9.1"
SCALATEST_VERSION="1.6.1"
MOCKITO_VERSION="1.8.5"
mkdir $PROJECT_NAME
cd $PROJECT_NAME
@maciej
maciej / purge-svn.sh
Created October 27, 2011 14:14
Remove all .svn folders
find . -name ".svn" -exec rm -rf {} \;
@maciej
maciej / create_entries.sh
Created October 3, 2011 15:26
Transforms SQL Import script into Java-like entries enum content
# TODO replace the magic 57 with an actual match of the prefix
perl -pe 's/.{57}('.*')\);$/\1/' entries.txt | tr "[:lower:]" "[:upper:]" | sed "s/'//g" | sed -E 's/([^A-Z])+/_/g' | perl -e '$i = 1; while (<>) {chomp; printf("%s(\"%04d\"),\n", $_, $i); $i = $i + 1}'
@maciej
maciej / mysql_drop_create.sh
Created August 16, 2011 12:06
Re-create a database in MySQL
#!/usr/bin/env bash
# Author: Maciej Bilas (@maciejb)
# Based on http://david-burger.blogspot.com/2010/01/truncate-all-tables-in-mysql-database_31.html
# https://gist.github.com/290596
usage() {
echo "\
Usage: $0 -u username -d database [-h host] [-o port)] \\