Skip to content

Instantly share code, notes, and snippets.

View justincorrigible's full-sized avatar
🐺
Nose to the wind!

Anders Richardsson justincorrigible

🐺
Nose to the wind!
View GitHub Profile
@justincorrigible
justincorrigible / seekndestroy.js
Last active November 28, 2015 19:12
http://www.freecodecamp.com/hallaathrad 's solution for Bonfire: Seek and Destroy
// Bonfire: Seek and Destroy
// Author: @hallaathrad
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy?solution=function%20destroyer(arr)%20%7B%0A%20%20var%20taBort%20%3D%20Array.prototype.slice.call(arguments%2C1)%3B%0A%20%20return%20arr.filter(function(obj)%7Breturn%20(taBort.indexOf(obj)%3C0)%3B%7D)%3B%0A%7D%0A%0Adestroyer(%5B1%2C%202%2C%203%2C%201%2C%202%2C%203%5D%2C%202%2C%203)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
var taBort = Array.prototype.slice.call(arguments,1);
return arr.filter(obj => taBort.indexOf(obj)<0);
}
fire-where-do-i-belong.js
// Bonfire: Where do I belong
// Author: @hallaathrad
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(arr, num) {
// Find my place in this sorted array.
arr.push(num);
return arr.sort(function(x,y){return x<y?-1:x>y?1:0;}).indexOf(num);
@justincorrigible
justincorrigible / fizzbuzz.js
Last active December 5, 2015 19:26
A quick and dirty FizzBuzz attempt... just in case I ever need it.
var fzbz = Array .apply(null, { length: 101 })
.map(Number.call, Number)
.map(obj => obj % 3 === 0 && obj % 5 === 0 ?
'fizzbuzz' : obj % 3 === 0 ?
'fizz' : obj % 5 === 0 ?
'buzz' : obj);
fzbz.shift();
@justincorrigible
justincorrigible / romanconverter.js
Created December 20, 2015 14:44
Bonfire: Roman Numeral Converter
function convert(num) {
var x = '';
[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1].map(
function(obj,i){
while (num>=obj){
x+=['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I'][i];
num-=obj;}});
return x;
}
convert(36);
@justincorrigible
justincorrigible / curry.js
Created February 11, 2017 21:05 — forked from amatiasq/curry.js
Simple way to recursively curry javascript functions http://jsfiddle.net/amatiasq/osrsomq0/
/**
* @param {Function} fn Function to curry.
* @param {Number} lenght The arguments required to invoke the function. Optional. By default is fn.length
* @returns {Function} The currified function.
*/
function curry(fn, length) {
length = length || fn.length;
return function currified() {
var args = [].slice.call(arguments);
module.exports = {
env: {
'browser': true,
'commonjs': true,
'es6': true,
'jest/globals': true,
'jquery': true,
},
extends: [
'airbnb',
module.exports = {
extends: 'stylelint-config-standard',
ignoreAtRules: ['element', '/^define/'],
ignoreFiles: './dist/*'
};
const webpack = require('webpack');
const path = require('path');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const HtmlWebpack = require('html-webpack-plugin');
const HtmlWebpackAssetsPlugin = require('html-webpack-include-assets-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const AssetsPlugin = require('assets-webpack-plugin');
const Visualizer = require('webpack-visualizer-plugin')
const BUILD_DIRECTORY = 'src';
@justincorrigible
justincorrigible / WebpackHelper.cs
Created June 29, 2017 15:51 — forked from scottaddie/WebpackHelper.cs
C# helper method to parse webpack.assets.json
public static JObject GetWebpackAssetsJson(string applicationBasePath)
{
JObject webpackAssetsJson = null;
string packageJsonFilePath = $"{applicationBasePath}\\{"package.json"}";
using (StreamReader packageJsonFile = File.OpenText(packageJsonFilePath))
{
using (JsonTextReader packageJsonReader = new JsonTextReader(packageJsonFile))
{
JObject packageJson = (JObject)JToken.ReadFrom(packageJsonReader);
{
"name": "template",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "SET NODE_ENV=development && webpack-dev-server --progress --color --env=development",
"iis": "SET NODE_ENV=development && rimraf ./dist/* && webpack --progress --watch --color --env=production",
"build": "SET NODE_ENV=production && SET BABEL_ENV=production && rimraf ./dist/* && webpack -p --progress --color --env=production",
"buildDev": "SET NODE_ENV=development && SET BABEL_ENV=development && rimraf ./dist/* && webpack --progress --color --env=development",