Skip to content

Instantly share code, notes, and snippets.

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

@developit
developit / Rollup Automatic External Dependencies.md
Last active June 29, 2021 15:33
Rollup Automatic External Dependencies

Hi!

This is an example of how to use [Rollup] with external dependencies, without hard-coding them.

It reads your installed NPM dependencies and treats them as external to Rollup. They still get bundled, but not as ES2015.

Make sure you have a .babelrc or a "babel":{} section in your package.json.

@eliotsykes
eliotsykes / current-route-query-params-ember-component.js
Last active November 13, 2019 13:06
How to get the current route, queryParams, etc. in an Ember component
// Examples
// Yes, "router.router" twice - this assumes that the router is being injected
// into the component. Otherwise lookup 'router:main'
// One of these will be of interest, figure out which one you want:
this.get('router.router.state');
this.get('router.router.state.params');
this.get('container').lookup('controller:application').currentPath;
@wthit56
wthit56 / .md
Last active August 29, 2015 14:17
Using Your Own Non-Templating Engine

Please read Writing Your Own Non-Templating Engine before reading this article.

Using Your Own Non-Templating Engine

In the previous article (link at the top), I showed how you can write a very simple function that will turn a given template string into something JavaScript can use. In this article, I'll go into how you can use this in practise.

The Basics

First, let's just make sure we're on the same page as to what the code is and what it does. And while we're at it, let's wrap it up in a function we can reference in later code examples:

@othiym23
othiym23 / npm-upgrade-bleeding.sh
Created September 20, 2014 19:36
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
<?php
/**
* wdw_crop_img (http://webdeveloperswall.com/wordpress/crop-image-script)
* crops the image to given width and height
* Parameters :-
* $image_url : string : absolute url to the image
* $width: int : desired width after cropping
* $height : desired height after cropping
* $upload_directory : name of the target directory (directoty inside wp-content>uploads folder)
* Returns :- an array containing errors/success messages, new(cropped) file path and cropped file url
@yratof
yratof / base.scss
Last active June 6, 2019 07:15
Contact Form 7 - Removing the unwanted stuff, Making it look pretty, then reading the needed stuff
/*********************
Contact Form 7 Styles -
If you want to leave these colours as they are, then do so,
otherwise, wap grey and green for your brand colours in your MIXINS file
*********************/
$dark: rgb(50,50,50);
$green: rgb(0,200,100);
div.wpcf7 {
margin: 0;
@jboner
jboner / latency.txt
Last active May 10, 2024 14:27
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"