Skip to content

Instantly share code, notes, and snippets.

@TheBojda
TheBojda / erc223.sol
Created August 7, 2018 17:10
ERC-223 reference implementation
pragma solidity ^0.4.9;
import "./Receiver_Interface.sol";
import "./ERC223_Interface.sol";
/**
* ERC223 token by Dexaran
*
* https://github.com/Dexaran/ERC223-token-standard
* source: https://github.com/Dexaran/ERC223-token-standard/blob/Recommended/ERC223_Token.sol
@TheBojda
TheBojda / envienta_token.sol
Created February 2, 2019 12:10
ENVIENTA token
pragma solidity ^0.5.3;
contract EnvientaToken {
string public constant symbol = "ENV";
string public constant name = "ENVIENTA token";
uint8 public constant decimals = 18;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval( address indexed owner, address indexed spender, uint256 value);
@TheBojda
TheBojda / tensorflow_image_classification.py
Created October 21, 2019 08:31
TensorFlow image classification example
# TensorFlow image classification example
# based on https://www.tensorflow.org/tutorials/keras/classification
# model generation: https://gist.github.com/TheBojda/f297544cc4864b2b10c2aad965339c58
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
from tensorflow.keras.models import load_model
# Simple neural network with NumPy from 11 lines of code
# source: https://iamtrask.github.io/2015/07/12/basic-python-network/
X = np.array([ [0,0,1],[0,1,1],[1,0,1],[1,1,1] ])
y = np.array([[0,1,1,0]]).T
syn0 = 2*np.random.random((3,4)) - 1
syn1 = 2*np.random.random((4,1)) - 1
for j in xrange(60000):
l1 = 1/(1+np.exp(-(np.dot(X,syn0))))
l2 = 1/(1+np.exp(-(np.dot(l1,syn1))))
@TheBojda
TheBojda / autoencoder.py
Last active November 25, 2019 15:57
Simple autoencoder in Tensorflow, which converts 14 words to 3D vectors
import numpy as np
import tensorflow as tf
from tensorflow_core.python.keras import layers, models
words = ["cat", "dog", "apple", "orange", "car", "airplane", "man", "woman", "drink", "eat", "neural", "network",
"tensor", "flow"]
dict_len = len(words)
word_index = dict((word, i) for i, word in enumerate(words))
# Word embedding tensorflow example
# based on: https://www.tensorflow.org/tutorials/text/word_embeddings
import io
import tensorflow as tf
from tensorflow_core.python.keras import layers, models, datasets
import tensorflow_datasets as tfds
(train_data, test_data), info = tfds.load(
'imdb_reviews/subwords8k',
import gym
env = gym.make("Breakout-v0")
observation = env.reset()
for _ in range(10000):
env.render()
action = env.action_space.sample() # your agent here (this takes random actions)
observation, reward, done, info = env.step(action)
if done:
@TheBojda
TheBojda / cartpole.py
Created December 9, 2019 08:09
Deep Q-learning CartPole example with OpenAI Gym and Tensorflow
# Deep Q-learning CartPole example
# based on https://github.com/gsurma/cartpole.git & https://gym.openai.com/evaluations/eval_OeUSZwUcR2qSAqMmOE1UIw/
import gym
import random
import numpy as np
from os import path
from collections import deque
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
@TheBojda
TheBojda / simplernn.py
Last active January 12, 2020 08:05
Tensorflow SimpleRNN example
import numpy as np
import tensorflow as tf
from tensorflow_core.python.keras import layers, models
text = "Hello World!"
input_text = text[:-1]
target_text = text[1:]
print(input_text)
print(target_text)
@TheBojda
TheBojda / minst_gan.py
Last active January 25, 2020 20:08
MINST GAN Example
# MINST GAN Example
# based on https://www.tensorflow.org/tutorials/generative/dcgan
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.keras import layers, models
import time
BUFFER_SIZE = 60000
BATCH_SIZE = 256