Skip to content

Instantly share code, notes, and snippets.

@alecperkins
alecperkins / gist:8994490
Last active August 29, 2015 13:56
Promise example with When.js (https://github.com/cujojs/when)
// It's pretty straightforward to wrap callback-based functions in ones that
// use and return promises.
function readOne (url) {
var deferred = when.defer();
httpRequest(url, function(response){
deferred.resolve(response.length);
});
// This promise represents the end result of the operation, and will
// be resolved when `httpRequest` calls `deferred.resolve` above.
// Once resolved, anything waiting for its result can continue.
@alecperkins
alecperkins / SassMeister-input-HTML.html
Created February 18, 2014 16:25
Generated by SassMeister.com.
<iframe src="http://blog.alecperkins.net/one-toolkit-per-child/"></iframe>
@alecperkins
alecperkins / bookmarklet.js
Last active August 29, 2015 13:57
Bookmarklet for scraps.alecperkins.net that saves the selected text as an entry.
(function(){
var CONTENT_API_ROOT = 'http://marquee.by/content/';
var CONTENT_API_TOKEN = '<token>';
function getSelectionHtml() {
var html = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
@alecperkins
alecperkins / SassMeister-input-HTML.html
Created March 19, 2014 03:16
Generated by SassMeister.com.
<div class="Bar">Bar</div>
<div class="Baz">Baz</div>
<div class="Qux">
Qux
<div class="Qux_Sub">Qux_Sub</div>
</div>
@alecperkins
alecperkins / SassMeister-input-HTML.html
Created March 22, 2014 15:38
Generated by SassMeister.com.
<div class="Stream">
<div class="Stream_Header"></div>
<div class="Stream_Entries">
<div class="CollectionEntry">
<div class="StoryItem -featured"></div>
<div class="StoryItem"></div>
<div class="StoryItem"></div>
<div class="StoryItem"></div>
<div class="StoryItem"></div>
</div>

Keybase proof

I hereby claim:

  • I am alecperkins on github.
  • I am alecperkins (https://keybase.io/alecperkins) on keybase.
  • I have a public key whose fingerprint is 6FE3 06A2 D971 4442 2A3C 18F9 5DF1 1A38 4980 66DE

To claim this, I am signing this object:

@alecperkins
alecperkins / SassMeister-input-HTML.html
Created April 19, 2014 19:08
Generated by SassMeister.com.
<div class="LayoutName__">
<div class="_RegionName__">
<div class="ComponentName" data-state="true">
<div class="_SubComponent"></div>
</div>
<div class="ComponentName -variant_group--large">
<div class="_SubComponent"></div>
</div>
</div>
</div>
@alecperkins
alecperkins / SassMeister-input-HTML.html
Created April 19, 2014 19:08
Generated by SassMeister.com.
<div class="LayoutName__">
<div class="_RegionName__">
<div class="ComponentName" data-state="true">
<div class="_SubComponent"></div>
</div>
<div class="ComponentName -variant_group--large">
<div class="_SubComponent"></div>
</div>
</div>
@alecperkins
alecperkins / names.js
Last active August 29, 2015 14:06 — forked from bnb/names.js
Use Array::shift and Array::push to cycle through the names indefinitely.
var names = [
"&!",
"bnb",
"bang",
"bitnb",
"bitandbang",
"Tierney Coren"
]
while(names.length > 0){
var name = names.shift();
@alecperkins
alecperkins / names.js
Last active August 29, 2015 14:06 — forked from bnb/names.js
Cycle through the names using `Array::shift` and `Array::push`, with recursive `setTimeout` instead of a loop so it's non-blocking.
var names = [
"&!",
"bnb",
"bang",
"bitnb",
"bitandbang",
"Tierney Coren"
]
function typeName() {
// Get the first name in the list and push it to the end.