Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
jehoshua02 / bower_install.md
Created February 4, 2015 18:34
Bower install detects dependency conflicts and allows for resolution.
~/projects/deseretdigital/ksldeals/ksldeals
$ bower install --save deseretdigital-ui/ksl-header#v0.3.3
bower ksl-header#v0.3.3     not-cached git://github.com/deseretdigital-ui/ksl-header.git#v0.3.3
bower ksl-header#v0.3.3        resolve git://github.com/deseretdigital-ui/ksl-header.git#v0.3.3
bower ksl-header#v0.3.3       download https://github.com/deseretdigital-ui/ksl-header/archive/v0.3.3.tar.gz
bower ksl-header#v0.3.3        extract archive.tar.gz
bower ksl-header#v0.3.3       resolved git://github.com/deseretdigital-ui/ksl-header.git#0.3.3
bower ksl-styles#0.0.4          cached git@github.com:deseretdigital-ui/ksl-styles.git#0.0.4
bower ksl-styles#0.0.4        validate 0.0.4 against git@github.com:deseretdigital-ui/ksl-styles.git#0.0.4
@jehoshua02
jehoshua02 / my_thoughts_about_apis.md
Last active August 29, 2015 14:14
My thoughts about APIs.

Requests

It all starts with a request. The request is quite simple: some action on some resource with some parameters. I'd like requests to be easy to make and in a format that is easy to construct.

Endpoints

Endpoints represent resources. Example: /dogs, /cats, /users.

I'm curious if a second endpoint to get a single entity (/dogs/:id) is really needed or if we could just piggy back on the collection endpoint (/dogs?ids=[...]). You get guaranteed consistency since there aren't two endpoints to maintain, plus you can get a whole batch using the ids.

@jehoshua02
jehoshua02 / SassMeister-input.scss
Last active August 29, 2015 14:14
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
.media {
&--ratio-16-9 {
padding-top: percentage(9/16);
}
}
@jehoshua02
jehoshua02 / SassMeister-input.scss
Created January 27, 2015 21:31
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
.media {
&--ratio-16-9 {
padding-top: percentage(9/16);
}
}
@jehoshua02
jehoshua02 / example.md
Last active August 29, 2015 14:12
Example of how to process a tree with a queue (rather than a recursive function). It's just pop, process, collect inside a do-while.

Many times, when processing a tree, the natural tendency is to reach for a recursive function. But recursive functions can be hard to grok and also run into call-stack issues. Try a queue instead.

For example, I wanted to find all clean tasks in my tasks directory. You just have to tell the queue processing function what to do with each item, and how to collect more items into the queue from each item.

var queue = require('./processQueue');
var tasks = require('require-dir')('.', { recurse: true });
var cleanTasks = [];

var process = function (item) {
@jehoshua02
jehoshua02 / _button.scss
Created December 12, 2014 11:36
Sass button mixins. The color and sizing properties separated to make it convenient for defining button modifiers without redefining the whole button.
@mixin button-common() {
border: 0 none;
color: #fff;
display: inline-block;
text-align: center;
cursor: pointer;
vertical-align: baseline;
text-decoration: none;
&:active,
@jehoshua02
jehoshua02 / getResponsiveDimensions.js
Last active August 29, 2015 14:11
Responsive design utility to get all the dimensions of
var getResponsiveDimensions = function ($element, minWindowWidth, maxWindowWidth) {
minWindowWidth = minWindowWidth || 320;
maxWindowWidth = maxWindowWidth || 1280;
var dimensions = {
minWidth: Infinity,
maxWidth: 0,
minHeight: Infinity,
maxHeight: 0,
@jehoshua02
jehoshua02 / note_block.md
Last active August 29, 2015 14:10
Trying to figure out different ways to make a block stand out in a Github markdown page.

Make a Block Stand Out

Vanilla Markdown

NOTE: This is still a v0 project and anything can change. If there is any wiggle room in the version number saved to your bower.json this could cause breakage when installing in a new environment. Either lock in on a version or embrace spontaneous change.

@jehoshua02
jehoshua02 / svg-loader.md
Last active August 29, 2015 14:10
Dreamcode for webpack svg-loader.

The webpack way to load svg?

Every time I use svg images, I want to provide png fallbacks. I was looking into using the file-loader, but I need to do a bit more:

  • Move svg and png fallback files into the destination folder.
  • Bundle a module for the client to check for svg support.
  • Bundle a module for the client that returns the correct url for the image based on svg support.

I hoped there would be an svg-loader but didn't find one in the list. Maybe it's a good idea?