Skip to content

Instantly share code, notes, and snippets.

View chrisshroba's full-sized avatar

Christopher Shroba chrisshroba

View GitHub Profile
@chrisshroba
chrisshroba / gist:3e77c7832d1df5894127718b12b67653
Created January 24, 2022 14:17
Cron Refresher (to be put at the top of my crontab)
# Cron Syntax Refresher
#
# /- Minute (0-59)
# | /- Hour (0-23)
# | | /- Day (1-31)
# | | | /- Month (1-12)
# | | | | /- Day of Week (0-7: 0 and 7 are Sunday)
# * * * * *
#
# * is any value
# This is a sanity check to make sure we're parsing major, minor, patch versions correctly
➜ ~ echo 'abcdeef-v123.456.789 blah' | sed -E 's/.*-v([0-9]+)\.([0-9]+)\.([0-9]+).*/major=\1, minor=\2, patch=\3/g'
major=123, minor=456, patch=789
# These parse out each of the parts
➜ ~ echo 'abcdeef-v123.456.789 blah' | sed -E 's/.*-v([0-9]+)\.([0-9]+)\.([0-9]+).*/\1/g'
123
➜ ~ echo 'abcdeef-v123.456.789 blah' | sed -E 's/.*-v([0-9]+)\.([0-9]+)\.([0-9]+).*/\2/g'
456
➜ ~ echo 'abcdeef-v123.456.789 blah' | sed -E 's/.*-v([0-9]+)\.([0-9]+)\.([0-9]+).*/\3/g'
# Make it so when you set the window title,
# it is never automatically changed by tmux
set-option -g allow-rename off
# This enables mouse reporting. It lets you:
# - Click on a pane to activate it
# - Right click a pane to `mark` it
# - Drag borders to resize panes
setw -g mouse on
set -g mouse on
# Welcome to my tmux config!
# Some helpful notes to future me
# - bind is an alias of bind-key (no difference).
# - bind <key> binds the key after the prefix.
# - bind -r <key> binds the key in the root table,
# meaning no prefix is necessary.
# -
# Put Plugins first because they may define behavior
@chrisshroba
chrisshroba / regex
Last active December 16, 2016 14:41
A CLI for searching for a matching group and returning only that group (Rather than the entire matching line as grep does)
#!/usr/bin/env python
import re
from sys import argv
if len(argv)<3:
print("Usage:")
print("{} <string> <pattern>".format(argv[0]))
exit(2)
@chrisshroba
chrisshroba / one_line_flask_app.py
Last active December 15, 2016 14:02
A one liner flask app!
(lambda a:a.route('/')(lambda:'Hello')+a.run())(__import__('flask').Flask(''))
@chrisshroba
chrisshroba / nginx.conf
Created October 31, 2016 14:59
The nginx configuration for wiki.shroba.io
server {
listen 80;
server_name wiki.shroba.io w;
client_max_body_size 15M;
client_body_buffer_size 128k;
root /usr/share/nginx/www/wiki;
index doku.php;
/* File: simp3.k */
requires "arithbool.k"
module SIMP3-SYNTAX
imports ARITHBOOL-SYNTAX
imports ARITHBOOL-SEMANTICS
/*
ARITHBOOL-SYNTAX introduces (variable free) arithmetic and boolean
@chrisshroba
chrisshroba / server.py
Created September 23, 2016 01:30
Dogfacts Slack Bot
from flask import *
import random
import json
app = Flask(__name__)
@app.before_request
def before_request():
raw_text = open('facts.txt').read()
g.facts = raw_text.split('\n')
@chrisshroba
chrisshroba / slack-dogfacts.txt
Created May 4, 2016 02:27
Input data to my Slack bot, DogFacts
Dogs are cute
It is a myth that dogs are color blind
Dogs DO have better low-light vision than humans because of a special light-reflecting layer behind their retinas
A German Shepherd guide dog led her blind companion the entire 2100 mile Appalachian Trail
If never spayed or neutered, a female dog, her mate, and their puppies could produce over 66,000 dogs in 6 years!
Dogs’ only sweat glands are between their paw pads
Like human babies, Chihuahuas are born with a soft spot in their skull which closes with age
The breed Lundehune has 6 toes and can close its ears
Teddy Roosevelt’s dog, Pete, ripped a French ambassador’s pants off at the White House
President Lyndon Johnson had two beagles named Him and Her