Skip to content

Instantly share code, notes, and snippets.

@muaazsaleem
muaazsaleem / pngTojpg.sh
Created February 26, 2020 14:40
Batch convert images from png to jpg on a mac
#!/bin/bash
PNG_PATH=~/Desktop
shopt -s nullglob
png_files=($PNG_PATH/*.png)
shopt -u nullglob
for pfile in "${png_files[@]}"; do
jfile="${pfile%.png}.jpg"
@muaazsaleem
muaazsaleem / murder_mystry.rb
Created June 23, 2019 10:04
Some music written with Sonic Pi
live_loop :rolling_drum do
sample :drum_roll, amp: 0.5
sleep 16
end
live_loop :heavy_kick do
sample :drum_heavy_kick, amp: 0.5
sleep 0.5
end
@muaazsaleem
muaazsaleem / latency.txt
Created January 14, 2017 22:55 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
@muaazsaleem
muaazsaleem / crawler.go
Created October 23, 2016 07:01
A Tour of Go. Exercise: Web Crawler
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@muaazsaleem
muaazsaleem / pub_sub.exs
Last active April 2, 2016 20:22 — forked from JEG2/pub_sub.exs
An example pub/sub server in Elixir.
defmodule PubSubServer do
def start(subscriber_callback \\ nil) do
spawn(__MODULE__, :run, [[ ], subscriber_callback])
end
def subscribe(server, handler) do
send(server, {:subscribe, self})
listen(handler)
end