Skip to content

Instantly share code, notes, and snippets.

// Usage
<Router>
<Provider store={store}>
<ListeningRouter>
<Main />
</ListeningRouter>
</Provider>
</Router>
@graste
graste / strace.md
Last active November 14, 2023 12:09
strace process for network and memory and other syscalls

File activity

strace -e trace=file -fp PID (file) or strace -e trace=desc -fp PID (file descriptors)

Common calls:

  • access
  • close – close file handle
  • fchmod – change file permissions
  • fchown – change file ownership
@gokulkrishh
gokulkrishh / media-query.css
Last active April 23, 2024 08:01
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@DmitrySoshnikov
DmitrySoshnikov / es2015-callable.js
Last active August 29, 2015 14:26
es2015-callable.js
/**
* Callable objects in ES2015.
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License
*/
class Callable extends Function {
constructor() {
super('(' + Callable.prototype.__call__ + ')();');
return this.bind(this);
@michelsalib
michelsalib / deprecated.ts
Created April 23, 2015 13:17
Typescript @deprecated annotation
class Dog {
@deprecated('Dogs don\'t roar, they talk.')
roar() {
console.log('RRRRR');
}
@deprecated()
smile() {
console.log('smile');
}
@minwe
minwe / EventSystem.js
Last active October 22, 2019 03:03 — forked from yitsushi/EventSystem.js
Global event system for React.js
var EventSystem = (function() {
var self = this;
self.queue = {};
return {
publish: function (event, data) {
var queue = self.queue[event];
if (typeof queue === 'undefined') {
@kad3nce
kad3nce / ch3.md
Created April 3, 2015 15:28
# You Don't Know JS: ES6 & Beyond

You Don't Know JS: ES6 & Beyond

Chapter 3: Organization

Some of the most important changes in ES6 involve improved support for the patterns we already commonly use to organize JavaScript functionality. This chapter will explore Iterators, Generators, Modules, and Classes.

Iterators

An iterator is a structured pattern for pulling information from a source in one-at-a-time fashion. This pattern has been around programming for a long time. And to be sure, JS developers have been ad hoc designing and implementing iterators in JS programs since before anyone can remember, so it's not at all a new topic.

What ES6 has done is introduce an implicit standardized interface for iterators. Many of the built in data structures in JavaScript will now expose an iterator implementing this standard. And you can also construct your own iterators adhering to the same standard, for maximal interoperability.

@Couto
Couto / webpack.js
Last active November 11, 2020 17:53
Fetch polyfill with webpack
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var folders = {
APP: path.resolve(__dirname, '../app'),
BUILD: path.resolve(__dirname, '../build'),
BOWER: path.resolve(__dirname, '../bower_components'),
NPM: path.resolve(__dirname, '../node_modules')
};
@ShirtlessKirk
ShirtlessKirk / performance-timing.js
Last active February 12, 2024 00:32
Performance timing polyfill
/**
* performance-timing.js: Polyfill for performance.timing object
* For greatest accuracy, this needs to be run as soon as possible in the page, preferably inline.
* The values returned are necessarily not absolutely accurate, but are close enough for general purposes.
* @author ShirtlessKirk. Copyright (c) 2014.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
(function (window) {
'use strict';
@allenwb
allenwb / 0Option2ConstructorSummary.md
Last active November 4, 2023 14:39
New ES6 constructor features and semantics: Alternative 2 manual super in derived classes

New ES6 Constructor Semantics and Usage Examples

Manual super: Alternative Design where subclass constructors do not automatically call superclass constructors

This Gist presents a new design of class-based object construction in ES6 that does not require use of the two-phase @@create protocol.

One of the characteristics of this proposal is that subclass constructors must explicitly super invoke their superclass's constructor if they wish to use the base class' object allocation and initialization logic.

An alternative version of this design automatically invokes the base constructor in most situations.