Skip to content

Instantly share code, notes, and snippets.

View soluml's full-sized avatar
⌨️

Benjamin Solum soluml

⌨️
View GitHub Profile
@soluml
soluml / css.js
Created April 4, 2016 23:24
Sample Build for CSS in Node
var fs = require('fs');
var path = require('path');
var glob = require('glob');
var nodesass = require('node-sass');
var postcss = require('postcss');
var autoprefixer = require('autoprefixer')({ browsers: ['last 2 versions', 'ie >= 9'] });
var cssnano = require('cssnano');
var cssmodules = require('postcss-modules')({});
@soluml
soluml / gist:be1ea9642bc3c73ff42f
Created August 5, 2015 14:21
_.get() use case
$.post('/some-api', {data: true}).done(function(data) {
//I don't need to check if settings.someAPI exists in data, _.get does that for me.. if undefined, returns null;
var apiDataValue = _.get(data, 'settings.someAPI', null);
})
//ng-boolean-attr="{'data-menu': 'scope.var', 'data-stretch': 'scope.var'}"
angular.module('MyModule').directive('ngBooleanAttr', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var bat = scope.$eval(attrs.ngBooleanAttr);
function updateAttrVal(att, val) {
if(val) element.attr(att, att);
//Assumes jQuery and Angular
$(window).resize((function() {
var timer;
return function(e) {
if(timer) clearTimeout(timer);
timer = setTimeout(function() { $rootScope.$broadcast('window-resize', e); }, 250);
};
}()));
@soluml
soluml / dialog.reset
Created August 27, 2014 15:23
<dialog> Element Reset
dialog {
background: inherit;
border: 0;
color: inherit;
height: auto;
left: auto;
padding: 0;
position: static;
right: auto;
width: auto;
@soluml
soluml / array_walk.js
Last active August 29, 2015 14:01
A function that allows you to run a function over an array of values.
function array_walk(arr, cb) {
for(var i = arr.length; i > 0; i--) arr[i-1] = cb(arr[i-1]);
return arr;
}
@soluml
soluml / armstrong.js
Created May 6, 2013 15:23
JavaScript version of the Coding Challenge
/*
# Coding challenge : Armstrong Numbers
#
# Write a program using any language or technique that can accept two positive
# integers defining a range (such as 0 and 100 for the range 0 <= x <= 100) and
# will print all Armstrong Numbers in that range.
#
# An Armstrong Number is fully defined at
# http://en.wikipedia.org/wiki/Narcissistic_number
#