Skip to content

Instantly share code, notes, and snippets.

@lotsofcode
lotsofcode / gulpfile.js
Created June 1, 2015 13:44
Gulp browserify coffeescript
var gulp = require('gulp');
var util = require('gulp-util');
var concat = require('gulp-concat');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var header = require('gulp-header');
var rimraf = require('gulp-rimraf');
var pkg = require('./package.json');
var coffeeify = require('coffeeify');
var sourcemaps = require('gulp-sourcemaps');
@lotsofcode
lotsofcode / removeEmpty
Created May 13, 2015 14:01
remove empty elements from array
// pre 1.6
function cleanArray(actual){
var newArray = new Array();
for(var i = 0; i<actual.length; i++){
if (actual[i]){
newArray.push(actual[i]);
}
}
return newArray;
}
{% set currentPath = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
@lotsofcode
lotsofcode / s3.sh
Last active August 29, 2015 14:20 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@lotsofcode
lotsofcode / extend-new.js
Last active August 29, 2015 14:20
js extend
// ie9+
function extend (target, source) {
var a = Object.create(target);
Object.keys(source).map(function (prop) {
prop in a && (a[prop] = source[prop]);
});
return a;
};
var Injector = {
dependencies: {},
add : function(qualifier, obj){
this.dependencies[qualifier] = obj;
},
get : function(func){
var obj = new func;
var dependencies = this.resolveDependencies(func);
func.apply(obj, dependencies);
return obj;
#!/bin/bash
port_param=$1
port=${port_param:-5555}
function processId {
/bin/ps aux | grep "SimpleHTTPServer $port" | grep -v grep | awk '{print $2}'
}
# kill previous processes
// Find all YouTube videos
var $allVideos = $("iframe[src^='http://www.youtube.com']"),
// The element that is fluid width
$fluidEl = $("body");
// Figure out and save aspect ratio for each video
$allVideos.each(function() {
$(this)
@lotsofcode
lotsofcode / gist:eb8408859a43536f0882
Created February 26, 2015 12:29
simple gulp sass
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('watch', ['sass'], function() {
gulp.watch(['scss/*.scss'], ['sass']);
});
gulp.task('sass', function() {
gulp.src('scss/*.scss')
.pipe(sass())
@lotsofcode
lotsofcode / gist:3d58bd7da8f5627c0978
Created January 13, 2015 14:35
name-that-color.js
/*
+-----------------------------------------------------------------+
| Created by Chirag Mehta - http://chir.ag/projects/ntc |
|-----------------------------------------------------------------|
| ntc js (Name that Color JavaScript) |
+-----------------------------------------------------------------+
All the functions, code, lists etc. have been written specifically
for the Name that Color JavaScript by Chirag Mehta unless otherwise