Skip to content

Instantly share code, notes, and snippets.

View kn9ts's full-sized avatar
🌠
I am one with the force!

Eugene Mutai kn9ts

🌠
I am one with the force!
View GitHub Profile
@kn9ts
kn9ts / shortsusd.js
Last active August 26, 2020 08:02
Short SUSD with USDC
const Web3 = require('web3');
const DSA = require('dsa-sdk');
const ETH_ADDRESS = 'XXXX';
const ADDRESS_PVT_KEY = 'XXXX'
const TARGET_ENDPOINT = 'https://mainnet.infura.io/v3/XXXX';
const mainnetP = new Web3.providers.HttpProvider(TARGET_ENDPOINT);
const web3 = new Web3(mainnetP);
const dsa = new DSA({
convertToReadableDate(unixTimestamp) {
// Months array
const monthsArray = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// Convert timestamp to milliseconds
const date = new Date(unixTimestamp * 1000);
const year = date.getFullYear();
const month = monthsArray[date.getMonth()];
const day = date.getDate();
const hours = date.getHours();
const minutes = `0${date.getMinutes()}`;
const rainbowHexColors = [
'#f80c12', '#ee1100', '#ff3311', '#ff4422',
'#ff6644', '#ff9933', '#feae2d', '#ccbb33',
'#d0c310', '#aacc22', '#69d025', '#22ccaa',
'#12bdb9', '#11aabb', '#4444dd', '#3311bb',
'#3b0cbd', '#442299',
];
@kn9ts
kn9ts / env.js
Created February 24, 2019 16:48
Script to load up environment variables into the application
const fs = require('fs');
const yaml = require('js-yaml');
const uuid = require('node-uuid');
const appYamlConfigFile = 'app.yaml';
const requiredEnvVariables = ['DATABASE_URL'];
// default configuration
process.env.API_VERSION = 1;
['SESSION_SECRET_KEY', 'WEB_TOKEN_SECRET'].forEach((configVar) => {
@kn9ts
kn9ts / blockchain_adoption.md
Created February 6, 2019 17:38
Blockchain adoption: Stock exchanges

Blockchain adoption: Stock exchanges

The adoption of blockchain technology among stock exchanges is expected to offer significant scope to improve the efficiency around settlement/clearing and collateral management. As a reminder, settlement in the exchanges space is typically T+3 days, but the delay is principally due to market practices, financial industry laws, and regulatory requirements and not necessarily to current technological infrastructure. The industry has already been discussing the potential to reduce settlement to T+2 (already common in Australia) and the implementation of blockchain could act as a catalyst to drive down the settlement period further towards T+0.

Regulatory and legal challenges require resolution before we see wide-spread adoption. The use of blockchain/distributed ledger for settlements could provide a secure, consistent source of proof of the current ownership and provide the origin of assets to custodians, agents and beneficial owners. We note the constraint will clear

pragma solidity ^0.4.11;
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);

Keybase proof

I hereby claim:

  • I am kn9ts on github.
  • I am kn9ts (https://keybase.io/kn9ts) on keybase.
  • I have a public key ASDqotrrc13OFl4FQRzD7D1z4t5GT78lIzCKQ_j2IOTs2Ao

To claim this, I am signing this object:

@kn9ts
kn9ts / vm_mpesa_api_readme.md
Last active April 9, 2022 06:32
Instructions to using the Vitumob Mpesa API
@kn9ts
kn9ts / makeHTTPRequest.js
Last active December 4, 2018 08:43
makeHTTPRequest.js
import queryparams from 'query-params';
export default (method, targetedResource, { headers, pathVariables, params, body }) => {
if (pathVariables) {
Object.keys(pathVariables).forEach((key) => {
targetedResource = targetedResource.replace(`{${key}}`, pathVariables[key]);
});
}
if (params) targetedResource += `?${queryparams.encode(params)}`;
pragma solidity ^0.4.24;
/**
* @title Math
* @dev Assorted math operations
*/
library Math {
function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b;
}