Skip to content

Instantly share code, notes, and snippets.

@shuhaowu
shuhaowu / debug-dnsmasq.sh
Created May 16, 2016 18:05
Debug dnsmasq by logging its queries
#!/bin/bash
echo 'log-queries' > /etc/dnsmasq.conf
service network-manager restart
tail -f /var/log/syslog
@shuhaowu
shuhaowu / pandoc.css
Last active November 10, 2022 16:43 — forked from killercup/pandoc.css
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@shuhaowu
shuhaowu / a.cpp
Last active August 22, 2022 17:54
#include <iostream>
struct A {
int a;
const A operator*(const A& other) const {
std::cout << "A1: " << this->a << " A2: " << other.a << "\n";
return *this;
}
};
@shuhaowu
shuhaowu / glvsync.c
Created June 24, 2020 03:00 — forked from Cloudef/glvsync.c
Force glXSwapInterval* to whatever you want
/* gcc -std=c99 -fPIC -shared -Wl,-soname,glvsync.so glvsync.c -o glvsync.so
* gcc -m32 -std=c99 -fPIC -shared -Wl,-soname,glvsync.so glvsync.c -o glvsync.so (for 32bit)
*
* Force VSYNC interval on OpenGL applications
* Alternatively can also try FPS locking a OpenGL program
* Usage: LD_PRELOAD="/path/to/glvsync.so" ./program
*/
#define _GNU_SOURCE
#include <dlfcn.h>
@shuhaowu
shuhaowu / podman-shell.nix
Created May 24, 2020 23:56 — forked from adisbladis/podman-shell.nix
Use podman within a nix-shell
{ pkgs ? import <nixpkgs> {} }:
let
# To use this shell.nix on NixOS your user needs to be configured as such:
# users.extraUsers.adisbladis = {
# subUidRanges = [{ startUid = 100000; count = 65536; }];
# subGidRanges = [{ startGid = 100000; count = 65536; }];
# };
package main
import (
"sync"
"github.com/Shopify/ghostferry"
"github.com/Shopify/ghostferry/copydb"
"github.com/sirupsen/logrus"
)
#!MC 1100
$!ALTERDATA
EQUATION = '{s11} = {dUdX}'
$!ALTERDATA
EQUATION = '{s12} = 0.5*({dUdY}+{dVdX})'
$!ALTERDATA
EQUATION = '{s13} = 0.5*({dUdZ}+{dWdX})'
$!ALTERDATA
EQUATION = '{s22} = {dVdY}'
$!ALTERDATA
@shuhaowu
shuhaowu / samsung-evo-plus-32-gb
Last active November 29, 2016 21:33
MicroSD Benchmarks
W530:
Running flashbench
4MiB 14M/s
2MiB 18M/s
1MiB 18M/s
512KiB 18.4M/s
256KiB 17.7M/s
128KiB 17.9M/s
64KiB 17.3M/s
@shuhaowu
shuhaowu / facebook_adblock.greasemonkey.js
Last active August 16, 2016 04:10
Facebook Adblock for GreaseMonkey PoC
// To use this script:
// - For chrome, install https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en
// - For firefox, install https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
// ==UserScript==
// @name Facebook AdBlock
// @namespace facebook_adblock
// @include https://www.facebook.com/
// @version 1
// @grant none
// ==/UserScript==
#!/bin/bash
SAVE_BASE=~/Seafile/Public/gamesaves/RimWorld
switch_save() {
version=$1
cd ~/.config/unity3d/Ludeon\ Studios
rm RimWorld
ln -s ${SAVE_BASE}${version}$2 RimWorld
}