Skip to content

Instantly share code, notes, and snippets.

View wassname's full-sized avatar
🙃

Michael J Clark wassname

🙃
View GitHub Profile
@wassname
wassname / jquery-canvasFlame.js
Last active February 23, 2016 03:53
jQuery plugin to generate flame on a canvas element. Demo: http://codepen.io/wassname/pen/KVOKNe
/**
* @name Flame
* @description jquery plugin to generate flame on a canvas element.
* Based on http://codepen.io/jackrugile/pen/Jbnpv
* @copyright (c) 2015 wassname
* @license: MIT
*/
;(function ( $, window, document, undefined ) {
var pluginName = "flame";
@wassname
wassname / permutations.js
Last active June 28, 2022 22:53
Combinatorics permutatons and product in javascript using lodash.js (like python's itertools)
/**
* Lodash mixins for combinatorics
* by: wassname & visangela
* url: https://gist.github.com/wassname/a882ac3981c8e18d2556/edit
* lodash contrib issue: https://github.com/node4good/lodash-contrib/issues/47
* lic: same as lodash
* Inspired by python itertools: https://docs.python.org/2.7/library/itertools.html
*
* Usage:
* permutations([0,1,2],2) // [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]]
@wassname
wassname / invertByMany.js
Last active March 8, 2016 02:47
invertByMany
// use lodash and es6 to invert a Object by subvalues. This let's you catalouge subvalues by keys
/**
* inverts a object by many values
* e.g. invertByMany({ 'a': [1,2,3], 'b': [1], c:[2]})
* // {"1":["a","b"],"2":["a","c"],"3":["a"]}
**/
var invertByMany=(dataObj)=>
_.transform(dataObj, (result, values, key)=>
_.map(values,subvalue=>
@wassname
wassname / inject_scripts.js
Last active July 25, 2016 02:16
Snippet to inject jquery etc into page
/**
Put links to injectable scripts in the cdns array. Try searching on cdnjs.com
but if you need the latest you can use the github version via https://rawgit.com/.
This start with // so they word on https and http.
They are not minified so comment are visible during development.
**/
var cdns = [
/* polyfill */
@wassname
wassname / natural-webpack.js
Created April 3, 2016 09:16
Importing natural into webpack (the node nlp toolkit)
/*
Importing natural into webpack (the node nlp toolkit)
This is just copy of natural's index.js with some exports commented out.
This way it works in webpack, however I haven't full tested it.
*/
exports.SoundEx = require('natural/lib/natural/phonetics/soundex');
exports.Metaphone = require('natural/lib/natural/phonetics/metaphone');
exports.DoubleMetaphone = require('natural/lib/natural/phonetics/double_metaphone');
@wassname
wassname / Javascript_random_string_one_liner.js
Created April 15, 2016 06:49
Javascript_random_string_one_liner
// using Math.random
Math.random().toString(36).slice(2)
// => "j9ix7gr3xw7iiww8nqkh5b3xr"
@wassname
wassname / .eslintrc.js
Last active September 14, 2023 23:57
eslint.recommended (annotated)
/**
* eslint.recommended (annotated)
* ================
* Annotated defaults based on eslint.recommended
*
* @author: wassname
* @license: MIT
* @website https://gist.github.com/wassname/4693303388396c5f074b10865a969b43
* @date 2017-11-13T23:08
* @eslint-version: 4.11.0
@wassname
wassname / segpy_read_writer.py
Last active April 21, 2016 01:45
Using segypy to read large files by assuming they have a fixed layout
"""
See: https://github.com/sixty-north/segpy/issues/29
This iherits it licence from segpy
This is for segpy commit: 91562fd
"""
import os
import sys
root = os.path.dirname(os.path.dirname(__file__))
segpy_path=os.path.join(root,'segpy')
@wassname
wassname / describe.js
Created July 6, 2016 08:01
describe statistics of data in javascript (like pandas.DataFrame.describe)
import {jStat} from 'jstat'
/**
* describe statistics of data
* like: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.describe.html
* @param {Object} data - e.g. {x:[1,2,3],y:[6,7,8]}
* @return {Object} - e.g. {x:{mean:2,...},y:{...}}
*/
export function describe(data){
var labels = {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.