Skip to content

Instantly share code, notes, and snippets.

View tschaefer's full-sized avatar

Tobias Schäfer tschaefer

View GitHub Profile
@johnlane
johnlane / README.md
Last active November 1, 2023 19:56
Simple installer for ArchLinux on ZFS (tested in VirtualBox)

ArchZFS examples

Use with QEMU; example:

for i in {1..2}; do qemu-img create -f qcow2 hd$i.qcow2 4G; done
qemu-system-x86_64 --enable-kvm -global isa-fdc.fdtypeA=none -cdrom archlinux-2023.07.25-x86_64.iso -nic bridge,br=br0 -m 8192 -smp cpus=4 -hda hd1.qcow2 --hdb hd2.qcow2 &
@ErikAugust
ErikAugust / spectre.c
Last active August 2, 2024 01:59
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
  1. Install speedtest-cli from pip and be sure pip exists:
$ pkgin in py34-pip
$ pip install speedtest-cli
  1. Configure cronjob to run speedtest-cli every X hours or minutes:
2,42 * * * * /opt/local/bin/speedtest-cli --simple &gt; /tmp/speedtest.tmp &amp;&amp; cat /tmp/speedtest.tmp &gt; /tmp/speedtest.out
@andir
andir / tasks_to_ical.py
Created August 18, 2016 14:46
convert taskwarrior tasks to ical entries when they have a scheduled date
#!/usr/bin/env python3
import os.path
from ics import Calendar, Event
import subprocess
import json
def read_tasks():
output = subprocess.check_output(['task', 'export'])
for task in json.loads(output.decode('utf-8')):
if task['status'] == 'completed':
## Depends on your network setup of the global zone build environment
echo '{
"brand": "joyent",
"resolvers": ["8.8.8.8"],
"ram": 512,
"nics": [{
"nic_tag": "switch0",
"ip": "192.168.200.200",
"netmask": "255.255.255.0",
"gateway": "192.168.200.1",
@evgeny-boger
evgeny-boger / mqtt_example.c
Created September 7, 2015 09:04
libmosquitto MQTT example
#include <signal.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <mosquitto.h>
#define mqtt_host "localhost"
#define mqtt_port 1883
@nl5887
nl5887 / gpg-agent.conf
Last active November 14, 2022 09:37
Using GPG Agent on OS-X
launchctl unload -w -S Aqua /System/Library/LaunchAgents/gpg.agent.daemon.plist
launchctl load -w -S Aqua /System/Library/LaunchAgents/gpg.agent.daemon.plist
@dtchepak
dtchepak / echo.rb
Last active September 12, 2022 07:24
Simple Ruby HTTP server to echo whatever GET or POST requests come through. Largely based on https://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/.
# Reference: https://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/
require 'webrick'
class Echo < WEBrick::HTTPServlet::AbstractServlet
def do_GET(request, response)
puts request
response.status = 200
end
def do_POST(request, response)
puts request
@mlanett
mlanett / rails http status codes
Last active November 4, 2024 18:04
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@moertel
moertel / suppress_ruby_output.rb
Last active March 21, 2024 08:54
Temporarily suppress STDOUT and STDERR (ruby)
# Temporarily redirects STDOUT and STDERR to /dev/null
# but does print exceptions should there occur any.
# Call as:
# suppress_output { puts 'never printed' }
#
def suppress_output
original_stderr = $stderr.clone
original_stdout = $stdout.clone
$stderr.reopen(File.new('/dev/null', 'w'))
$stdout.reopen(File.new('/dev/null', 'w'))