Skip to content

Instantly share code, notes, and snippets.

@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)
@sh78
sh78 / .htpasswd
Last active December 30, 2015 02:58
AuthName "Secure Area"
AuthType Basic
AuthUserFile /path/to/your/directory/.htpasswd
require valid-user
@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
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;
}
}
<!doctype html>
<html>
<head>
<title>Title of your document</title>
<meta charset="utf-8">
<meta name="description" content="description of your document">
</head>
<body>
set theDate to current date
=> date object
set theDate to current date as string
=> Thursday, December 03, 2015 at 09:57:25
set theDate to current date
set y to rich text -4 thru -1 of ("0000" & (year of theDate))
set m to rich text -2 thru -1 of ("00" & ((month of theDate) as integer))
set t to rich text -2 thru -1 of ("00" & (day of theDate))
  • only relevant files/changes are staged
  • imperative tone is used without past tense
  • type is referenced by the first word: -- feat: a new feature -- fix: a bug fix -- docs: changes to documentation -- style: formatting, missing semi colons, etc; no code change -- refactor: refactoring production code -- test: adding tests, refactoring test; no production code change -- chore: updating build tasks, package manager configs, etc; no production code change
/etc/nginx/nginx.conf
gzip on;
gzip_vary on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_http_version 1.1;
gzip_types text/plain text/html text/css application/javascript text/javascript application/x-javascript text/xml application/xml application/xml+rss;
/* To target IE 6 and 7 */
@media screen\9 {
body { background: red; }
}
/* To target IE 6, 7 and 8 */
@media \0screen\,screen\9 {
body { background: green; }
}
# dump
mysqldump -h mysql.server.org -u MyUser -pMyPass MyDB > MyDump.sql
# restore
mysql -h mysql.server.org -u MyUser -pMyPass MyDB < MyDump.sql