Skip to content

Instantly share code, notes, and snippets.

View serial-coder's full-sized avatar
🎯
Focusing

Phuwanai Thummavet serial-coder

🎯
Focusing
View GitHub Profile
@serial-coder
serial-coder / PizzaCoin-Flattened.sol
Created August 23, 2018 11:04
Pizza Coin contract's source code
/*
* Copyright (c) 2018, Phuwanai Thummavet (serial-coder). All rights reserved.
* Github: https://github.com/serial-coder
* Contact us: mr[dot]thummavet[at]gmail[dot]com
*/
pragma solidity ^0.4.23;
// ----------------------------------------------------------------------------
@serial-coder
serial-coder / bytes32ToString.sol
Created August 26, 2018 06:42
bytes32ToString() in Solidity
function bytes32ToString (bytes32 x)
private
view
returns (string)
{
bytes memory bytesString = new bytes(32);
uint256 charCount = 0;
for (uint256 j = 0; j < 32; j++) {
byte char = byte(bytes32(uint256(x) * 2 ** (8 * j)));
@serial-coder
serial-coder / msg-signing.js
Last active January 21, 2019 09:40
Web3 Message Signing for ecrecover()
signMessage = async () => {
const web3 = this.state.web3;
const { voucherId, parity, amount, dateUnix } = this.state;
const intVoucherId = web3.utils.toDecimal('0x' + this.String2Hex(voucherId));
const intParity = web3.utils.toDecimal('0x' + this.String2Hex(parity));
console.log('signerAddress', this.state.signerAddress);
console.log(intVoucherId);
@serial-coder
serial-coder / VoucherRedeem.sol
Created January 21, 2019 09:42
redeemVoucher() for PKTF
function redeemVoucher(
uint8 _v,
bytes32 _r,
bytes32 _s,
uint64 _voucherID,
uint64 _parityCode,
uint256 _amount,
uint256 _expired,
address _receiver,
bytes32 _socialHash
[
{
"name": "PDC-1",
"policy": "OR('Org1MSP.member', 'Org2MSP.member', 'Org3MSP.member')",
"requiredPeerCount": 1,
"maxPeerCount": 3,
"blockToLive": 0,
"memberOnlyRead": true
},
{
@serial-coder
serial-coder / lock.sol
Created May 28, 2019 06:49 — forked from biigpongsatorn/ERC20Interface.sol
Lock P'Brite'DAI
pragma solidity >=0.4.22 <0.6.0;
import './ERC20Interface.sol';
contract LockBrite {
address big;
address jeff;
address brite;
uint256 timeLock = 2537332769;

Keybase proof

I hereby claim:

  • I am serial-coder on github.
  • I am serial_coder (https://keybase.io/serial_coder) on keybase.
  • I have a public key ASAhveoBXI1KGnGQWin4tRljcyBHKwuY5yVfUA43XM4F9Ao

To claim this, I am signing this object:

@serial-coder
serial-coder / medium_private.go
Last active September 27, 2019 03:50
Demo the private data in Hyperledger Fabric
/*
This gist is a fixed version from https://github.com/macienrique/hfPrivateData.
The code base has 2 vulnerabilities including
1. The private data arguments were sent to the chaincode using -c switch,
resulting in the private data would be stored into the public ledger of every peer.
2. The function createProduct returned the client the Product object
which might consider sensitive information.
For more detailed information, please refer to the discussion section in the following article:
@serial-coder
serial-coder / kube-registry.yaml
Created February 26, 2020 07:38 — forked from coco98/kube-registry.yaml
Docker registry on minikube
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
@serial-coder
serial-coder / kvm_minikube.md
Created July 3, 2020 08:52 — forked from alexellis/kvm_minikube.md
Run multiple minikube Kubernetes clusters on Ubuntu Linux with KVM

Ramp up your Kubernetes development, CI-tooling or testing workflow by running multiple Kubernetes clusters on Ubuntu Linux with KVM and minikube.

In this tutorial we will combine the popular minikube tool with Linux's Kernel-based Virtual Machine (KVM) support. It is a great way to re-purpose an old machine that you found on eBay or have gathering gust under your desk. An Intel NUC would also make a great host for this tutorial if you want to buy some new hardware. Another popular angle is to use a bare metal host in the cloud and I've provided some details on that below.

We'll set up all the tooling so that you can build one or many single-node Kubernetes clusters and then deploy applications to them such as OpenFaaS using familiar tooling like helm. I'll then show you how to access the Kubernetes clusters from a remote machine such as your laptop.

Pre-reqs

  • This tutorial uses Ubuntu 16.04 as a base installation, but other distributions are supported by KVM. You'll need to find out how to install