Skip to content

Instantly share code, notes, and snippets.

@gampleman
gampleman / readme.md
Last active August 29, 2015 14:07
JS Build tool of my dreams

Features desired

(but not necessarily found elsewhere)

Must Have

  1. Native Sourcemap support: JavaScript and CSS often need these for debugging purposses. Managing this manually tends to be a complete PITA. Also we want a way to globally turn these off, if we need better build time (see next).
  2. Native Watch & Serve: Setting up a dev environment should be straightforward, as the build tool should support mutliple environments, but also the abbility to watch source files and serve them from itself.
  3. Lazy: Shouldn't rebuild stuff if it doesn't need to.
  4. Native concurrency: Detect dependencies and parallelize automatically.
angular.module('ui.router').config(['$provide', function($provide) {
$provide.decorator('$controller', [
'$delegate', '$state',
function($delegate, $state) {
// the `later` and `ident` are private angular variables,
// that break the app if not present
return function(expression, locals, later, ident) {
if ($state.$current) {
locals = _.extend(locals, $state.$current.locals.globals);
}
@gampleman
gampleman / lodash-map-tree.js
Last active August 29, 2015 14:14
Lodash map tree
function Tree(label, branches) {
this.label = label;
this.branches = branches || [];
}
_.mixin({
mapTree: function(tree, fn, thisArg) {
var cb = _.callback(fn, thisArg),
agregate = [];
function recurse(tree) {
#sidebar_ads, #rightCol, #presence
{
display: none !important;
}
.profile_two_columns .right_column {
float: left !important;
margin-left: 30px;
}
.fbx #globalContainer {
.tooltip {
font: 14px Helevetica, sans-serif;
line-height: 18px;
position: relative;
border: 2px solid #73a7f0;
max-width: 200px;
margin-left: 20px;
padding: 5px 14px;
border-radius: 4px;
-webkit-border-radius: 4px;

hello

world

Testing out Gist publishin'

Yeah, this is so cool, its ridiculous.

@gampleman
gampleman / expiring_message.rb
Created February 7, 2012 12:25
Auto expiring message on command line
def expiring_message(msg, time)
message = Thread.new {
time.downto(0) do |t|
# You can use some code to get terminal width here instead of the 15 spaces I use
# however that usually isn't terribly portable.
printf "#{msg}#{' ' * 15}\r", t
sleep 1
end
puts
}
# Entity
# ======
# Entity is the base class of the Scene-Graph renderer and represents
# a single object.
class Entity
# When `perform_caching` is set to `yes` the renderer will cache the
# result as an image, unless `is_cached` is set to `no`.
perform_caching: no
is_cached: false
# `parent` is a reference to the entity this class is a child to.
@gampleman
gampleman / example.js
Created October 20, 2015 12:22
Making a custom repeater directive in Angular.js
app.directive('readableList', function(Repeater) {
return {
restrict: 'E',
transclude: true,
compile: Repeater.compile('repeat', function($scope, $element, $attr, ctrl, $repeat) {
$repeat.$watch(function(inputList) {
$element.empty();
if (inputList.length == 1) {
$repeat.$transclude(1, inputList[0], null, 0, function(clone) {