Skip to content

Instantly share code, notes, and snippets.

View darrylhebbes's full-sized avatar

Darryl Hebbes darrylhebbes

  • Berlin, Germany
View GitHub Profile
@DanDiplo
DanDiplo / JS-LINQ.js
Last active May 8, 2025 17:25
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
@chantastic
chantastic / on-jsx.markdown
Last active May 13, 2025 12:04
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@lukechinworth
lukechinworth / jquery-deferreds-promises.md
Last active February 13, 2018 13:22
jQuery Deferreds and Promises

Two ideas: Deferreds and Promises.

Part 1: Deferred

A Deferred object is initially pending. It can be either resolved or rejected. You can do so by literally calling .resolve or .reject on the Deferred object. You can check its state (pending, resolved, or rejected) by calling .state on it. Once it leaves pending (to be either resolved or rejected) it is permanently that state and cannot be undone (unless of course with a page refresh).

These states are nice because you can put code in functions that will only run when the Deferred object has been set to one of these states. This is done with the .done and .fail methods on the Deferred object. Two examples: the first to explain states, and the second to explain running code based on states.

Example 1:

# Type(<scope>): <subject>
# <body>
# <footer>
# Type should be one of the following:
# * feat (new feature)
# * fix (bug fix)
# * docs (changes to documentation)
@sebmarkbage
sebmarkbage / Enhance.js
Last active February 10, 2025 06:23
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@frozeman
frozeman / tapi18n-default-lanuage.js
Last active March 21, 2017 23:07
TAPi18n set default language
// SET default language
if(Cookie.get('TAPi18next')) {
TAPi18n.setLanguage(Cookie.get('TAPi18next'));
} else {
var userLang = navigator.language || navigator.userLanguage,
availLang = TAPi18n.getLanguages();
// set default language
if (_.isObject(availLang) && availLang[userLang]) {
TAPi18n.setLanguage(userLang);
@rjmoggach
rjmoggach / webfaction_meteor.py
Last active August 18, 2017 12:41
Webfaction MongoDB/Meteor Install
#!/usr/local/bin/python2.7
import xmlrpclib
import os
import socket
import wget
import getpass
from subprocess import call
# Set some defaults
@alexhawkins
alexhawkins / nativeJavaScript.js
Last active November 1, 2024 12:00
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@torgeir
torgeir / playing-with-js-combinators.js
Last active May 18, 2017 07:51
Playing with js combinators.
var log = console.log.bind(console);
var arr = [1, 2, undefined, 3];
var unary = (v) => v;
var binary = (first, rest) => [first, rest];
log('unary', unary.apply(null, arr)); // 1
log('binary', binary.apply(null, arr)); // [1, 2]
@staltz
staltz / introrx.md
Last active May 15, 2025 10:37
The introduction to Reactive Programming you've been missing