Skip to content

Instantly share code, notes, and snippets.

@jboner
jboner / latency.txt
Last active April 9, 2025 11:46
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
@chrisvest
chrisvest / Notes.md
Created June 14, 2012 20:56 — forked from rednaxelafx/JDK5u22_client.log
PrintCompilation on different versions of HotSpot VM

About PrintCompilation

This note tries to document the output of PrintCompilation flag in HotSpot VM. It was originally intended to be a reply to a blog post on PrintCompilation from Stephen Colebourne. It's kind of grown too big to fit as a reply, so I'm putting it here.

Written by: Kris Mok [email protected]

Most of the contents in this note are based on my reading of HotSpot source code from OpenJDK and experimenting with the VM flags; otheres come from HotSpot mailing lists and other reading materials listed in the "References" section.

This

@ayosec
ayosec / README.md
Created July 17, 2012 13:08
Scripts to start a Xvnc server inside a machine

Xvnc

The scripts in this gist will start an Xvnc server with a basic window manager (IceWM). This is intended to use in a virtual machine, where we can need to start a browser to run a test suite.

Installation on Debian

All commands have to be run as root

apt-get install icewm vnc4server
@headius
headius / gist:3491618
Created August 27, 2012 19:34
JVM + Invokedynamic versus CLR + DLR

Too much for teh twitterz :)

JVM + invokedynamic is in a completely different class than CLR + DLR, for the same reasons that JVM is in a different class than CLR to begin with.

CLR can only do its optimization up-front, before executing code. This is a large part of the reason why C# is designed the way it is: methods are non-virtual by default so they can be statically inlined, types can be specified as value-based so their allocation can be elided, and so on. But even with those language features CLR simply cannot optimize code to the level of a good, warmed-up JVM.

The JVM, on the other hand, optimizes and reoptimizes code while it runs. Regardless of whether methods are virtual/interface-dispatched, whether objects are transient, whether exception-handling is used heavily...the JVM sees through the surface and optimizes code appropriate for how it actually runs. This gives it optimization opportunities that CLR will never have without adding a comparable profiling JIT.

So how does this affect dynamic

@ayosec
ayosec / paste_img.py
Created September 15, 2012 16:19
Create images from clipboard
#!/usr/bin/python
#
# Usage: python paste_img.py dest_file.png
#
# This program readd the image stored in the clipboard, and dumps it into a file
import gtk, pygtk
pygtk.require('2.0')
import sys
@ayosec
ayosec / en.yml
Created October 18, 2012 05:47
POC: Type locales in Scala
package: myapp.foo.locales
en:
mailbox:
header:
title: "Your mailbox"
subtitle: "Read and send messages"
welcome: "Welcome %{user}!"
actions:
@ayosec
ayosec / OpenSSL and RSA.md
Created December 17, 2012 21:43
Encrypt/descrypt with OpenSSL and RSA

OpenSSL and RSA

You can encrpt files using a private/public keys.

First, create the keys:

openssl req -x509 -nodes -days 100000 -newkey rsa:2048 \
  -keyout private.pem -out public.pem -subj /
@torgeir
torgeir / #1 - Scala macros tutorial.md
Last active July 6, 2019 08:49
A quick howto on getting started with scala macros (from the scala macros paradise branch, using sbt and sbt gen-idea)

Scala macros tutorial, using sbt

The following steps executed in order will;

  • create the project file structure
  • set the sbt version
  • add the gen-idea sbt plugin (if you want to import your project into intellij)
  • create an sbt build, that builds the macros project prior to the macrostest project (so the regex macro is usable in the macrostest project)
  • create the macros project scala file
  • create the macrostest project scala file
@elimisteve
elimisteve / goroutines2.go
Last active February 18, 2024 01:52
Programming Challenge: Launch 4 threads, goroutines, coroutines, or whatever your language uses for concurrency, in addition to the main thread. In the first 3, add numbers together (see sample code below) and pass the results to the 4th thread. That 4th thread should receive the 3 results, add the numbers together, format the results as a strin…
// Steve Phillips / elimisteve
// 2013.01.03
// Programming Challenge: Launch 4 threads, goroutines, coroutines, or whatever your language uses for concurrency,
// in addition to the main thread. In the first 3, add numbers together (see sample code below) and pass the results
// to the 4th thread. That 4th thread should receive the 3 results, add the numbers together, format the results as
// a string (see sample code), and pass the result back to `main` to be printed.
//
// Do this as succinctly and readably as possible. _Go!_ #golang #programming #concurrency #challenge
package main
@ayosec
ayosec / README.md
Last active December 10, 2015 17:48
Basic client to get PivotalTracker stories, in a easy to read format.

List for PivotalTracker stories

Get the stories for your PitalTracker project.

Installation

  • Install httparty and term-ansicolor gems
  • Download the pt-list.rb file in this gist.
  • Set execution flag with chmod +x
  • Put it in some directory in your $PATH