Skip to content

Instantly share code, notes, and snippets.

@greggb
greggb / gist:4553916
Created January 17, 2013 05:33
symlink Sublime text 2 preferences
OSX:
# move the original to dropbox
mv “~/Library/Application Support/Sublime Text 2″ “~/Dropbox/Sublime Text 2″
# symlink it back to make it work.
ln -s “~/Library/Application Support/Sublime Text 2″ “~/Dropbox/Sublime Text 2″
@greggb
greggb / gist:6065873
Created July 23, 2013 20:29
Noodling on a "see more" method
var el = Y.all(".show-more");
hideChildren: function() {
Y.each(el, function(item, index, array) {
var childEls = item.get('children'),
nodeLimit = item.getData("limit"),
hiddenChildEls;
if (childEls.length > nodeLimit) {
hiddenChildEls = childEls.slice(nodeLimit + 1);
hiddenChildEls.hide();
}
@greggb
greggb / Default (Linux).sublime-keymap
Created July 23, 2013 21:21 — forked from coldnebo/Default (Linux).sublime-keymap
Perforce Plugin for Sublime Text. In ST3 this goes directly in the Packages directory.
[
{ "keys": ["f8"], "command": "p4_edit" }
]
@greggb
greggb / 3-col-flex
Created August 4, 2013 01:07
Three column layout
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="BFC - 3 column layout" />
<meta charset=utf-8 />
<title>BFC - 3 column layout</title>
</head>
<body>
<aside role="complementary">
Left column
@greggb
greggb / styles.css
Last active August 29, 2015 14:23 — forked from pburtchaell/styles.css
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@greggb
greggb / ReduxMicroBoilerplate.js
Last active August 29, 2015 14:26 — forked from gaearon/ReduxMicroBoilerplate.js
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
@greggb
greggb / arrayzing.md
Last active April 8, 2017 22:43 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
@greggb
greggb / Liberal Regex Pattern for All URLs
Last active January 11, 2017 05:53 — forked from gruber/Liberal Regex Pattern for All URLs
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:[email protected]", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))*(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>regex tests</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@greggb
greggb / function_invocation.js
Created June 22, 2017 15:21 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);