Skip to content

Instantly share code, notes, and snippets.

View jakekara's full-sized avatar
💾

Jake jakekara

💾
View GitHub Profile
@jakekara
jakekara / sig.c
Created May 9, 2017 15:55
Examining the return valu of signal function
/*
* sig.c - examining the return value of the signal function
*
* The signal function returns the pointer to the previous
* handler for the signal.
*/
#include <stdio.h> /* for printf */
#include <signal.h> /* for signal */
#include <stdlib.h> /* for exit */
@jakekara
jakekara / stat_size.c
Created May 10, 2017 14:17
get a file's size in bytes two ways, using lseek and stat
/*
* determine a file's size with stat
*/
#include <sys/stat.h> /* for stat */
#include <stdio.h> /* for printf */
int main(int ac, char *av[])
{
if ( ac < 2 ) return 0;
@jakekara
jakekara / netyet.sh
Created June 29, 2017 15:20
Announce (using MacOS say) when the Internet is working again.
# ============================================
#
# netyet.sh - Announce, in English, when your
# Internet connection is working
#
# You could also use:
#
# ping -i 60 -a 8.8.8.8
#
# which will just ring the terminal bell once
@jakekara
jakekara / appicon-resize.sh
Created November 12, 2017 16:26
create versions of a .png for all ios required appicon sizes
# usage: ./appicon-resize.sh ORIGINAL_PNG.png
ORIG=$1
function resize {
convert $ORIG -resize $1 $(echo $ORIG | sed -e "s/.png/-$1.png/g")
}
resize 1024
resize 167
@jakekara
jakekara / get_unemployment_ct.py
Created December 22, 2017 15:14
Get CT Unemployment rates as pandas dataframe
#
# get unemployment rates for CT and US
# Jake Kara, December 2017
#
# get unemployment rate CSV because these excel links:
# http://www1.ctdol.state.ct.us/lmi/unemploymentrate.asp
# seem to work in non-IE browsers or pandas/requests lib
@jakekara
jakekara / ipclass.c
Last active February 4, 2018 17:48
Determine IPv4 class. Just a quick teaching tool for those of us who need to convince ourselves that the most significant bits thing works.
/********************************************************
* ipclass.c
*
* Demonstrate that the first significant bits
* can be used to determine the address class
*
*
* https://en.wikipedia.org/wiki/Classful_network
*******************************************************/
#include <stdio.h>
@jakekara
jakekara / UNIX File Permissions.playground
Last active March 22, 2018 20:24
List all possible UNIX file permissions -- example to teach myself enums and structs in Swift
// Unix File Permissions - List all possible file permissions
// Written to teach myself structs and enums in Swift
// Jake Kara, September 2017
enum Permission:Int{
case None = 0
case Execute, // 1
Write, // 2
ExecuteWrite, // 1 + 2 = 3
@jakekara
jakekara / mine_demo.py
Created September 16, 2018 14:48
Demo of how blockchain mining works, and why it gets harder and harder
"""
usage: python mine_demo.py ZEROES VALUE_TO_HASH
Find a nonce that, when concatenated with VALUE_TO_HASH, results in an
SHA256 hexdigest that starts with ZEROES number of zeroes.
output: NONCE HASH
Where NONCE is the solution that resulted in a HASH that the required
number of zeroes at the start.
@jakekara
jakekara / nagsite.sh
Created September 26, 2018 18:05
Bash script to check if a site is online (via ping) every X seconds until it is back online.
#!/usr/bin/env sh
# nagsite.sh - ping a site until it comes back online
RET_VAL=1;
#
# checksite - Check if a site is online
# args - url to ping
# returns - no returns, but modifies RET_VAL
@jakekara
jakekara / clean-mess.sh
Last active October 3, 2018 12:49
Convert a SQL text output to CSV, for when someone sends you SQL text output of a table instead of a CSV...
#!/usr/bin/env sh
#
# clean-mess.sh - Convert a SQL text output to CSV, for when
# someone sends you SQL text output of a table instead of a CSV...
#
# Beware, this will not properly handle double spaces in a column
# because that wasn't an issue for the data I received.
#
# In this case, it just does every .mess file in a folder called data