Skip to content

Instantly share code, notes, and snippets.

View ciarand's full-sized avatar

Ciaran Downey ciarand

View GitHub Profile
@ciarand
ciarand / LICENSE
Last active August 24, 2021 06:02
Reading network stats from /proc/net/dev
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@ciarand
ciarand / main.go
Last active August 29, 2015 14:21
https server
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
)
tee /etc/ipsec.conf << EOF
config setup
dumpdir=/var/run/pluto/
#in what directory should things started by setup (notably the Pluto daemon) be allowed to dump core?
nat_traversal=yes
#whether to accept/offer to support NAT (NAPT, also known as "IP Masqurade") workaround for IPsec
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v6:fd00::/8,%v6:fe80::/10
#contains the networks that are allowed as subnet= for the remote client. In other words, the address ranges that may live behind a NAT router through which a client connects.
@ciarand
ciarand / fuses.pas
Last active August 29, 2015 14:21
Solving the blowing fuses problem in Pascal
program Fuses;
{
The input consists of several test cases. Each test case describes a set of
electrical devices and gives a sequence of turn on/off operations for these
devices.
The input will be terminated by a test case starting with n = m = c = 0. This
test case should not be processed.
}
@ciarand
ciarand / brew-install-missing
Created April 15, 2015 18:28
install missing brew deps
brew install $(brew missing | perl -ne 'my @splits = split / /; shift @splits; ; print join(" ", @splits) =~ s/[:\n]/ /gr;')
@ciarand
ciarand / sqlite_error.txt
Created February 9, 2015 18:24
sqlite interop error
System.DllNotFoundException
SQLite.Interop.dll
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Data.SQLite.
Exception stack trace:
at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods:sqlite3_config_none (System.Data.SQLite.SQLiteConfigOpsEnum)
at System.Data.SQLite.SQLite3.StaticIsInitialized () [0x00000] in <filename unknown>:0
at System.Data.SQLite.SQLiteLog.Initialize () [0x00000] in <filename unknown>:0
at System.Data.SQLite.SQLiteFactory..cctor () [0x00000] in <filename unknown>:0
@ciarand
ciarand / pre-commit
Last active August 29, 2015 14:13
the really cool PHP pre-commit hook by @ciarand
#!/usr/bin/env php
<?php
/*
.---._----------------------------------+
___________/ ._____) WELCOME TO |
) __| the really cool |
__| PHP pre-commit hook |
..---------.._____| by @ciarand |
+---------------------------------+
$coverage_attrs = option(simplexml_load_file("./app/coverage/coverage.xml"))
->map(method("xpath", ["/coverage/project/metrics"]))
->reject([])
->map(index(0))
->map(method("attributes"))
->get();
@ciarand
ciarand / extract.sh
Created December 13, 2014 03:23
probably extract most of @ciarand's app.net posts (you'll need a token)
#!/bin/sh
curl -q -H "Authorization: Bearer $AUTH_TOKEN" \
"https://api.app.net/posts/search?creator_id=45708&count=200" > tmp.json
while true
do
MIN_ID=$(jq < tmp.json .meta.min_id | sed -e 's/"//g')
jq < tmp.json '.data[].text' | gsed -e 's/^"//' | gsed -e 's/"$//' | gsed -e 's/@\w\+ \?//g' >> ./posts.txt
@ciarand
ciarand / FooBar.php
Created October 24, 2014 23:03
playing around with multiple steps
<?php
class FooBar
{
public function doThing()
{
while (true) {
// just render the regular view for non-post reqs
if (!Request::isPost()) {
break;
}