Skip to content

Instantly share code, notes, and snippets.

View ryanwoodsmall's full-sized avatar
🍞
🍞 bread 🍞 sandwich 🍞

ryan ryanwoodsmall

🍞
🍞 bread 🍞 sandwich 🍞
View GitHub Profile
@ryanwoodsmall
ryanwoodsmall / gclone.c
Last active June 30, 2018 06:11
clone only git client using libgit2
//
// gclone.c
// clone only git client using libgit2
// ignores all cert errors - unsafe!
// usage: glone <url> <path>
// links:
// sample clone: https://libgit2.github.com/docs/guides/101-samples/#repositories_clone_simple
// based on examples/network/clone.c: https://github.com/libgit2/libgit2/blob/master/examples/network/clone.c
// license: public domain
//
@ryanwoodsmall
ryanwoodsmall / sysinfodirjson.py
Created June 3, 2018 05:58
dump json of dir(os/platform/sys)
#!/usr/bin/env python
import json
import os
import platform
import sys
i = {}
for m in [os,platform,sys]:
@ryanwoodsmall
ryanwoodsmall / rendermd.cgi
Last active March 16, 2019 04:50
extremely simple python 2.7 + apache markdown + gfm + yaml renderer cgi
#!/opt/python/current/bin/python
# working meta_yaml.py:
# mde="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')/markdown/extensions"
# test -e ${mde} && mkdir -p ${mde}
# wget -P ${mde} https://raw.githubusercontent.com/teoric/python-markdown-yaml-meta-data/master/meta_yaml.py
# sed -i 's/>meta/<normalize_whitespace/g' ${mde}/meta_yaml.py
#
# apache conf:
# Action rendermd /cgi-bin/rendermd.cgi
@ryanwoodsmall
ryanwoodsmall / linknodewifimanager.ino
Created January 8, 2018 01:00
linknode d1 / wemos d1 r1 wifimanager example
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
@ryanwoodsmall
ryanwoodsmall / lkvh.c
Created October 25, 2017 07:02
get linux kernel version from linux/version.h header and uname() syscall
#include <stdio.h>
#include <linux/version.h>
#include <sys/utsname.h>
/*
* from rhel7's linux/version.h:
* #define LINUX_VERSION_CODE 199168
* #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
*/
@ryanwoodsmall
ryanwoodsmall / jsontoxml.py
Last active February 14, 2019 17:06
simple python xml -> json conversion using xmltodict
#!/usr/bin/env python
import fileinput
import json
from dicttoxml import dicttoxml
jsonin = ""
jsondict = ""
jsonxml = ""
@ryanwoodsmall
ryanwoodsmall / adservers.crontab
Last active August 26, 2017 00:00
openwrt adservers crontab, add /etc/hosts.adservers to dnsmasq as additional hosts file
#1 0 * * * wget -q -O - 'http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=0' | sed '/<pre>/,/<\/pre>/!d' | grep -v 'pre>' > /etc/hosts.adservers
1 0 * * * wget -q -O - 'http://pgl.yoyo.org/as/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext' > /etc/hosts.adservers
@ryanwoodsmall
ryanwoodsmall / bload.sh
Last active January 28, 2018 06:03
dump twitter block list to paged json files with cursors / block twitter advertisers / etc.
#!/bin/bash
mkdir -p out
for i in $(cat advertisers_to_block.txt) ; do
{
echo '{ "'${i}'" : ['
twurl -d "screen_name=${i}" /1.1/blocks/create.json | jq -M .
echo ' ] }'
} | tee out/${i}.json >/dev/null 2>&1
@ryanwoodsmall
ryanwoodsmall / myexpt.js
Last active March 29, 2017 01:54
nasty buggy javascript exponent thing
function myexpt(x, y) {
var expt = 1;
if (x < 0) {
// XXX - need to check Number.isFinite(parseFloat(y)) and cast for modulus via parseInt
if (y % 2 != 0) {
expt = -1 * myexpt(Math.abs(x), y);
} else {
expt = myexpt(Math.abs(x), y);
}
} else {
@ryanwoodsmall
ryanwoodsmall / dumpJarClasses.java
Created February 22, 2017 18:49
dump .class lists in a .jar file
/*
* via http://stackoverflow.com/questions/15720822/how-to-get-names-of-classes-inside-a-jar-file
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;