This file contains hidden or 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
| # webapps/michaelehead_redirect/.htaccess | |
| # michaelehead_redirect | |
| # | - http://michaelehead.com | |
| # | - http://www.michaelehead.com | |
| # This simply redirects all traffic to https://www (with or without www) to the app itself at “michaelehead”. | |
| # That app’s redirect rules then take care of the www portion. | |
| Options +FollowSymLinks | |
| RewriteEngine on | |
| RewriteRule ^(.*)$ https://www.michaelehead.com/$1 [R=301,L] |
This file contains hidden or 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
| const fs = require('fs'); | |
| const postcss = require('postcss'); | |
| const postcssJs = require('postcss-js'); | |
| // e.g. body { font-size: 14px } h1 { font-size: 21px; } | |
| const cssFile = fs.readFileSync('./path/to/file.css'); | |
| const css = postcss.parse(cssFile.toString()); | |
| const cssJsObject = postcssJs.objectify(css); | |
| // e.g. module.exports = { body: { fontSize: "14px" }, h1: { fontSize: "21px" }; |
This file contains hidden or 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
| /** | |
| * Run in the console on a MERGED PR page: https://bitbucket.org/<org>/<project>/pull-requests/?state=MERGED | |
| */ | |
| var names = {}; | |
| for(var node of document.querySelectorAll('.pr-number-and-timestamp')){ | |
| var text = node.innerHTML | |
| var info = text.split(' - '); | |
| var name = info[0]; | |
| if(names[name]) { |
This file contains hidden or 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
| # Find things listening on ports on Mac | |
| lsof -n -i4TCP:$PORT | grep LISTEN | |
| # Find a process PID | |
| ps ax | grep ruby | |
| # ...and kill it | |
| kill -9 <PID> | |
| # Alternatively, kill all of them with a name | |
| pkill node |
This file contains hidden or 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/ruby | |
| # shebang (#!) must on the first line of the script in order to run this | |
| # with `./script.rb` rather than `ruby script.rb` | |
| # use `whereis ruby` to find the path | |
| # single line comments | |
| =begin | |
| Multi-line comments. | |
| Begin and End must be on the first |
This file contains hidden or 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
| var item = 'abcdefghijkl'; | |
| var term = 'bfg'; | |
| var termArray = term.split(''); | |
| // start regex with 0 or more character match | |
| var regex = '.*'; | |
| for(var i = 0; i < termArray.length; i++) { | |
| // add character term to regex string | |
| regex += termArray[i]; |
This file contains hidden or 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
| # Aliases | |
| alias editprofile="nano ~/.bash_profile" | |
| alias loadprofile="source ~/.bash_profile" | |
| alias flushdns="sudo discovery udnsflushcaches" | |
| alias pythonserver="python -m SimpleHTTPServer 8000" | |
| alias mochatest="mocha test/setup.js --compilers js:babel-core/register --require ignore-styles " | |
| alias setprod="export NODE_ENV=production" | |
| alias setdev="unset NODE_ENV" | |
| alias checkenv="echo \$NODE_ENV" | |
| alias disableipv6="networksetup -setv6off Wi-Fi" |
This file contains hidden or 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
| /** | |
| * Diff Java resource bundles to find missing keys. | |
| */ | |
| var fs = require('fs'); | |
| var englishFile = 'path/to/ResourceBundleMessage.properties'; | |
| var germanFile = 'path/to/ResourceBundleMessage_de.properties'; | |
| var japaneseFile = 'path/to/ResourceBundleMessage_ja.properties'; | |
| var chineseFile = 'path/to/ResourceBundleMessage_zh_CN.properties'; |
This file contains hidden or 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
| var prices = document.querySelectorAll('[class*="color-price a-text-bold"]'); | |
| prices = Array.prototype.slice.call(prices); | |
| var total = 0; | |
| prices.forEach(function (price) { | |
| total += parseFloat(price.textContent.replace('$', '')); | |
| }); | |
| alert(total); |
This file contains hidden or 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
| <a href="#nogo" class="button--PRIMARY">Primary Button</a> | |
| <br /> | |
| <a href="#nogo" class="button--SECONDARY">Secondary button</a> |