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 / GenericsDemo.java
Last active August 29, 2015 13:57
Example of using parametrised multiple bounds in Java 7.This is just showing how stuff is connected - it really does not make any sense in itself.Compiles with JDK7.
/*
Example of using parametrised multiple bounds in Java 7.
This is just showing how stuff is connected - it really does not make any sense in itself.
Compiles with JDK7.
*/
import java.util.ArrayList;
import java.util.List;
// parametrised interfaces
interface IF1<T>{T returnIt();}
@fatso83
fatso83 / Errors with color coding
Created May 19, 2014 23:52
Errors when running mocha tests of npm-kit
 4 failing
 1) Kit should parse imports:
 Error: Line 1 in imports.kit: You're attempting to import a file that does not exist in the specified location: someFile.kit" -->
at Kit._findFile (C:\tmp\node-kit\lib\node-kit.js:365:11)
at Kit._handleImport (C:\tmp\node-kit\lib\node-kit.js:316:21)
at Kit._compileToken (C:\tmp\node-kit\lib\node-kit.js:285:35)
at Kit.compile (C:\tmp\node-kit\lib\node-kit.js:110:14)
at Kit.toString (C:\tmp\node-kit\lib\node-kit.js:122:28)
at kit (C:\tmp\node-kit\lib\node-kit.js:21:25)
@fatso83
fatso83 / Gruntfile.js
Created June 26, 2014 21:44
Grunt file that shows how dynamic config (and option!) values are not used in the grunt-contrib-concat task, but picked up by other tasks
// Grunt file that shows how dynamic config (and option!) values
// are not used in the grunt-contrib-concat task. Run using 'grunt'
module.exports = function(grunt){
grunt.initConfig({
concat : {
foo : {
src: '<%= grunt.config.get("myfiles") %>',
dest : 'outfile.txt'
@fatso83
fatso83 / pre-commit
Created June 27, 2014 13:32
pre-commit hook for the framework: sanity checking and testing
#!/bin/sh
check() {
cd develop && npm install && grunt sanity-checks
}
if [[ $(git symbolic-ref --short HEAD) == 'internal' ]]; then
echo On internal branch - testing commit
check
fi
@fatso83
fatso83 / post-commit
Created June 27, 2014 13:34
post-commit hook for jira integration
#!/usr/bin/env python
##########################################################################
# Copyright 2009 Broadcom Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@fatso83
fatso83 / log4javascript_uncompressed.js
Last active August 29, 2015 14:03
log4javascript patched to use native formatting in BrowserConsoleAppender
/**
* HACKED VERSION of 1.4.9 - has native console.log formatting of objects
*
*
* Copyright 2014 Tim Down.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@fatso83
fatso83 / space_remover.py
Created October 28, 2014 12:25
Script to remove spaces from all file and folder names under a certain directory root.
# space_remover.py
#
# Script to remove spaces at the end of folder or file names
# This is a problem when creating a folder on a platform other
# than Windows and sharing that folder with a Windows user
# The Windows user will then not be able to work with files
# within that folder.
# The solution is simply to remove the space at the end of
# the folder name, but this is not possible to do through
# the Windows GUI interface. Normal "CMD" also has problems.
@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 / 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;