Skip to content

Instantly share code, notes, and snippets.

View lots0logs's full-sized avatar
🧑‍💻
Working on Divi Sites

Dustin Falgout lots0logs

🧑‍💻
Working on Divi Sites
View GitHub Profile
@Rich-Harris
Rich-Harris / service-workers.md
Last active July 10, 2024 17:04
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@mhulse
mhulse / fromhex.bash
Last active March 13, 2024 22:15
Bash function to convert hex to 256 terminal color.
# fromhex A52A2A
# fromhex "#A52A2A"
# BLUE_VIOLET=$(fromhex "#8A2BE2")
# http://unix.stackexchange.com/a/269085/67282
function fromhex() {
hex=$1
if [[ $hex == "#"* ]]; then
hex=$(echo $1 | awk '{print substr($0,2)}')
fi
r=$(printf '0x%0.2s' "$hex")
# Copyright (C) 2015 Patrick Griffis <tingping@tingping.se>
# Copyright (C) 2014 Christian Hergert <christian@hergert.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of

What is the difference between Cerebral and Redux?

Cerebral and Redux were built to solve different problems

Redux was developed to achieve hot reloading global state and state changing logic. To achieve that it was necessary for state changes to be run with pure functions and the state has to be immutable. Now you can change the logic inside your reducer and when the application reloads Redux will put it in its initial state and rerun all the actions again, now running with the new state changing logic.

Cerebral had no intention of achieving hot reloading. Cerebral was initially developed to give you insight into how your application changes its state, using a debugger. In the Redux debugger you see what actions are triggered and how your state looks after the action was handled. In Cerebral you see all actions fired as part of a signal. You see asynchronous behaviour, paths taken based on decisions made in your state changing flow. You see all inputs and outputs produced during the flow and you even

@ptomato
ptomato / css.md
Created August 12, 2015 04:27
GTK CSS properties
@cuibonobo
cuibonobo / python-daemons.md
Last active March 25, 2016 07:57
Running daemons in Python

Once a daemon is running, I need some way of communicating with it. That's where Pyro comes in. (I briefly considered running an HTTP server, but the HTTP protocol was designed to handle resources, not remote procedure calls (RPC). Plus, the overhead of an HTTP server, URL handling, and JSON parsing compared to a lightweight Pyro daemon was too much to justify if my plans were to only interact with the daemon over SSH.)

Example Pyro daemon

Example taken from http://stackoverflow.com/questions/24461167/how-can-i-cleanly-exit-a-pyro-daemon-by-client-request. (My test did not demonstrate the hangs that the OP was experiencing.)

server.py:

@pjeby
pjeby / pep487_demo.py
Last active June 5, 2019 15:00
Pure-Python PEP 487 Implementation, usable back to Python 3.1
"""Demonstrate the features"""
from pep487 import init_subclasses, noconflict
class Demo(init_subclasses):
def __init_subclass__(cls, ns, **kw):
print((cls, ns, kw))
super().__init_subclass__(cls, ns, **kw)
# The above doesn't print anything, since it's not a subclass of itself
@you-think-you-are-special
you-think-you-are-special / Singleton.js
Created February 18, 2015 10:52
ES6 Singleton example. Use: import Singleton from 'Singleton'; let instance = Singleton.instance;
'use strict';
/**
* Created by Alexander Litvinov
* Email: alexander@codeordie.ru
* May be freely distributed under the MIT license
*/
let singleton = Symbol();
let singletonEnforcer = Symbol();
@md5
md5 / 00_README.md
Last active June 20, 2024 15:54
Demonstration Docker config for Wordpress on PHP-FPM behind Nginx

Proof of concept setup for Wordpress running under PHP-FPM with an Nginx frontend

Usage

Build a copy of this image:

git clone git://github.com/d9206eacb5a0ff5d6be0.git docker-nginx-fpm
cd docker-nginx-fpm
docker build -t nginx-fpm .
@dasevilla
dasevilla / github-issue-to-phab-task.py
Created May 6, 2014 23:01
Copy GitHub issues to Phabricator
import json
import os
import requests
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
if GITHUB_TOKEN is None:
raise Exception('Missing GITHUB_TOKEN from os.environ')