Skip to content

Instantly share code, notes, and snippets.

<audio controls autoplay muted volume="0.5">
<source src="audio_file.ogg" type="audio/ogg">
<source src="audio_file.mp3" type="audio/mpeg">
</audio>
@sh78
sh78 / censor.py
Created October 30, 2015 23:46
My submission for the Built-In Python Functions assignment in Udacity's Programming Foundations With Python course.
import string
import sys
import re
# define method that can censor a string
def censor(the_input, blacklist, replacements):
# create a receptacle for the censored output
censored = []
# split input into words, using the regex split method to preverve formatting
words = re.split(r'(\s+)', the_input)
<!-- make elemment really annoying to copy paste -->
<div class="unselectable" unselectable="on" onmousedown="return false;" onclick="return false;" ondragstart="return false;" onselectstart="return false;" style="-moz-user-select: none; cursor: default;">
</div>
# extract html comments from files in current working directory recursively
from bs4 import BeautifulSoup, Comment
import os
# run the following commands to install dependencies (OS X):
# easy_install beautifulsoup4
# easy_install lxml
// map keyboard codes to their actual key value
var keyCodeMap = {
48: "0",
49: "1",
50: "2",
51: "3",
52: "4",
53: "5",
54: "6",
55: "7",
# log output of a command to a file while still viewing it in the shell
command | tee /dev/tty | >> file.log
var detectDevices = {
iOS: function() {
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
},
Safari: function() {
return !!navigator.userAgent.match(/safari/i) && !navigator.userAgent.match(/chrome/i) && typeof document.body.style.webkitFilter !== "undefined" && !window.chrome;
}
}
@sh78
sh78 / prepend creation date.bash
Created March 25, 2017 00:49
rename files prepending creation date to name
#!/bin/bash
# prepend creation date to file names in format `YYY-MM-DD original_file_name`
for file in *; do
thedate=$(date -r $(stat -f %B "$file") +%Y-%m-%d)
echo "renaming \"$file\" to \"$thedate $file\""
mv -v "$file" "$thedate $file"
done
<!doctype html>
<html>
<head>
<title>Title of your document</title>
<meta charset="utf-8">
<meta name="description" content="description of your document">
</head>
<body>
# Format Current Date
date +%Y-%m-%d\ %H:%M:%S
# Reformatting string date
# most distros
date -d'27 JUN 2011' +%Y%m%d
# => 20110627
# os x / BSD
date -jf "%m %d %Y" "07 08 1990" +%Y-%m-%d
# => 1990-07-08