Skip to content

Instantly share code, notes, and snippets.

View smokinjoe's full-sized avatar

Joe smokinjoe

View GitHub Profile
@francisrstokes
francisrstokes / StateDispatcher.js
Last active May 28, 2019 02:31
Redux without redux - sharing state and one way data flow using only standard react
import React from 'react';
export class StateDispatcher extends React.Component {
constructor(props) {
super(props);
this.state = props.state || {};
this._dispatch = this.dispatch.bind(this);
}
dispatch(action) {
@sebmarkbage
sebmarkbage / The Rules.md
Last active June 30, 2024 01:30
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@jim-at-jibba
jim-at-jibba / meteor-auth.js
Last active June 28, 2017 16:37
Example of authenticated routes with restivus and jsonroutes in meteor
import { Restivus } from 'meteor/nimble:restivus';
import { JsonRoutes } from 'meteor/simple:json-routes';
import { Meteor } from 'meteor/meteor';
import YourCollection from '../your-collection';
JsonRoutes.Middleware.use(
'/api/yourCollection',
JsonRoutes.Middleware.parseBearerToken
);
anonymous
anonymous / config.json
Created August 17, 2016 02:44
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@gaearon
gaearon / connect.js
Last active June 24, 2024 09:43
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@smokinjoe
smokinjoe / gist:aecc398e53500cbb7907
Last active March 8, 2016 06:47
Debugging Hubot
# From https://github.com/github/hubot/issues/648#issuecomment-78796436
The book Automation and Monitoring with Hubot has a section on debugging.
I've just tested that myself, and it seems to work well. Basically, the steps are:
npm install -g node-inspector
node-inspector --no-preload --web-port 8123
Then, we can insert debugger in our code somewhere to setup a breakpoint. Then we run Hubot:
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 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() {
@kentcdodds
kentcdodds / get-watchers.js
Last active December 4, 2023 22:34
Get Watchers of element and its children
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
@justinmc
justinmc / anchor_smooth_scroll.js
Last active May 14, 2019 19:52
Anchor Smooth Scroll - Angular Directive
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
angular.module('yourapp').directive('anchorSmoothScroll', function($location) {
'use strict';
return {
restrict: 'A',
replace: false,
@maxired
maxired / RadialBlurInGimp.md
Last active December 23, 2021 06:45
How to do a radial blur in Gimp

#How to do a radial blur in Gimp

Gimp as some function to do blur effects, but it is not clear how to do a radial blur : Blur part of an image, starting from a point, with a radius, and the effect beeing less and less strong the farer we are from the central point.

Here is a sample Radial Blur Sample.

Here is the solution :

  • start with an unblur image.
  • copy the layer
  • on the top layer apply a gaussian blur : "filter -> blur -> gaussian blur". Change parameters so that the image is blurry as you want. This settings would be the blurriest of your final image.