Skip to content

Instantly share code, notes, and snippets.

@cmlsharp
cmlsharp / bad.py
Created March 2, 2019 18:12
style50 demo
import os
import sys
from flask import Flask, redirect, render_template, request, url_for
import helpers
from analyzer import Analyzer
app = Flask(__name__)
@app.route( "/" )
def index():
return render_template( "index.html" )
@cmlsharp
cmlsharp / cs50-hardened.c
Last active February 20, 2017 00:51
My (hopefully) improved version of the cs50 library. It checks for overflow, prevents a possible segfault and allows for larger input
/****************************************************************************
* CS50 Library 6
* https://manual.cs50.net/library/
*
* Based on Eric Roberts' genlib.c and simpio.c.
*
* Copyright (c) 2013,
* Glenn Holloway <holloway@eecs.harvard.edu>
* David J. Malan <malan@harvard.edu>
* All rights reserved.
/usr/bin/xterm
@cmlsharp
cmlsharp / snp
Last active August 29, 2015 14:06 — forked from erikw/snp
#!/usr/bin/env bash
# Runs a command wrapped with btrfs pre-post snapshots.
log_path="/var/local/log/snp"
date=$(date "+%Y-%m-%d-%H%M%S")
log_file="${log_path}/snp_${date}.log"
if (( EUID != 0 )); then
echo "This script must be run as root" 1>&2
exit 1
fi
@cmlsharp
cmlsharp / make.sh
Last active February 13, 2018 09:27
In case of reinstall, this script puts all of my dotfiles where they should be, sets up mpd and gives me the option of installing all of my previous packages from the official repos and from the AUR (requires my pkgdump script)
#!/usr/bin/env bash
dir=~/.dotfiles # dotfiles directory
olddir=~/.dotfiles_old # old dotfiles backup directory
files="zshrc vimrc tmux.conf vimperatorrc" # list of files/folders to symlink in homedir
# create dotfiles_old in homedir
echo -n "Creating $olddir for backup of any existing dotfiles in ~ ..."
mkdir -p $olddir
@cmlsharp
cmlsharp / keybase.md
Created July 21, 2014 03:33
My keybase proof

Keybase proof

I hereby claim:

  • I am crossroads1112 on github.
  • I am crossroads1112 (https://keybase.io/crossroads1112) on keybase.
  • I have a public key whose fingerprint is 9C2D 06BC F805 3215 5ECD 7BE4 74A1 B23F 108D 84DC

To claim this, I am signing this object:

@cmlsharp
cmlsharp / !!
Last active November 26, 2019 11:57
Repeat most recent command in fish
# Add this to your ~/.config/fish/config.fish
# Syntax:
# To just rerun your last command, simply type '!!'
# '!! sudo' will prepend sudo to your most recent command
# Running !! with anything other than sudo will append the argument to your most recent command
# To add another command to prepend list remove the # on line 10 and put the command in the quotes. Repeat as needed
function !!;
set prevcmd (history | head -n 1)
if test "$argv"
if test "$argv" = "sudo" #; or "any other command you want to prepend"
@cmlsharp
cmlsharp / rollback
Last active August 29, 2015 14:03
Script that makes it easy to rollback snapshots with snapper
#!/usr/bin/env bash
log_path="/var/local/log/rollback"
date=$(date "+%Y-%m-%d-%H%M%S")
log_file="${log_path}/rollback_${date}.log"
#If log directory doesnt exist, make it
if [ ! -d "$log_path" ]; then
mkdir $log_path
fi