Skip to content

Instantly share code, notes, and snippets.

@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) {
@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) {
@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

@lantins
lantins / Makefile
Created January 11, 2015 01:35
"Auto build & serve" of golang code :)
#
# Makefile to perform "live code reloading" after changes to .go files.
#
# n.b. you must install fswatch (OS X: `brew install fswatch`)
#
# To start live reloading run the following command:
# $ make serve
#
# binary name to kill/restart
@17twenty
17twenty / simple_git.md
Created September 27, 2013 18:32
A Simple Git branching model

a simple git branching model

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

The gist

package pool
type Task interface {
Execute(id int)
}
type Pool struct {
tasks chan Task
kill chan bool
}
@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({

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).