View switchy.js
// What is the console output of this code?
function switchFoo (foo) {
switch (foo) {
case 1:
foo = 5
case 2: {
View twelve_days_of_emoji.markdown




🐢🐦 🐢🐦


View renaming.markdown

How to rename solutions and projects in Visual Studio

  1. Don't.

How to rename solutions and projects that were created in Visual Studio

  1. Close Visual Studio and don't open it again until I tell you. Visual Studio is not competent at renaming things.
  2. Assuming you're using git, clean the working folder to remove anything that's not in version control (this will help the search-and-replace step because it won't have to go through a bunch of generated files)

    git clean -fdx

View dw-sorter.clj
(defn episode-number [file]
(def match (re-matches
#"\d{4}-\d{2}-\d{2} - (S\d\d E\d\d) - .*"
(.getName file)))
(if (= match nil)
(match 1)))
(def episodes (partition-by episode-number files))
View browserify_transforms.markdown

If you're using Browserify and Reactify to write React components and build them for the browser, you may, depending on your setup, see errors along the lines of "unexpected token <", which means that your code is not getting Reactified properly. You will either see this in Gulp, because some subsequent step in the pipeline can't parse your code, or in the browser.

Here's how browserify decides how to apply transforms:

  1. Anything specified when you actually call browserify (i.e. in a gulpfile or on the command line) will be run first. Calls here can specify {global: true}, which will make them be applied to dependencies as well as code in the current module.
  2. If there is a browserify.transform key in package.json, it can list transforms which should be applied, in the order that they should be applied.

You need to specify reactify before anything else which is going to want to parse the code, because obvs. it isn't valid es5 until it's been reactified (so e.g. having `["browserify-shim", "reactify"

View ConEmu Git
  1. Open Conemu
  2. Open Settings -> Tasks or go to new tab button -> Setup tasks.
  3. Click + to add a new task
  4. Enter the name as Git Bash or whatever you like
  5. Task parameters:

    /icon "C:\Program Files (x86)\Git\etc\git.ico" /dir "C:\_git"
  6. Command:

View gulpfile.js
gulp.task("install", function(cb) {
var npm = require("npm");
npmConfig = {};
// sample command line opts, you may have others
if (gUtil.env["npm-cache-path"]) npmConfig.cache = gUtil.env["npm-cache-path"];
if (gUtil.env["npm-log-level"]) npmConfig.loglevel = gUtil.env["npm-log-level"];
npm.load(npmConfig, function (er) {
if (er) return cb(er);
npm.commands.install([], function (er, data) { cb(er); });
View requireTime.js
* requireTime.js
* require()s every thing in your node_modules and tells you how long each one
* took.
* $ cd your_project_folder
* $ node loadTest.js
View bash_here.bat
@echo off
rem If Windows's idea of $HOME is wrong for you, you can use
rem Console2 and instead of using bash directly, use this batch
rem file instead. It will set $HOME to wherever it is located.
set PATH=%PATH%;%~dp0
set HOME=%~dp0
rem adjust path to suit

Deleting a tree of folders using rimraf can be pretty fraught on MS Windows; the OS itself can lock files randomly, and there may be various processes getting in the way, like virus checkers or cloud file syncing apps. rimraf itself will do an exponential-backoff-and-retry for EBUSY and ENOTEMPTY errors on Windows, but you can still see EPERM and others. If you want to do exponential-backoff-and-retry for any error, see the below recipe, using node-retry.