Skip to content

Instantly share code, notes, and snippets.

  • 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
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))
# 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
<!doctype html>
<html>
<head>
<title>Title of your document</title>
<meta charset="utf-8">
<meta name="description" content="description of your document">
</head>
<body>
@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;
}
}
# log output of a command to a file while still viewing it in the shell
command | tee /dev/tty | >> file.log
// 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",
# 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
<!-- 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>