Skip to content

Instantly share code, notes, and snippets.

@hayleyxyz
hayleyxyz / usb-swap.service
Created July 8, 2019 20:58
systemd service to automatically toggle swapon when a certain usb drive is installed
[Unit]
Description=Flash drive swapon
Requires=dev-disk-by\x2duuid-7849984a\x2de42f\x2d497a\x2dafec\x2d8bebb8384f7a.device
After=dev-disk-by\x2duuid-7849984a\x2de42f\x2d497a\x2dafec\x2d8bebb8384f7a.device
[Service]
ExecStart=/sbin/swapon -U 7849984a-e42f-497a-afec-8bebb8384f7a
[Install]
WantedBy=dev-disk-by\x2duuid-7849984a\x2de42f\x2d497a\x2dafec\x2d8bebb8384f7a.device
@hayleyxyz
hayleyxyz / install_realpath.sh
Created June 7, 2019 23:13
Install realpath on macOS using GNU coreutils
#!/bin/sh
curl https://ftp.gnu.org/gnu/coreutils/coreutils-8.31.tar.xz -O
tar xf coreutils-8.31.tar.xz
cd coreutils-8.31
./configure --enable-no-install-program=$(./build-aux/gen-lists-of-programs.sh --list-progs | tr '\n' ',' | sed -e 's/realpath,//' -e 's/,$//')
make
ln -s $(which install) src/ginstall # Hack because we didn't build GNU install, but make install requires it
echo "\nNow run 'make install' to install realpath\n"
#include <iostream>
#include <SDL.h>
void draw(SDL_Window * window, SDL_Renderer * renderer) {
int w, h;
SDL_GetWindowSize(window, &w, &h);
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
//srand(x * y);
embed: function(t, e) {
var i = function(t) {
var e = JSON.parse(t.data),
i = e.action,
n = e.data || {};
void 0 !== mediamanager[i] && mediamanager[i](n)
};
this.eventsSet || (void 0 !== window.addEventListener ? (window.removeEventListener("message", i), window.addEventListener("message", i)) : (window.detachEvent("onmessage", i), window.attachEvent("onmessage", i)), this.eventsSet = !0), void 0 === this.meta.pageurl && (this.meta.pageurl = window.location.href), void 0 === this.autoresize && (this.autoresize = !1), void 0 === this.aspect && (this.aspect = ["16", "6"]);
var n,
r = void 0 !== this.scroll && this.scroll;
@hayleyxyz
hayleyxyz / adb.sh
Created December 16, 2015 03:56
adb logcat example
# Usage: logcat [options] [filterspecs]
# (adb logcat or run logcat from shell inside Android)
# filterspecs are a series of
# <tag>[:priority]
#
# where <tag> is a log component tag (or * for all) and priority is:
# V Verbose
# D Debug
# I Info
# W Warn
@hayleyxyz
hayleyxyz / interfaces
Created December 13, 2015 05:31
Proxmox NAT - /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# vmbr0: Bridging. Make sure to use only MAC adresses that were assigned to you.
auto vmbr0
iface vmbr0 inet static
#!/usr/bin/env php
<?php
/*
* This script will transform file names for templates downloaded for OpenVZ[1],
* to match the format used in Proxmox[2].
*
* [1] https://download.openvz.org/template/precreated/
* [2] http://pve.proxmox.com/wiki/Template_naming_convention
*
$ bash -c "echo '2 eth1_rt' >> /etc/iproute2/rt_tables"
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto eth0
iface eth0 inet dhcp
auto eth0:1
@hayleyxyz
hayleyxyz / server.js
Created January 26, 2015 19:59
node.js http server
var http = require('http');
if(process.argv.length < 3) {
console.error('Missing listen address argument');
return;
}
var listenAddress = process.argv[2];
var server = http.createServer(function (req, res) {
{
"id": 617991,
"token": "6c3afbfe52",
"title": "(C80) [Fukunoren (Yukiwo)] labyrinth (Alice In Wonderland) [SMDC] [English]",
"title_jp": "(C80) [福のれん (ユキヲ)] labyrinth (ふしぎの国のアリス) [英訳]",
"uploader": "shuntensatsu",
"rating_count": 96,
"rating_average": 4.72,
"images_count": 19,
"file_size": 16714949,