I no longer mantain this list. There are lots of other very comprehensive JavaScript link lists out there. Please see those, instead (Google "awesome JavaScript" for a start).
type Cast<T, U> = T extends U ? T : U; | |
type Prop<T, K> = K extends keyof T ? T[K] : never; | |
type HexChars = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f"; | |
type HexPairs = `${HexChars}${HexChars}`; | |
/** | |
* returns a Tuple of hex pairs (bytes), or `never` if the input doesn't contain an even number of hex characters | |
*/ | |
type Hex<S extends string> = | |
S extends "" ? [] : |
// 'Hello, World!" with only lodash | |
// Either `var _ = require('lodash')`, OR | |
// Go to https://lodash.com/docs/4.17.15, open the dev console, copy, paste and execute the below code | |
_.each( | |
_.uniqBy(_.flatMap( | |
_.merge(_.groupBy(_.keys(_), _.head), _.groupBy(_.keys(_), _.last)), | |
_.rearg(_.over(_.identity, _.toUpper), _.toInteger(_.stubTrue())) | |
)), |
@FunctionalInterface | |
public interface Judiciously<T> { | |
class WrappedException extends RuntimeException { | |
public WrappedException(Throwable cause) { | |
super(cause); | |
} | |
} | |
static <T> T attempt(Judiciously<T> f) { |
public interface Nonchalantly<T> { | |
static <T, E extends Throwable> T invoke(Nonchalantly<T> f) throws E { | |
try { | |
return f.run(); | |
} catch (Throwable e) { | |
throw (E) e; | |
} | |
} | |
T run() throws Throwable; | |
In all the discussions about ES6 one thing is bugging me. I'm picking one random comment here from this io.js issue but it's something that comes up over and over again:
There's sentiment from one group that Node should have full support for Promises. While at the same time another group wants generator syntax support (e.g.
var f = yield fs.stat(...)
).
People keep putting generators, callbacks, co, thunks, control flow libraries, and promises into one bucket. If you read that list and you think "well, they are all kind of doing the same thing", then this is to you.
# OSX for Hackers (Mavericks/Yosemite) | |
# | |
# Source: https://gist.github.com/brandonb927/3195465 | |
#!/bin/sh | |
# Some things taken from here | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# Ask for the administrator password upfront |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#include "H264_Decoder.h" | |
H264_Decoder::H264_Decoder(h264_decoder_callback frameCallback, void* user) | |
:codec(NULL) | |
,codec_context(NULL) | |
,parser(NULL) | |
,fp(NULL) | |
,frame(0) | |
,cb_frame(frameCallback) | |
,cb_user(user) |
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
-
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the
secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection. -
Use production SSL certificates locally. This is annoying