Skip to content

Instantly share code, notes, and snippets.

View briangonzalez's full-sized avatar
🏠
🚚

Brian Gonzalez briangonzalez

🏠
🚚
View GitHub Profile
@briangonzalez
briangonzalez / angular-with-server-side-rendering.md
Last active August 29, 2015 13:56
Using Angular w/ Server side rendering

Hey Tim, so I am going to try my best here. It's Friday, bear with me.

Us engineers here at Dollar Shave Club have come to determine that Angular really, really excels at user interface scripting. It's not as good as others at model operations like create/read/update/destroy. But it's really, really good at UI.

It removes all of the tedious $('.my-button').on('click', function(){}) that one typically does when building a simple jQuery/JS scripted site. Event handlers, global variables that manage state of UI elements, variable passing all quickly turn into spaghetti code. When building these kinds of sites, we were always left wondering Where should we store state?, Where should we store information about this or that?, Which file is that event handler located in?, etc.

In Angular, you get this for free. If you want to script a set of DOM elements on a page, you use a "Controller" or add that logic straight into the markup*. If you want to wrap up arbitary functionality or data, you throw that in

@briangonzalez
briangonzalez / rbenv-systemwide-installer.sh
Last active August 10, 2016 02:11
Install rbenv systemwide
#!/usr/bin/env bash
# Verify Git is installed:
if [ ! $(which git) ]; then
echo "Git is not installed, can't continue."
exit 1
fi
if [ -z "${RBENV_ROOT}" ]; then
RBENV_ROOT="/usr/local/rbenv"
{"tweets": [{
"name": "Classy Sloth",
"img": "https://s3.amazonaws.com/uifaces/faces/twitter/idiot/128.jpg",
"tweet": "I am a sloth, hear me roar. #slothsays"
},
{
"name": "Classy Sloth",
"img": "https://s3.amazonaws.com/uifaces/faces/twitter/idiot/128.jpg",
"tweet": "I am a sloth, hear me roar. #slothsays"
},
@briangonzalez
briangonzalez / FontPrep Clean & Restart.md
Last active December 27, 2015 02:38
FontPrep Clean & Restart

Open Terminal.app on your Mac and issue the following commands.

Step 1

Backup FontPrep files:

mv ~/Library/Application\ Support/FontPrep ~/Library/Application\ Support/FontPrep.old

Step 2

Kill the currently running server:

@briangonzalez
briangonzalez / howto.md
Last active January 5, 2020 18:59
Installing Dropbox on CentOS

Setup Dropbox for system startup

The following instructions will get you setup to run Dropbox at system start. Below, also find instructions on how to install the Dropbox CLI.

# Login as root and go into home dir.
sudo su && cd ~

# Download Dropbox depending on architecture (uname -a) and unpack.
# You will need to repeat this "download and unpack" step for all users
#!/bin/sh
VERSION=0.11.2
PLATFORM=darwin
ARCH=x64
PREFIX="$HOME/node-v$VERSION-$PLATFORM-$ARCH"
mkdir -p "$PREFIX" && \
curl http://nodejs.org/dist/v$VERSION/node-v$VERSION-$PLATFORM-$ARCH.tar.gz \
| tar xzvf - --strip-components=1 -C "$PREFIX"

Combinator Recipes for Working With Objects in JavaScript, Part I

(This post is Part I of [II][Part II]. The recipes in this post are excerpted the book JavaScript Allongé.)

combinators

The word "combinator" has a precise technical meaning in mathematics:

"A combinator is a higher-order function that uses only function application and earlier defined combinators to define a result from its arguments."--[Wikipedia][combinators]

@briangonzalez
briangonzalez / README.md
Created October 21, 2012 04:25
img2boxshadow - a ruby script to convert images to CSS [http://codepen.io/briangonzalez/details/AvrGI#pen-details-tab]

img2boxshadow.rb

a ruby script to convert images to CSS (box-shadows)

Installation

gem install rmagick    # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse
@briangonzalez
briangonzalez / gist:3242283
Created August 2, 2012 23:57
Running Applescript from Cocoa
NSString *someScript = [[NSBundle mainBundle] pathForResource:@"some_script" ofType:@"osascript"];
NSString *contents = [NSString stringWithContentsOfFile:someScript encoding:NSUTF8StringEncoding error:nil];
NSAppleScript *script =[[NSAppleScript alloc] initWithSource:contents];
[script executeAndReturnError:nil];
@briangonzalez
briangonzalez / gist:2493742
Created April 25, 2012 21:41
Javascript tricks
// ensure user wants to navigate away, or unbind it...
window.onbeforeunload = function() { return "You sure?" };
window.onbeforeunload = null;