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

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@kn9ts
kn9ts / object_inheritance_function.js
Created April 28, 2015 17:13
How jQuery's $.extend function works, a way for object to inherit other objects properties and functions
function extend(target_object) {
// Look for additional parameters in this function
// eg. extend(target_object, ....a,b,c,d)
if (!arguments[1]) {
return;
}
// If any extra arguments, which are objects
// loop through them
for (var index = 1; index < arguments.length; index++) {
@kn9ts
kn9ts / mimetypes.go
Created July 6, 2015 08:33
mime types of different documents/files
var mimemaps map[string]string = map[string]string{
".3dm": "x-world/x-3dmf",
".3dmf": "x-world/x-3dmf",
".7z": "application/x-7z-compressed",
".a": "application/octet-stream",
".aab": "application/x-authorware-bin",
".aam": "application/x-authorware-map",
".aas": "application/x-authorware-seg",
".abc": "text/vndabc",
".ace": "application/x-ace-compressed",
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 / 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)}`;