Skip to content

Instantly share code, notes, and snippets.

View fatso83's full-sized avatar
🐢
Two toddlers. Very little time for OSS after work hours. File a PR!

Carl-Erik Kopseng fatso83

🐢
Two toddlers. Very little time for OSS after work hours. File a PR!
View GitHub Profile
@fatso83
fatso83 / router.js
Created March 5, 2015 15:44
Mini-router - 654 bytes minified+gzipped supporting History API and hasbang urls
/**
* Minimal singleton router - good enoughfor our needs
* 654 bytes using Google Closure Compiler and gzipping
*
* @see http://krasimirtsonev.com/blog/article/A-modern-JavaScript-router-in-100-lines-history-api-pushState-hash-url
*
* @example
* // configuration
* Router.config({ mode: 'history'});
*
@fatso83
fatso83 / gist:88370e1d75de2b9ba00b
Created March 9, 2015 16:08
Gulp config for babelify
var gulp = require('gulp');
var source = require('vinyl-source-stream'); // Used to stream bundle for further handling
var browserify = require('browserify');
var watchify = require('watchify');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var streamify = require('gulp-streamify');
var notify = require('gulp-notify');
var concat = require('gulp-concat');
var cssmin = require('gulp-cssmin');
@fatso83
fatso83 / rescue-time-stats
Last active August 29, 2015 14:17
Helper functions to validate shown Rescue Time stats. Simply sums up the time values and prints the sum in the console
// Helper functions to validate Rescue Time stats
// Copy paste into the console or add to Code Snippets in Chrome => run
// run in the console by running `printStats()`
function findElems() {
return $('.report-table tr td:nth-child(2)');
}
function t(time) {
var tmp, min, sek;
@fatso83
fatso83 / promise-stubbing.js
Created August 25, 2015 11:37
Create a faked Promise to use in testing
/**
* How to create a Promise I can control
* when and if it resolves
* @returns {promise, resolve, reject}
*/
function promiseStub(){
var result = {};
result.p = new Promise(function(res,rej){
result.resolve = res;
result.reject = rej;
@fatso83
fatso83 / redis connection output.txt
Last active September 16, 2015 17:16
Shows how Redis is behaving when disconnecting and connecting
7 'connected'
5007 'getting key'
5881 'ended'
5882 'reconnecting' { delay: 255, attempt: 2 }
6143 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED]
6144 'reconnecting' { delay: 433, attempt: 3 }
6580 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED]
6580 'reconnecting' { delay: 736, attempt: 4 }
7319 'error' [Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED]
7319 'reconnecting' { delay: 1251, attempt: 5 }
@fatso83
fatso83 / millis.c
Last active December 23, 2021 01:08
Print the number of millis since the Epoch (Jan 1 1970)
/**
* Print the number of millis since the Epoch (Jan 1 1970)
* Compile: cc millis.cc -o millis
* Put in your path: mv millis /usr/local/bin
*/
#include <stdio.h>
#include <sys/time.h>
int main(void)
{
struct timeval time_now;
@fatso83
fatso83 / ycm-cygwin.patch
Created December 9, 2015 00:44
Patch to make YCM compile on Cygwin See ycm-core/YouCompleteMe#833
diff --git a/cpp/BoostParts/boost/python/detail/wrap_python.hpp b/cpp/BoostParts/boost/python/detail/wrap_python.hpp
index eaef784..6b367ce 100644
--- a/cpp/BoostParts/boost/python/detail/wrap_python.hpp
+++ b/cpp/BoostParts/boost/python/detail/wrap_python.hpp
@@ -82,7 +82,7 @@
// Some things we need in order to get Python.h to work with compilers other
// than MSVC on Win32
//
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32)
@fatso83
fatso83 / chrome-fresh
Last active October 4, 2016 10:15
Launch a fresh Chrome browser instance each time. Very useful for profiling.
#!/bin/sh
# This is quite useful for front-enders, as it will launch a fresh
# Chrome instance with no loaded plugins or extensions that messes
# with your performance profiling or network debugging
#
# Install:
# install -m 555 ~/Downloads/chrome-fresh /usr/local/bin/
#
# As an Application, just open the OS X script editor and type
# do shell script "~/bin/chrome-fresh"
@fatso83
fatso83 / collaborator.js
Last active January 26, 2023 10:54
Demonstrates how to stub and test for collaborators in a class constructor using sinon and proxyquire. See https://github.com/sinonjs/sinon/issues/831
module.exports = function(n){
// do something with n
}
@fatso83
fatso83 / vector_map.js
Created April 24, 2016 19:01
Browserified vector map giving me headaches when bundled in ASP.NET
(function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
var a = typeof require == "function" && require;
if (!u && a) return a(o, !0);
if (i) return i(o, !0);
var f = new Error("Cannot find module '" + o + "'");
throw f.code = "MODULE_NOT_FOUND", f
}