Skip to content

Instantly share code, notes, and snippets.

@slorber
slorber / react-navigation-tree.jsx
Last active August 13, 2022 19:17
react-navigation-tree.jsx
const App = createAppContainer(
createStack({
LoggedSwitch: createSwitch({
// When user is authenticated
LoggedIn: createStack({
// The logged in root is generally a tab or drawer navigator
LoggedInRoot: createTabsOrDrawer({
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@nicolai86
nicolai86 / gofuncs.go
Created December 15, 2017 05:50
osx sleep/ wake notifications in golang
package main
import (
"C"
"log"
"time"
)
//export CanSleep
func CanSleep() C.int {

Redux WebSocket Middleware: Example

This Gist provides some code examples of how to implement WebSocket stream handling using a Redux middleware. Please be aware that this is only provided as an example and that critical things like exception handling have not been implemented.

A more complete version has been packaged, tested, and is available on GitHub as redux-websocket. This library has also been published to npm at @giantmachines/redux-websocket.

Middleware

This module represents the foundation of the middleware and implements the ideas presented above. The exported function is used during the creation of the Redux store (see the following snippet).

@levibostian
levibostian / post.md
Last active April 15, 2020 20:31
webpack, Tachyons, pug, Vue.js web app.

Today, single page web apps are driving many websites that we use each and every day. Instead of having your browser request a new web page for each and every action you perform on a web page, single page web apps may load all in one request to smoothly and quickly transition with every action you perform.

When building single page web apps, you may decide to retrieve all of the HTML, CSS and Javascript with one single page load or dynamically load these resources as the user moves about your site. Either way, it can be a pain to bundle all of these assets together for the end user to download from your web server. This is where webpack comes into play.

webpack does all of the heavy lifting bundling all of your HTML, CSS and Javascript together. If you write your site all from scratch or depend on dependencies from npm, webpack takes care of packaging it all together for you. It has the ability to take your single page web app, cut out all of the code you don't need, then packa

@Vpr99
Vpr99 / _borders.css
Created August 30, 2016 17:33
App Card
/* BORDERS */
@import '_colors';
/*
Base:
bw = border-width
br = border-radius
Modifiers:
0 = 0 width border
@mohanrohith
mohanrohith / ErrorUtils.js
Created July 15, 2016 10:07
Error handler for React Native
import StackTrace from 'stacktrace-js'
const Fabric = require('react-native-fabric')
const { Crashlytics } = Fabric
// call this to start capturing any no-handled errors
exports.init = function () {
const originalHandler = global.ErrorUtils.getGlobalHandler()
function errorHandler (e) {
exports.issue(e)
if (originalHandler) {
@brandondurham
brandondurham / styles.less
Last active January 11, 2024 06:46
Using Operator Mono in Atom
/**
* Using Operator Mono in Atom
*
* 1. Open up Atom Preferences.
* 2. Click the “Open Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called “styles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
*
* Theme from the screenshot (http://cdn.typography.com/assets/images/blog/operator_ide2.png):
@siddontang
siddontang / rint.go
Created September 3, 2015 12:31
round implementation in go
package main
import "fmt"
import "math"
// see http://www.gnu.org/software/libc/manual/html_node/Rounding.html
func rint(x float64) float64 {
v, frac := math.Modf(x)
if x > 0.0 {
if frac > 0.5 || (frac == 0.5 && uint64(v)%2 != 0) {