Skip to content

Instantly share code, notes, and snippets.

View johanalkstal's full-sized avatar

Johan Alkstål johanalkstal

View GitHub Profile
@cowboy
cowboy / HEY-YOU.md
Last active July 1, 2024 08:37
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
[AttributeUsage(System.AttributeTargets.All, AllowMultiple = true, Inherited = true)]
public class ಠ_ಠAttribute : Attribute
{
public ILog Log { get; set; }
public ಠ_ಠAttribute()
{
Log.Info("This code is bad and you should feel bad");
}
}
@jamesgpearce
jamesgpearce / dimoc.md
Last active September 22, 2017 23:34
DIMOC: Do It Myself or Callback - a simple pattern for React components

TLDR: a React component should either manage its own state, or expose a callback so that its parent can. But never both.

Sometimes our first impulse is for a component to entirely manage its own state. Consider this simple theater seating picker that has a letter for a row, and a number for a seat. Clicking the buttons to increment each value is hardly the height of user-interface design, but never mind - that's how it works:

/* @flow */
var React = require('react');

var Letter: React.ReactClass = React.createClass({
  getInitialState: function(): any {
@xt0rted
xt0rted / 2017.vsconfig
Last active October 19, 2022 18:12
Boxstarter script for setting up my dev environment
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.Static.Analysis.Tools",
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
"Microsoft.VisualStudio.Component.PortableLibrary",
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages