Skip to content

Instantly share code, notes, and snippets.

@TheBojda
TheBojda / gist:98887f71dfe966521a8d2007674f8e5d
Created June 24, 2018 07:02
Minimal push gateway for RocketChat in PHP
<?php
// logging the requests for DEBUG
/*
ob_start();
echo $_SERVER['REQUEST_URI'];
$post_data = file_get_contents("php://input");
print_r($post_data);
$data = json_decode($post_data);
var_dump($data);
echo "\n";
@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_cnn_model_training.py
Created October 21, 2019 08:19
TensorFlow CNN model training example
# TensorFlow CNN model training example
# based on https://www.tensorflow.org/tutorials/images/cnn
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt
@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 / gradtape.py
Created November 10, 2019 10:44
Linear regression with Tensorflow GradientTape
# Linear regression using GradientTape
# based on https://sanjayasubedi.com.np/deeplearning/tensorflow-2-linear-regression-from-scratch/
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
class Model:
def __init__(self):
self.W = tf.Variable(16.0)
@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: