Skip to content

Instantly share code, notes, and snippets.

View johngrantuk's full-sized avatar

John Grant johngrantuk

View GitHub Profile
def WorkCheck():
try:
# HERE SOME INITIAL WORK IS DONE THAT SCRIPTS 1 & 2 NEED TO WAIT FOR
# IDs SERIAL PORTS
# SAVE TO db
r = redis.StrictRedis(host='localhost', port=6379) # Connect to local Redis instance
p = r.pubsub() # See https://github.com/andymccurdy/redis-py/#publish--subscribe
@johngrantuk
johngrantuk / Grid+.md
Last active October 12, 2017 13:48
Grid+
Question BOLT GRID
Is the token tied to a product usage, i.e. does it give the user exclusive access to it, or provide interaction rights to the product? Yes, Provides access to Grid+ energy. Yes, 1 GRID token = 500 kWh at the wholesale price.
Does the token grant a governance action, like voting on a consensus related or other decision-making factor? No No
Does the token enable the user to contribute to a value-adding action for the network or market that is being built? Yes, Selling generated electricity on a p2p network. No
Does the token grant an ownership of sorts, whether it is real or a proxy to a value? Yes, Ownership of energy. Yes, Ownership of wholesale energy.
Does the token result in a monetizable reward based on an action by the user (active work)? Yes, Any revenue earned by a customer from selling electricity is earned in BOLT tokens instead of fiat and is stored on the Agent. No
Does the token grant
Question STORM
Is the token tied to a product usage, i.e. does it give the user exclusive access to it, or provide interaction rights to the product? Yes, 'Makers' are required to pay for posts in STORM tokens
Does the token grant a governance action, like voting on a consensus related or other decision-making factor? No
Does the token enable the user to contribute to a value-adding action for the network or market that is being built? Yes. Bolts can be used to boost Players access to tasks.
Does the token grant an ownership of sorts, whether it is real or a proxy to a value? No
Does the token result in a monetizable reward based on an action by the user (active work)?

Intro

IOTA is a revolutionary new transactional settlement and data integrity layer for the Internet of Things. It’s based on a new distributed ledger architecture, the Tangle, which overcomes the inefficiencies of current Blockchain designs and introduces a new way of reaching consensus in a decentralized peer-to-peer system. For the first time ever, through IOTA people can transfer money without any fees. This means that even infinitesimally small nanopayments can be made through IOTA. - From the docs

Sounds pretty cool! And I think it has potential to overcome some existing blockchain issues. I wanted to try out some development using Python and IOTA Python. It took a bit of work getting started but once you know the steps it's pretty easy so I thought I'd share what I did.

Setup Dev Environment

It's always good practise to develop using a virtual environment so I started in a clean dir and ran:

@johngrantuk
johngrantuk / readSensor.py
Created March 29, 2016 18:20
Django Channels background worker
from channels import Group
from django.core.management import BaseCommand
import time
#The class must be named Command, and subclass BaseCommand
class Command(BaseCommand):
# Show this when the user types help
help = "Simulates reading sensor and sending over Channel."
# A command must define handle()
def FieldSumHorn(ElementArray, Freq):
"""
Summation of field contributions from each horn element in array, at frequency freq for theta 0°-95°, phi 0°-360°.
Horn pattern estimate using cos q(theta) function.
Element = xPos, yPos, zPos, ElementAmplitude, ElementPhaseWeight
Returns arrayFactor[theta, phi, elementSum]
"""
arrayFactor = np.ones((360, 95))
@johngrantuk
johngrantuk / App.js
Created August 9, 2019 18:46
Minimal viable call for 3Box Spaces demo
import React from 'react';
const Box = require('3box');
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
heading: 'What If I Told You',
@johngrantuk
johngrantuk / App.js
Last active August 9, 2019 18:58
3Box & React Spaces Example
import React from 'react';
const Box = require('3box');
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
heading: 'What If I Told You', // Default values to display when no 3Box user settings loaded
var LeaderToken = artifacts.require("LeaderToken");
var UniSwapFactory = artifacts.require("uniswap_factory");
var UniSwapExchange = artifacts.require("uniswap_exchange");
contract("UniSwapFactory", accounts => {
it("Add Liquidity.", async () => {
var UniSwapFactoryInstance = await UniSwapFactory.deployed();
var LeaderTokenInstance = await LeaderToken.deployed();
var ExchangeInstance = await UniSwapExchange.deployed();
import redis
import time
import traceback
def RedisCheck():
try:
r = redis.StrictRedis(host='localhost', port=6379) # Connect to local Redis instance
p = r.pubsub() # See https://github.com/andymccurdy/redis-py/#publish--subscribe