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 / myexpt.scm
Last active December 28, 2019 08:06
quick and dirty "x ^ y" power function in scheme to raise a base to an exponent
(define (myabs x)
(cond ((< x 0) (* x -1))
((x >= 0) (* x 1))))
(define (myexpt x y)
(cond ((< x 0) (* (cond ((odd? (myabs y)) -1)
(else 1))
(myexpt (myabs x) y)))
((< y 0) (/ 1 (myexpt x (myabs y))))
((= y 0) 1)
@ryanwoodsmall
ryanwoodsmall / jsysprop.java
Last active November 3, 2016 19:33
dump java system properites
/*
* single command version:
* jrunscript -e 'java.lang.System.getProperties().list(java.lang.System.out);'
*/
import java.util.Properties;
public class jsysprop {
public static void main(String[] args) {
System.getProperties().list(System.out);
@ryanwoodsmall
ryanwoodsmall / jcecheck.java
Created July 7, 2016 18:02
JCE unlimited strength crypto checker
// exit code 0 if JCE is available, 1 otherwise
/*
* one-liner:
* jrunscript -e 'exit (javax.crypto.Cipher.getMaxAllowedKeyLength("AES") < 256);'
*/
import javax.crypto.Cipher;
public class jcecheck {
@ryanwoodsmall
ryanwoodsmall / cpu_mem.py
Created July 12, 2016 15:38
get CPU counts and memory in bytes for Python on Linux
import re
def get_cpu_count():
cpu_count = 0
cpu_file = '/proc/cpuinfo'
ch = open(cpu_file, 'r')
for line in ch:
if re.match('processor', line):
cpu_count = cpu_count + 1
ch.close()
@ryanwoodsmall
ryanwoodsmall / extremely_dangerous_ssh_config
Last active October 3, 2021 01:56
~/.ssh/config settings you should never, ever use
Host *
AddKeysToAgent yes
ForwardAgent yes
HostKeyAlgorithms +ssh-rsa
KexAlgorithms +diffie-hellman-group1-sha1
LogLevel QUIET
PubkeyAcceptedKeyTypes +ssh-rsa
ServerAliveCountMax 10
ServerAliveInterval 30
StrictHostKeyChecking no
@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;
@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 / 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 / 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 / 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 = ""