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 this JavaScript on the chai API doc page: | |
console.log([].map.call(document.querySelectorAll('div.api_method_wrapper h3'), (x) => x.innerText).join('\n')) | |
*/ | |
assert(expression, message) | |
.fail(actual, expected, [message], [operator]) | |
.isOk(object, [message]) | |
.isNotOk(object, [message]) |
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
alias screenunlock='defaults write com.apple.screensaver askForPassword 0 && defaults write com.apple.screensaver askForPasswordDelay 0' | |
alias screenlock='defaults write com.apple.screensaver askForPassword 1 && defaults write com.apple.screensaver askForPasswordDelay 60' |
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 express = require("express"); | |
const router = express.Router(); | |
router.get('/', function (req, res) { | |
res.send("This is the '/' route in ep_app"); | |
}); | |
module.exports = router; |
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 emitterModule = require('./emitter_module'); | |
emitterModule.on("e1", function () { | |
console.log("emitterModule.e1 handler invoked", arguments); | |
}); | |
emitterModule.func1(); |
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
#Export like this: prefs export iterm | |
#import like this: prefs import iterm | |
prefs() { | |
local OP="${1}" | |
shift | |
case "${OP}" in | |
export|import); | |
;; | |
*) |
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
NCSEND_PORT=6666 | |
ncsend() { | |
local DEST_HOST="${1-smair}" | |
pbpaste | nc "${DEST_HOST}" "${NCSEND_PORT}" | |
} | |
ncreceive() { | |
while true | |
do | |
nc -l "${NCSEND_PORT}" | tee /dev/tty | pbcopy |
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
//Note, works with either Backbone.Model or Backbone.Collection | |
//Returns a function that will fetch the provided model and works with | |
//async's callback API | |
function asyncFetch(model) { | |
return function (callback) { | |
model.fetch({ | |
success: function (model) {callback(null, model);}, | |
error: function (model, response) {callback(response);} | |
}); | |
}; |
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
So the question was: should programming languages use a different syntax (or character) for comments intended to be read by developer vs comments whose purpose is to disable code. For example, in my mind, these two scenarios are semantically entirely different intents: | |
# Add 2 px to account for border | |
width += 2 | |
vs ...... | |
#def someFunc(): | |
# pass |
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
addConvenienceMethods = -> | |
for prop, value of this.attributes | |
((prop) -> | |
#Define a setter/getter function | |
this[prop] = (newValue...) -> | |
if newValue.length | |
this.set prop, newValue[0] | |
return this | |
else | |
return this.get prop |
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 tipper = function (percentage) { | |
return function tip(total) { | |
return total + (total * (percentage / 100)); | |
}; | |
}; | |
var generous = tipper(20); | |
var normal = tipper(18); | |
var stingy = tipper(8); |