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 / 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 / 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 / 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 / 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 / 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
//
SOLIPSISTIC ECLIPSE PUBLIC LICENSE
Version 1, NOVEMBER 2014
Copyright (C) 2014
Everyone is permitted to copy and distribute verbatim copies of this license
document. Modified copies of this document are permitted provided that they
denounce BOTH the original AND their copy as mere sense data with no verifiable
cause outside the mind.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@ryanwoodsmall
ryanwoodsmall / python-readline-tab-completion.py
Last active January 9, 2019 09:43
python-readline-tab-completion.py
# https://stackoverflow.com/questions/246725/how-do-i-add-tab-completion-to-the-python-shell
# https://gist.github.com/twneale/5245670
#
# add to ~/.pythonrc
# set environment:
# export PYTHONSTARTUP="$HOME/.pythonrc"
#
# enable syntax completion
try:
import readline
@ryanwoodsmall
ryanwoodsmall / loop_an_mp3_with_lame.sh
Created February 16, 2019 08:44
loop_an_mp3_with_lame.sh
#!/bin/bash
for i in {1..7} ; do
echo $i 1>&2
cat the_caretaker-an_empty_bliss_beyond_this_world.mp3
done \
| lame \
--preset standard \
--mp3input \
- \
the_caretaker-an_empty_bliss_beyond_this_world-6hr_loop.mp3
@ryanwoodsmall
ryanwoodsmall / esp8266_wifi.py
Last active February 8, 2021 19:53
esp8266 esp32 micropython main.py wifi setup
#!/usr/bin/env python
#
# erase the esp8266 flash
# sudo $(which esptool.py) --port /dev/ttyUSB0 erase_flash
# write the micropython firmware
# sudo $(which esptool.py) --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect -fm dio 0 /tmp/esp8266-20190125-v1.10.bin
# save this file to esp8266_wifi.py
# add your wireless network/password to the wifi.connect() line
# run:
# echo "f=open('/main.py','w')"
@ryanwoodsmall
ryanwoodsmall / etc_init.d_rcS
Last active May 2, 2019 18:16
busybox_lxc_files
#!/bin/sh
/bin/test -e /etc/fstab && /bin/mount -a
/bin/test -e /dev/urandom || /bin/mknod -m 666 /dev/urandom c 1 9
/bin/test -e /dev/zero || /bin/mknod -m 666 /dev/zero c 1 5
/bin/test -e /dev/null || /bin/mknod -m 666 /dev/null c 1 3
/bin/syslogd
/bin/ifconfig eth0 0.0.0.0 up
/bin/udhcpc -b -v