Skip to content

Instantly share code, notes, and snippets.

@alanrubin
alanrubin / gulpfile.js
Last active August 29, 2015 14:16
Jest (gulp-jest) + React + React Router Testing files
/** .... **/
var $ = require("gulp-load-plugins")();
var gulp = require("gulp");
function handleError(task) {
return function(err) {
$.util.log($.util.colors.red(err));
$.notify.onError(task + " failed, check the logs..")(err);
};
@jizhang
jizhang / md5.clj
Created December 18, 2012 07:14
Clojure - Calculate MD5 hash of a given string.
(import 'java.security.MessageDigest
'java.math.BigInteger)
(defn md5 [s]
(let [algorithm (MessageDigest/getInstance "MD5")
size (* 2 (.getDigestLength algorithm))
raw (.digest algorithm (.getBytes s))
sig (.toString (BigInteger. 1 raw) 16)
padding (apply str (repeat (- size (count sig)) "0"))]
(str padding sig)))
@ghostwords
ghostwords / .eslintrc
Last active February 13, 2024 07:35 — forked from cletusw/.eslintrc
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"arrowFunctions": false, // enable arrow functions
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"classes": false, // enable classes
"defaultParams": false, // enable default function parameters
"destructuring": false, // enable destructuring
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@mrmartineau
mrmartineau / stimulus.md
Last active March 21, 2024 17:51
Stimulus cheatsheet
@mik01aj
mik01aj / gulpfile.js
Created February 10, 2015 12:10
A hackish way to re-run tests just for the changed file. (Gulp + Jest)
// ... requires, initialization and stuff ...
function runJest(changedFilePath) {
var nodeModules = path.resolve('./node_modules');
var jestConfig = {
scriptPreprocessor: nodeModules + '/gulp-jest/preprocessor.js',
unmockedModulePathPatterns: [nodeModules + '/react'],
moduleFileExtensions: ['js', 'jsx'],
testFileExtensions: ['js', 'jsx'],
};