Skip to content

Instantly share code, notes, and snippets.

@aleclarson
aleclarson / rollup-typescript.md
Last active July 31, 2024 14:24
The best Rollup config for TypeScript libraries

Features

🔥 Blazing fast builds
😇 CommonJS bundle
🌲 .mjs bundle
.d.ts bundle + type-checking
🧐 Source maps

Install

@tduarte
tduarte / publish-ghpages.md
Last active May 18, 2024 13:52
If you need to force push an subtree
git checkout master # you can avoid this line if you are in master...
git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref
@roymckenzie
roymckenzie / KeyboardAvoidable.swift
Last active September 6, 2022 19:42
Easy way to get your view controllers to respect appearance of the keyboard.
// KeyboardAvoidable
// Roy McKenzie
protocol KeyboardAvoidable: class {
func addKeyboardObservers(customBlock: ((CGFloat) -> Void)?)
func removeKeyboardObservers()
var layoutConstraintsToAdjust: [NSLayoutConstraint] { get }
}
var KeyboardShowObserverObjectKey: UInt8 = 1
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@kristopolous
kristopolous / hn_seach.js
Last active July 24, 2023 04:12
hn job query search
// Usage:
// Copy and paste all of this into a debug console window of the "Who is Hiring?" comment thread
// then use as follows:
//
// query(term | [term, term, ...], term | [term, term, ...], ...)
//
// When arguments are in an array then that means an "or" and when they are seperate that means "and"
//
// Term is of the format:
// ((-)text/RegExp) ( '-' means negation )
@rbobbins
rbobbins / protocols.md
Last active June 11, 2024 22:11
Notes from "Protocol-Oriented Programming in Swift"

PS: If you liked this talk or like this concept, let's chat about iOS development at Stitch Fix! #shamelessplug

Protocol-Oriented Programming in Swift

Speaker: David Abrahams. (Tech lead for Swift standard library)

  • "Crusty" is an old-school programmer who doesn't trust IDE's, debuggers, programming fads. He's cynical, grumpy.

  • OOP has been around since the 1970's. It's not actually new.

  • Classes are Awesome

    • Encapsulation
    • Access control
@aldendaniels
aldendaniels / alternative-to-higher-order-components.md
Last active October 6, 2018 09:50
Alternative to Higher-order Components

React now supports the use of ES6 classes as an alternative to React.createClass().

React's concept of Mixins, however, doesn't have a corollary when using ES6 classes. This left the community without an established pattern for code that both handles cross-cutting concerns and requires access to Component Life Cycle Methods.

In this gist, @sebmarkbage proposed an alternative pattern to React mixins: decorate components with a wrapping "higher order" component that handles whatever lifecycle methods it needs to and then invokes the wrapped component in its render() method, passing through props.

While a viable solution, this has a few drawbacks:

  1. There's no way for the child component to override functionality defined on the higher order component.
@benmccormick
benmccormick / marionette2to3.md
Last active November 17, 2018 10:01
Marionette v2 and v3 Concepts

Marionette 3 is currently in development, but one of its main thrusts is going to be simplifying the concepts needed for Marionette Developers. This involves deprecating and renaming some features. This gist is meant to provide a mapping of V2 to V3 concepts to help developers plan for and understand v3.

Disclaimers:

  • this is not an official document
  • I'm not on the Mn core team, this is just the understanding of an observer of the library
  • Mn V3 is still in development. I'll try to keep this document up to date, but if something looks wrong please leave a comment and double check.

Concepts table

@jgornick
jgornick / 00-marionette-dashboard.md
Last active August 29, 2015 14:15
Marionette: Dashboard Framework
@sebmarkbage
sebmarkbage / Enhance.js
Last active July 31, 2024 18:33
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() {