Skip to content

Instantly share code, notes, and snippets.

View dmichael's full-sized avatar

David Michael dmichael

View GitHub Profile
@dmichael
dmichael / miner-template
Created November 2, 2018 02:53
A grammar test
if balance(BLOCK, BajWThUb9svYuPeQ5AzBni2aiyPxazhf31) > 15
pragma solidity ^0.4.11;
// This contract keeps all Ether sent to it with no way to get it back.
contract Pain {
function() payable {}
}
// So does this one
contract MorePain {
function payme() payable {}
$ go get github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen
$ ipfs-swarm-key-gen > ~/.ipfs/swarm.key

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

# Load up the JSON file, simulating an API call and deserialization
#
netsuite_order = JSON.parse(File.read('sales_order.json').gsub("\n",""))
# Wrap NetSuite's order representation in our translator
#
order_translator = OrderTranslator.new(netsuite_order)
puts order_translator.to_hash
# {
#!/usr/bin/env ruby
require 'json'
require 'active_support/time'
require 'money'
require 'hashie'
class Translator < Hashie::Dash
include Hashie::Extensions::IgnoreUndeclared
include Hashie::Extensions::Dash::PropertyTranslation
include Hashie::Extensions::Coercion
#!/usr/bin/env ruby
require 'json'
require 'active_support/time'
require 'money'
# A class to translate the embedded order items
#
class OrderItemTranslator
# Initialize with the Hash version of the NetSuite JSON
{
"custbody_order_state":{
"name":"Sent
to Production (Full Approval)"
},
"terms":{
"name":"NET 30"
},
"createddate":"5/5/2015
6:20 pm",
#!/usr/bin/env ruby
require 'json'
require 'active_support/time'
require 'money'
require 'hashie'
class Translator < Hashie::Dash
include Hashie::Extensions::IgnoreUndeclared
include Hashie::Extensions::Dash::PropertyTranslation
include Hashie::Extensions::Coercion
ssh pi@raspberrypi.local