Skip to content

Instantly share code, notes, and snippets.

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@chetanmeh
chetanmeh / .bashrc
Last active February 28, 2020 09:48
Script to launch a KDE Konsole window with multiple tabs. It is based on script provided in [Linux Journal](http://www.linuxjournal.com/content/start-and-control-konsole-dbus). It helps to bootstrap development env by launching multiple tabs with preconfigured directory and titles.
source ~/path/to/tabs.sh
load-dev(){
#Create sessi data format '<Tab Name/Title> <Profile Name> <Working Directory>'
local sessions=(
oak Shell 'clear; cd ~/git/apache/oak'
sling Shell 'clear; cd ~/git/apache/sling'
felix Shell 'clear; cd ~/git/apache/felix'
)
start_sessions sessions[@]
@cabal95
cabal95 / vm-backup.sh
Created July 25, 2015 17:53
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
@null-dev
null-dev / index.php
Created June 19, 2017 23:51
1fichier.com direct link generator (PHP)
<?php
if(!isset($_GET['a'])) {
die('<form action="" method="get"><input type="text" name="a"/><input type="submit"/></form>');
}
$url = "https://1fichier.com/?" . urlencode($_GET['a']) . "?auth=1&inline";
stream_context_set_default(array(
'http' => array(
'method' => 'GET',
'header' => 'Authorization: Basic ' . '[BASE64 encoded login credentials. Format: "user:pass" (without quotes)]'
@harrykipper
harrykipper / gist:2c2884938cf7484c647e8aa6f0abd089
Created November 13, 2017 16:03
Prevent the kernel from disabling ASPM
diff -rupN linux-4.10-orig/drivers/acpi/pci_root.c linux-4.10/drivers/acpi/pci_root.c
--- linux-4.10-orig/drivers/acpi/pci_root.c 2017-04-03 11:16:04.296665638 +0200
+++ linux-4.10/drivers/acpi/pci_root.c 2017-04-03 11:17:21.696665034 +0200
@@ -494,13 +494,13 @@ static void negotiate_os_control(struct
* it's unsupported. Leave existing configuration
* intact and prevent the OS from touching it.
*/
- dev_info(&device->dev, "FADT indicates ASPM is unsupported, using BIOS configuration\n");
- *no_aspm = 1;
+ dev_info(&device->dev, "FADT indicates ASPM is unsupported, not caring and keeping ASPM\n");
@pigeonhill
pigeonhill / HHB.Lua
Last active June 1, 2019 15:45
Hand Held Bracketing Script
--HHB Script Release 1.75
--[[
********************************************************************************************
This script attempts to capture 'the best' bracket sequence when hand holding.
The bracketing scheme is based on ISO shifting as well as time shifting.
The general strategy being to time shift from the highlights at the lowst ISO you can, and ISO shift from the shadows from the lowest Tv you can, at ISO 100. That is try and maximise photon capture, ie for the highest DR.
Note pushing ISO too far is pointless, as once above a critical level, Canon cameras go into ISO invariant zone (varies with camera) and overall DR falls with no increase in (read) noise.
You should also be high enough to be above the 'pattern noise', but not too high.
On a 5D3 a figure of 6400 seems to work well, on an EOSM, say, maybe try 1600 or 3200.
@droM4X
droM4X / collectd-qbittorrent
Last active June 24, 2023 17:58
Collectd - Qbittorrent stats + current speeds // Qbittorrent v4.1+
#!/bin/bash
HOSTNAME=${COLLECTD_HOSTNAME:-localhost};
INTERVAL=${COLLECTD_INTERVAL:-60};
while sleep "$INTERVAL"
do
for filter in active all downloading
do
url="http://localhost:8080/api/v2/torrents/info?filter=$filter"
@AndrewLipscomb
AndrewLipscomb / README.md
Created March 24, 2020 11:06
How to set up static nspawn IP address networking without a bridge

How to set up static nspawn IP address networking without a bridge

Note - this article assumes you have reasonable familiarity with systemd, networkd and nspawn/machinectl

What is this guide for

There seem to be a lot of references on the internet for nspawn networking with a bridge - but not on simply using the stock veth networking with static addresses. The default behaviour of nspawn (as of 24/03/20 and systemd:245 on Arch) is to:

  • Make a virtual ethernet port on the host (defined by /lib/systemd/network/80-container-ve.network)
  • Make a virtual ethernet port in the container (defined by /lib/systemd/network/80-container-host0.network)
  • Based on those configurations, serve the host port a random IP from the local network ranges with a 28 bit subnet, and a DHCP server for the host port serves a random IP in the subnet to the container
@aelk00
aelk00 / remove-likes.md
Last active March 1, 2024 00:58
Remove all your facebook likes
#! /bin/bash -e
if [ -z "$1" ]; then
echo 'usage: [OPTIONS] <file>|<dir>'
echo 'same as btrfs filesystem defrag (look at its --help)'
exit
fi
if [ ! "$(id -u)" -eq 0 ]; then
echo 'This probably needs root, if not edit' "$0"
echo 'Remove line 10: sed -e '\''10d'\'' -i' "$0"
exit 2