Skip to content

Instantly share code, notes, and snippets.

View juhamust's full-sized avatar
⌨️
hackhack.

Juha Mustonen juhamust

⌨️
hackhack.
View GitHub Profile
@balupton
balupton / README.md
Last active December 11, 2015 06:08
DocPad: Protecting documents with basic http authentication
@nikcorg
nikcorg / bower.json
Last active January 3, 2016 02:39
Localised Moment.js
{
"name": "moment-demo",
"version": "0.0.0",
"authors": [
"Niklas Lindgren <niklas@sc5.io>"
],
"description": "localisation inclusion demo",
"dependencies": {
"moment": "~2.5.0",
"requirejs": "~2.1.10"
@kkung
kkung / app.py
Created May 27, 2011 09:34
Flask, session store in memcached
from flask import Flask, request, session, url_for, redirect, \
render_template, abort, g, flash
from werkzeug.contrib.sessions import Session, SessionStore
from cPickle import HIGHEST_PROTOCOL
from random import random
from flask import json
class MemcachedSessionStore(SessionStore):
def __init__(self, servers=None, key_prefix=None, default_timeout=300):
@colbywhite
colbywhite / _sls.sh
Created September 25, 2016 23:18
zsh completion for serverless v1.0
_sls_templates() {
_values \
'VALID TEMPLATES' \
'aws-nodejs' \
'aws-python' \
'aws-java-maven' \
'aws-java-gradle'
}
_sls_regions() {
@aMarCruz
aMarCruz / starts_ends_with.js
Last active December 26, 2018 02:01
String startsWith & endsWith polyfills
;(function (sp) {
if (!sp.startsWith)
sp.startsWith = function (str) {
return !!(str && this) && !this.lastIndexOf(str, 0)
}
if (!sp.endsWith)
sp.endsWith = function (str) {
var offset = str && this ? this.length - str.length : -1

What to use

  • Test runner: ava
  • React components testing: enzyme
  • Endpoint testing: express + supertest
  • Mocking framework: sinon
  • External dependencies mocking: proxyquire

Test cases

all the following examples are using ava syntax, but they may be easily adapted to mocha or tape as well

@mauvm
mauvm / Jasmine-and-Babel6.md
Created November 12, 2015 10:51
Jasmine ES6 run script for use with Babel 6
$ npm install --save babel-cli babel-preset-es2015
$ npm install --save-dev jasmine

.babelrc:

{
 "presets": ["es2015"]
@traviskaufman
traviskaufman / jasmine-this-vars.md
Last active September 19, 2022 14:35
Better Jasmine Tests With `this`

Better Jasmine Tests With this

On the Refinery29 Mobile Web Team, codenamed "Bicycle", all of our unit tests are written using Jasmine, an awesome BDD library written by Pivotal Labs. We recently switched how we set up data for tests from declaring and assigning to closures, to assigning properties to each test case's this object, and we've seen some awesome benefits from doing such.

The old way

Up until recently, a typical unit test for us looked something like this:

describe('views.Card', function() {
// https://forums.oculusvr.com/community/discussion/57052/quill-fbx-to-unity3d#latest
Shader "Unlit/Quill Shader" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
@emiloberg
emiloberg / GaugeChart.js
Last active February 13, 2024 14:30
Gauge Chart with React Recharts (http://recharts.org)
import React from 'react';
import { Sector, Cell, PieChart, Pie } from 'recharts';
const GaugeChart = () => {
const width = 500;
const chartValue = 180;
const colorData = [{
value: 40, // Meaning span is 0 to 40
color: '#663399'
}, {