Skip to content

Instantly share code, notes, and snippets.

View rozzzly's full-sized avatar
😫
const refactor = code => refactor(code);

Patrick Lienau rozzzly

😫
const refactor = code => refactor(code);
View GitHub Profile
@dherman
dherman / loader-api.md
Last active January 31, 2019 03:02
Complete ES6 Loader API

Notational Conventions

This section describes the conventions used here to describe type signatures.

A [T] is an array-like value (only ever used read-only in this API), i.e., one with an integer length and whose indexed properties from 0 to length - 1 are of type T.

A type T? should be read as T | undefined -- that is, an optional value that may be undefined.

Loaders

My Atom Config

Atom Editor Screenshot

Community Packages
├── Stylus@3.1.0
├── Zen@0.16.4
├── atom-eco@0.2.0
├── atom-material-syntax@0.4.6

Pattern Matching

This is a strawman proposal for adding pattern matching to ECMAScript. Pattern matching is useful for matching a value to some structure in a similar way to destructuring. The primary difference between destructuring and pattern matching are the use cases involved - destructuring is useful for binding pieces out of larger structures whereas pattern matching is useful for mapping a value's structure to data or a set of behaviors. In practice this means that destructuring tends to allow many shapes of data and will do its best to bind something out of it, whereas pattern matching will tend to be more conservative.

Additionally, the power of pattern matching is increased substantially when values are allowed to participate in the pattern matching semantics as a matcher as well as a matchee. This proposal includes the notion of a pattern matching protocol - a symbol method that can be implemented by objects that enables developers to use those values in pattern matching. A common scenario w

# Simple script to send you email when someone unfollows you on twitter.
#
# Replace email on line 24 with the email you want to receive notifications at, and
# twitter handle on line 23 with your own (or whomever you want to track unfollows for).
#
# Set up a crontab to check however often you like. If someone follows and then unfollows you
# very quickly (within the interval), you won't get an email.
#
# Requires that you can send mail from the command line of the environment where
# you're running the script using mailx, e.g. `echo "body" | mailx -s "subject" foo@bar.com
@rwest
rwest / README
Created January 9, 2012 16:42 — forked from symposion/README
Convert OS X Keychain exported entries into logins for 1Password import
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
@domenic
domenic / escape-vm.js
Created August 17, 2015 20:20
Escaping the vm sandbox
"use strict";
const vm = require("vm");
const sandbox = { anObject: {} };
const whatIsThis = vm.runInNewContext(`
const ForeignObject = anObject.constructor;
const ForeignFunction = ForeignObject.constructor;
const process = ForeignFunction("return process")();
const require = process.mainModule.require;
require("fs");
@JoshuaCWebDeveloper
JoshuaCWebDeveloper / BookModel.js
Created February 28, 2020 04:13
Example for combining the redux-toolkit and redux-orm libraries
/*
* The redux-orm model and redux-toolkit slice are defined together in the same
* class.
* An export scheme similiar to Ducks is used, where the model class is
* exported in place of the reducer function.
*/
import { Model, fk, many, attr } from 'redux-orm';
import { createSlice } from '@reduxjs/toolkit';
@lancejpollard
lancejpollard / cursor-position.js
Created September 22, 2012 07:24
Get Cursor Position in Terminal with Node.js
module.exports = function(callback) {
require('child_process').exec('./cursor-position.sh', function(error, stdout, stderr) {
callback(error, JSON.parse(stdout));
});
}
#include <windows.h>
void SetWindowBlur(HWND hWnd)
{
const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll"));
if (hModule)
{
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {