Skip to content

Instantly share code, notes, and snippets.

@javiermon
javiermon / latency.txt
Created December 15, 2022 01:22 — 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
@javiermon
javiermon / LICENSE
Created August 9, 2021 23:30 — forked from domnikl/LICENSE
C function to dump memory
Copyright 2018 Dominik Liebler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
import sys
# example:
# python int2ip.py -1062731768
# 192.168.0.8
#
# stolen from: https://pastebin.com/icqSZhYt
def int_to_ip(signed_int):
""" convert a 32-bit signed integer to an IP address"""
@javiermon
javiermon / gist:515672612abf3ffae27f0ae306c76e26
Created December 12, 2019 01:19 — forked from trodrigues/gist:1023167
Checkout only certain branches with git-svn
If you want to clone an svn repository with git-svn but don't want it to push all the existing branches, here's what you should do.
* Clone with git-svn using the -T parameter to define your trunk path inside the svnrepo, at the same time instructing it to clone only the trunk:
git svn clone -T trunk http://example.com/PROJECT
* If instead of cloning trunk you just want to clone a certain branch, do the same thing but change the path given to -T:
git svn clone -T branches/somefeature http://example.com/PROJECT
#!/usr/bin/python
# https://www.saltycrane.com/blog/2007/11/remove-c-comments-python/
import re
import sys
def remove_comments(text):
""" remove c-style comments.
text: blob of text with comments (can include newlines)
returns: text with comments removed
#!/bin/bash
ffmpeg -i 01.mkv -map_metadata -1 -vcodec libx264 -acodec copy -b:v 5208k ~/01_reduced.mkv
@javiermon
javiermon / gitignore2svnignore.sh
Last active September 6, 2017 17:19 — forked from iegik/gitignore2svnignore.sh
Oneliner to convert svn:ignore into .gitignore
#!/bin/bash
cat .gitignore | sed 's/^/\.\//g;s/\(.*\)\/\([0-9a-zA-Z\*\?\.]*\)$/svn propedit svn:ignore "\2" \1 /mg' | bash
@javiermon
javiermon / serve_http.py
Created March 6, 2017 12:56 — forked from pankajp/serve_http.py
Simple Python HTTP Server with multi-threading and partial-content support
#! /usr/bin/env python
# Standard library imports.
from SocketServer import ThreadingMixIn
import BaseHTTPServer
import SimpleHTTPServer
import sys
import json
import os
from os.path import (join, exists, dirname, abspath, isabs, sep, walk, splitext,
@javiermon
javiermon / zotac_wol.sh
Last active October 12, 2015 12:13
zotac wol
% nmcli con show
NAME UUID TYPE DEVICE
enp1s0 41f94b1c-2893-4f76-b49d-1ba0bb89fb5a 802-3-ethernet p4p1
# By following, one can view current status of Wake-on-LAN settings:
% nmcli c show "enp1s0" | grep 802-3-ethernet.wake-on-lan
802-3-ethernet.wake-on-lan: default
802-3-ethernet.wake-on-lan-password: --
# Enable Wake-on-LAN by magic packet on that connection:
@javiermon
javiermon / log.c
Last active September 28, 2022 23:34
va_args logging
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stdarg.h>
typedef signed int Int;
typedef unsigned int Uint;