Skip to content

Instantly share code, notes, and snippets.

View EvanLovely's full-sized avatar

Evan Lovely EvanLovely

View GitHub Profile
@ChrisChares
ChrisChares / AsyncAwaitGenerator.md
Last active September 30, 2022 13:26
async/await with ES6 Generators & Promises

async/await with ES6 Generators & Promises

This vanilla ES6 function async allows code to yield (i.e. await) the asynchronous result of any Promise within. The usage is almost identical to ES7's async/await keywords.

async/await control flow is promising because it allows the programmer to reason linearly about complex asynchronous code. It also has the benefit of unifying traditionally disparate synchronous and asynchronous error handling code into one try/catch block.

This is expository code for the purpose of learning ES6. It is not 100% robust. If you want to use this style of code in the real world you might want to explore a well-tested library like co, task.js or use async/await with Babel. Also take a look at the official async/await draft section on desugaring.

Compatibility

  • node.js - 4.3.2+ (maybe earlier with
@grayside
grayside / Dockerfile-yeoman
Last active February 13, 2017 07:32
Dockerfile for running Phase2 Yeoman generators and capturing the output via a volume mount.
FROM node:4-alpine
ENV YO_P2_VERSION 2.2.0
ENV PATTERN_LAB_STARTER_VERSION 2.0.0
ENV GADGET_VERSION 1.0.0-rc1
ENV P2_ENV_VERSION 1.2.0
RUN node -v
RUN npm -v
RUN echo "Yeoman Doctor will warn about our npm version being outdated. It is expected and OK."
@brandonpittman
brandonpittman / considerToggle.js
Last active August 29, 2015 14:23
JXA script for toggling "Considered" tasks in OmniFocus
of = Library('OmniFocus')
sel = of.selected()
app = Application('OmniFocus')
app.includeStandardAdditions = true
sel.forEach(function(task) {
pattern = /^(Consider) (.+ing) (.+)$/
name = task.name()
if (pattern.test(name)) {
words = name.split(' ').slice(1)
@ziggi
ziggi / parents.js
Last active August 11, 2022 16:10
Vanilla JS jQuery.parents() realisation (npm module: https://github.com/ziggi/dom-parents)
Element.prototype.parents = function(selector) {
var elements = [];
var elem = this;
var ishaveselector = selector !== undefined;
while ((elem = elem.parentElement) !== null) {
if (elem.nodeType !== Node.ELEMENT_NODE) {
continue;
}
@illepic
illepic / SassMeister-input.scss
Created May 30, 2014 00:23
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
@mixin estee-extender($extendable, $mq:false) {
@if $mq {
@extend %#{$extendable}-#{$mq};
} @else {
@extend %#{$extendable};
@denji
denji / README.md
Last active April 26, 2024 18:09 — forked from istepanov/gist:3950977
Remove/Backup – settings & cli for macOS (OS X) – DataGrip, AppCode, CLion, Gogland, IntelliJ, PhpStorm, PyCharm, Rider, RubyMine, WebStorm
@ttscoff
ttscoff / forecast_io.rb
Created February 11, 2014 23:25
Forecast IO
#!/usr/bin/ruby
require 'rubygems'
require 'forecast_io'
ForecastIO.api_key = 'xxxxxxxxxxxxxxxxxx'
forecast = ForecastIO.forecast(44.047889,-91.640439)
if ARGV[0] == "current"
print "#{forecast.currently.temperature.round}, #{forecast.currently.summary}"
else
@aarongustafson
aarongustafson / backup.sh
Created January 22, 2014 19:43
Backup DB & files to Git You want these in a folder that is part of a sparse checkout.
#!/bin/bash
##
# Backup Folders to Git
#
# Creates a local cached backup of the source folder using rsync and then
# synchronises that and the database with Git.
#
# It is assumed you have rsync installed on the server.
#
@igable
igable / watch.rb
Last active December 31, 2015 16:29
The code below is taken entirely from a post by Brett Terpstra located at: http://brettterpstra.com/2011/03/07/watch-for-file-changes-and-refresh-your-browser-automatically/ This version below is modified to work better with Jekyll (see comment below)
#!/usr/bin/env ruby
# watch.rb by Brett Terpstra, 2011 <http://brettterpstra.com>
# with credit to Carlo Zottmann <https://github.com/carlo/haml-sass-file-watcher>
trap("SIGINT") { exit }
if ARGV.length < 2
puts "Usage: #{$0} watch_folder keyword"
puts "Example: #{$0} . mywebproject"
exit
@mparker17
mparker17 / Allowed HTML tags and explanations.md
Last active June 21, 2019 19:12
HTML5 tags that could be used for general content entry on a typical Drupal site — for filter_xss() or filter.module's "Limit allowed HTML tags" filter.

Important notes:

The purpose of this list is to help you evaluate which tags to allow guest contributors to your CMS to use, so...

  • It doesn't list all available elements. Notably, it's missing the tags that deal with text-direction, ruby markings, advanced media tags, form elements, and HTML document structure tags.
  • It's not designed to be super-detailed or technically-correct. There are really detailed, technically-correct groupings of elements available if you want them.

... so, no hatin' please :)

Everyone knows these