This file contains 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
# Add the following to your ~/.bashrc file. | |
# | |
# I was inspired to do this because, after learning R and getting | |
# used to doing e.g. "?install.packages" when I wanted a reminder | |
# of the parameters list for a function, I kept accidentally trying | |
# to use the question mark to pull up help in Bash as well, e.g. | |
# "?grep" instead of "man grep" | |
# R-style help lookup, by doing "?CMD" for "man CMD" | |
# or "??CMD" for "man -K CMD" |
This file contains 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
minVal <- 0 | |
maxVal <- 100 | |
medVal <- 70 | |
numRows <- 1000000 | |
adjMax <- maxVal - minVal | |
adjMed <- medVal - minVal | |
# Generate a vector that sets how likel | |
# each value is to be chosen. |
This file contains 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
#!/bin/bash | |
# My customized pager script. Everything below this comment block is identical to | |
# the R pager script installed by the R debian package at /usr/lib/R/bin/pager, | |
# except that I've replaced ${PAGER} with /bin/less explicitly, and added | |
# the -I and -X flags. | |
# | |
# The "-I" flag makes searches in the pager case-insensitive by default. | |
# The "-X" flag tells the pager not to clear the screen when it closes. That | |
# allows me to continue to see the help content at the same time as having | |
# the prompt available; which is helpful because I have the memory of a |
This file contains 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
<?php | |
function require_auth() { | |
$AUTH_USER = 'admin'; | |
$AUTH_PASS = 'admin'; | |
header('Cache-Control: no-cache, must-revalidate, max-age=0'); | |
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW'])); | |
$is_not_authenticated = ( | |
!$has_supplied_credentials || | |
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER || | |
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS |
This file contains 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
#!/bin/bash | |
# A utility to list all the tasks in the current directory's makefile. | |
# | |
# Idea taken from https://stackoverflow.com/a/24453375/468642 | |
source /usr/share/bash-completion/completions/make | |
export _make_target_extract_script | |
sed -nrf <(_make_target_extract_script --) ./Makefile |
This file contains 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
#!/bin/bash | |
#### | |
# A script to run updates or check for updates, in many different package management systems | |
# on Ubuntu. | |
# | |
# When I was installing everything I use through apt alone, it was easy to keep all my | |
# packages up to date with "apt-get update && apt-get upgrade", or the GUI update manager. | |
# But now every programming language has its own separate package management system, and | |
# I often use these to install packages at a "global" level on my computer. It's a pain |
This file contains 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
/** | |
* Sometimes you want to programmatically force a Jest test failure. For example, mocking "console.warn()" to | |
* make tests fail if they print warning messages to the console. Throwing an error isn't sufficient, because | |
* the calling code may be in a try/catch block. | |
* | |
* Jest has no "fail()" method** to automatically trigger a test failure, but you can do it with an "expect()" matcher | |
* that will always fail, such as "expect(true).toBe(false)". This will fail the test, but the output isn't very | |
* self-explanatory. You can improve on it by providing a message string as one of the arguments: | |
* "expect(null).toBe('Automatic Failure!')". This is better, but the output is still a little confusing, saying | |
* it expected "null" and received "Automatic Failure!" |
This file contains 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
// Fail the test if it prints ANYTHING to the console! | |
// | |
// Warning & log messages in test output are an anti-pattern. Also, testing | |
// for console messages is the only way to check for PropTypes failures | |
// (because all PropTypes does is print a console warning) | |
const realConsole = global.console; | |
// TODO: It's possible that some of the functions under global.console may | |
// have legitimate uses during test runs. If so, we'll need to be more picky. | |
global.console = Object.keys(realConsole).reduce( |
This file contains 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
/** | |
* This file is the "Launch" script for running Create React App code at the command | |
* line. It calls "@babel/register", which is a Babel utility that hijacks | |
* the normal node "require()" function and lets Babel pre-compile imported | |
* files into Node-compatible JS before they're executed. | |
* | |
* This bootstraps up the fancy CRA TypeScript/React configuration (using the | |
* Babel config imported from "babel-preset-react-app"). Then it simply "require()"s | |
* some other JS/TS/JSX/TSX file, and executes it. | |
* |
This file contains 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 path = require('path'); | |
const nodeExternals = require('webpack-node-externals'); | |
const NodemonPlugin = require('nodemon-webpack-plugin'); | |
// Directory the compiled SSR server and assets will go in | |
const SSR_BUILD_PATH = './ssr-build' | |
const originalNodeEnv = process.env.NODE_ENV; | |
// This must be "production" for the CRA webpack config to be correct. |
OlderNewer