Skip to content

Instantly share code, notes, and snippets.

@etcwilde
etcwilde / ght-restore-psql
Last active September 3, 2019 19:26
Restore the GHTorrent database to postgres instead of mysql (based on mysql-2017-01-19 image)
#!/usr/bin/env bash
# Evan Wilde <[email protected]>
# July 20, 2017
# defaults
user="postgres"
passwd=""
host="localhost"
db="ghtorrent"
tmpdir='/tmp'
@etcwilde
etcwilde / failed.sh
Last active January 27, 2017 00:11
Fun Shell Scripts
#!/bin/sh
# Who is trying to access your server without permission?
sudo journalctl -u sshd \
| awk '/Failed password for/ {print $11}' \
| while read address; do whois "$address" \
| grep -m 1 -i "Country: " \
| sed "s/[Cc]ountry:/$address/"; done \
| awk '{print $2 " --> " $1}' \
| uniq -c \
@etcwilde
etcwilde / theano.py
Created October 21, 2016 02:40
Notes for machine learning
#!/bin/env python
# Just playing with theano. This doesn't do anything particularly useful
# other than showing how things work
import numpy
import theano
import theano.tensor as T
from theano import function
@etcwilde
etcwilde / brightness.service
Last active May 20, 2016 17:28
Hacky hacks to make things work in Linux
# Evan Wilde <[email protected]>
# May 19 2016
# /usr/lib/systemd/system/brightness.service
# Grants non-root permissions to the backlight file so that it can be set by a user process
#
[Unit]
Description=Grants non-root write access to the brightness file
[Service]
@etcwilde
etcwilde / lookup.sh
Created April 5, 2016 20:20
Lookup serial devices connected to the serial port
#!/bin/bash
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
(
syspath="${sysdevpath%/dev}"
devname="$(udevadm info -q name -p $syspath)"
[[ "$devname" == "bus/"* ]] && continue
eval "$(udevadm info -q property --export -p $syspath)"
[[ -z "$ID_SERIAL" ]] && continue
echo "/dev/$devname - $ID_SERIAL"
@etcwilde
etcwilde / CookieBase.md
Last active September 30, 2023 20:59
Recipes

Cookie Dough

Simple cookie dough recipe that goes well in Chocolate chip cookies

Ingredients

  • 1/2 cup butter
  • 1/2 cup (100 g) granulated sugar
  • 1/2 cup (104 g) brown sugar (packed)
  • 1 eggs
@etcwilde
etcwilde / concurrent_pi.rs
Last active September 1, 2015 23:28
Some quick and dirty Rust snippets
extern crate rand;
extern crate time;
use std::thread;
use std::sync::mpsc;
use rand::distributions::{IndependentSample, Range};
use time::PreciseTime;
/// Conncurent Monte-carlo PI calculator
fn main()
{
@etcwilde
etcwilde / keyboard_send.c
Created June 24, 2015 15:29
Keyboard Utility
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#include <stdio.h>
// Send data to keyboard
// This is for my IBM rapid access 1 keyboard media key support
// To activate all keys:
//
// sudo ./keyboard_send ea 71
@etcwilde
etcwilde / disk_rescan.sh
Created June 1, 2015 17:07
Various handy hardisk scripts
#!/bin/sh
# Rescan Hard disks
if [ "$(id -u)" != "0" ]; then
echo "Run as root" 1>&2
exit 1
fi
for i in $(ls /sys/class/scsi_host/); do
echo "- - -" > /sys/class/scsi_host/$i/scan;
@etcwilde
etcwilde / makefile
Created May 22, 2015 20:24
A fairly generalized automatic single-level C/C++ Makefile
# Evan Wide
# Generic Makefile
# LIBS
# pthread Threading
# Defines
# DEBUG on debug build
# TEST on test build
EXEC = project_name