Skip to content

Instantly share code, notes, and snippets.

@astoilkov
astoilkov / readme.md
Last active November 16, 2024 12:52
Async Operations with useReducer Hook

Async Operations with useReducer Hook

9 March, 2019

We were discussing with @erusev what we can do with async operation when using useReducer() in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer(). The problem we are facing and don't know how to solve is async operations.

In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.

Problem

@homerjam
homerjam / mc-section.js
Created January 11, 2017 12:57
Custom MJML component for use in MailChimp templates
import { MJMLElement, helpers } from 'mjml-core'
import cloneDeep from 'lodash/cloneDeep'
import merge from 'lodash/merge'
import React, { Component } from 'react'
const tagName = 'mc-section'
const parentTag = ['mj-container']
const defaultMJMLDefinition = {
attributes: {
'mc:hideable': null,
@iamsortiz
iamsortiz / docker-php_apache_modrewrite.sh
Last active May 31, 2020 01:30
Docker php apache modrewrite bash utils
# Convenience bash utils to handle docker: php + apache + modrewrite
# * related issue: https://github.com/docker-library/php/issues/179#issuecomment-234594522
#
# Usage:
# * Download the file
# * In your "bash file"
# * On debian based systems use: ~/.bashrc
# * On Mac use: ~/.bash_profile
# * Include the line: source PATH_TO_THE_DOWNLOADED_FILE
# * Or just copy and paste the contents of this file
@qwtel
qwtel / project.clj
Created July 4, 2016 17:38
Very basic ClojureScript Leiningen setup with cljs-devtools
(defproject hello-world "0.0.0"
;; lein obviously does dependency management
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.92"]]
;; and uses plugins for non-standard tasks
:plugins [[lein-cljsbuild "1.1.3"]
[lein-figwheel "0.5.4-4"]]
;; this will build cljs on `lein compile`
@edgar-bonet
edgar-bonet / sound-meter.ino
Created March 16, 2016 14:29
Arduino sound meter
/*
* sound-meter.ino: Arduino sound meter.
*
* This program continuously samples a sound signal on analog input 0
* and outputs the computed sound intensity through the serial port.
*
* The analog-to-digital converter is set to "free running mode" and
* takes one sample every 104 us. After subtracting a DC offset
* (constant dc_offset below), the samples are squared and low-pass
* filtered with a time constant of 256 sample periods (26.6 ms). They
@bobbygrace
bobbygrace / trello-css-guide.md
Last active September 27, 2025 06:29
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@addyosmani
addyosmani / README.md
Last active November 24, 2025 17:23 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

#!/bin/sh
# install build dependencies
sudo apt-get install git mono-mcs mono-gmcs mono-devel autoconf libtool g++ gettext libglib2.0-cil-dev libgtk2.0-cil-dev libglade2.0-cil-dev libgnome2.0-cil-dev libgconf2.0-cil-dev
# add the ssl certs
sudo certmgr -ssl -m https://go.microsoft.com
sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
sudo certmgr -ssl -m https://nuget.org
mozroots --import --sync
@ChillyBwoy
ChillyBwoy / core.cljs
Created May 22, 2014 23:54
Simple particles in ClojureScript
(ns particles.core)
(def display (.getElementById js/document "display"))
(def context (.getContext display "2d"))
(def damping 0.999)
(def max-particles 250)
(def line-width 2)
(def app-state (atom {:width (.-innerWidth js/window)
:height (.-innerHeight js/window)}))
@cuppster
cuppster / 1.cs
Created September 3, 2012 18:39
Promises for C# using Generics
/*
modified from original source: https://bitbucket.org/mattkotsenas/c-promises/overview
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Promises