Skip to content

Instantly share code, notes, and snippets.

💭
🕉 Coding...

Daniel Dietrich danieldietrich

💭
🕉 Coding...
Block or report user

Report or block danieldietrich

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@willfrew
willfrew / tuples.ts
Created Aug 15, 2018
Fun with tuple types in Typescript 3.0
View tuples.ts
type Head<T extends unknown[]> = T[0];
type FnWithArgs<T extends unknown[]> = (...args: T) => void;
type TailArgs<T> = T extends (x: unknown, ...args: infer T) => unknown ? T : never;
type Tail<T extends unknown[]> = TailArgs<FnWithArgs<T>>;
// Lol
type Decr<T extends number> =
T extends 10 ? 9 :
T extends 9 ? 8 :
View api-cheatsheet-array.md

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array<T[] | T>): T[] 🔒 ES3
View SetNarrowTest.java
import javaslang.collection.*;
import javaslang.*;
public class SetNarrowTest {
static class PersonBase {
public final String name;
public PersonBase(String name) {
this.name = name;
}
@bvaughn
bvaughn / react-lifecycle-cheatsheet.md
Last active Sep 4, 2019
React lifecycle cheatsheet
View react-lifecycle-cheatsheet.md

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
@citrusui
citrusui / dropdown.md
Last active Sep 14, 2019
"Dropdowns" in Markdown
View dropdown.md
How do I dropdown?
This is how you dropdown.

<details>
<summary>How do I dropdown?</summary>
<br>
This is how you dropdown.
@baldwmic
baldwmic / MochaHooksLifecycle
Last active Jun 3, 2018
Mocha Hooks Lifecycle
View MochaHooksLifecycle
describe('Mocha Hooks Lifecycle', () => {
describe('Level 1', () => {
before(() => {
console.log(1, 'before');
});
beforeEach(() => {
console.log(1, 'beforeEach');
});
View sol-test.js
var meta;
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var should = require('chai').should();
contract('HumanStandardTokenFactory', function(accounts) {
var createHumanStandardToken;
View SlangFizzBuzz.java
package fizzbuzz;
import javaslang.collection.Stream;
import javaslang.control.Option;
import static javaslang.control.Option.none;
import static javaslang.control.Option.some;
public class SlangFizzBuzz {
public static void main(String[] args) {
@netzwerg
netzwerg / FizzBuzz.java
Created May 1, 2016
FizzBuzz in Java 8 with Javaslang
View FizzBuzz.java
import javaslang.collection.Stream;
/**
* An implementation of https://dierk.gitbooks.io/fregegoodness/content/src/docs/asciidoc/fizzbuzz.html
* using http://www.javaslang.io
*
* @author Rahel Lüthy
*/
public class FizzBuzz {
@maxim
maxim / gh-dl-release
Last active Sep 17, 2019
Download assets from private Github releases
View gh-dl-release
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
You can’t perform that action at this time.