This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for f in *.webm; do | |
ffmpeg -n -i "${f}" "${f%.webm}.mp4" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Outputs the date in the format "2018-03-19 14:43:13". | |
date +"%Y-%m-%d %H:%M:%S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It doesn't seem to work if you put the prefix in quotes. | |
# The wildcard expansion doesn't pan out. | |
for file in The\ prefix\ *; do | |
mv "$file" "${file#The\ prefix\ }" | |
done | |
# You can do this inside instead if you want to remove | |
# a suffix. | |
mv "$file" "${file%\ the\ suffix}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I assigned this to an alias in .bash_profile. | |
# It gets rid of all your local git branches except for master and prod. | |
# I had to use command grep because I like to have alias grep='grep --color=auto -n -E' | |
# in my bash profile so I always have colors and extended regexes, but I don't want line numbers | |
# for this. (Adding that to the alias probably wasn't a good idea anyway.) | |
git branch | command grep -Ev '(master|prod)$' | xargs git branch -D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
echo $1 | |
sort $1 | uniq -c | grep -v '^ *1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This function stolen from https://emacs.stackexchange.com/a/7150/12219 | |
(defun re-seq (regexp string) | |
"Get a list of all regexp matches in a string" | |
(save-match-data | |
(let ((pos 0) | |
matches) | |
(while (string-match regexp string pos) | |
(push (match-string 0 string) matches) | |
(setq pos (match-end 0))) | |
matches))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -H "Content-Type: application/json" -b auth.txt <your url> -d @/path/to/file/containing/json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tail -n $(grep -n -m 1 "regex to match" "source file" | cut -d : -f1) "source file" > "dest file" | |
# The above throws away the first line that matches the regex. This will keep that line: | |
tail -n $(( $(grep -n -m 1 "regex to match" "source file" | cut -d : -f1) - 1)) "source file" > "dest file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name hideHotNetworkQuestions | |
// @namespace leyson | |
// @description Hides hot network questions on Stack Exchange | |
// @include *.stackexchange.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
document.getElementById("hot-network-questions").style.visibility = "hidden"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* KarpRabin.java | |
A Java implementation of the Karp-Rabin seminumerical string | |
matching algorithm. | |
See CLRS Section 32.2. | |
*/ | |
import java.util.Map; | |
import java.util.HashMap; | |
import java.math.BigInteger; | |
public class KarpRabin { |