Skip to content

Instantly share code, notes, and snippets.

View perfectmak's full-sized avatar
🎯
Focusing

Perfect Makanju perfectmak

🎯
Focusing
View GitHub Profile
@perfectmak
perfectmak / abi.json
Created June 1, 2022 01:06
Starknet Code to interact with Poster Contract on Chain
[
{
"data": [
{
"name": "address",
"type": "felt"
},
{
"name": "content_len",
"type": "felt"

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

pragma solidity 0.6.1;
interface MoneyToken {
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
}
contract Loan {
mapping(address => uint256) public loanRegistry;
address owner;
address public ngntTokenAddress;
@perfectmak
perfectmak / MeetupLoan.sol
Created March 1, 2020 11:45
A solidity Loan smart contract built at the blockchain meetup in Lagos
pragma solidity 0.6.1;
interface MoneyToken {
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
}
contract Loan {
mapping(address => int256) public loanRegistry;
address owner = 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c;
/**
function distance(color1, color2) {
const [ r1, g1, b1 ] = color1
const [ r2, g2, b2 ] = color2
return Math.sqrt(
Math.pow(r1 - r2, 2) + Math.pow(g1 - g2, 2) + Math.pow(b1 - b2, 2)
)
}
function quantize(k, colors) {
...
const centerDistances = new Array(k)
for(let i = 0; i < colors.length; i++) {
for(let j = 0; j < centers.length; j++) {
centerDistances[j] = distance(centers[j], colors[i])
}
const minimumDistance = Math.min(...centerDistances)
const closestCentersIndex = centerDistances.indexOf(minimumDistance)
function getRandomKCenters(k, colors) {
return lodash.sampleSize(colors, k);
}
function quantize(k, colors) {
...
const centers = getRandomKCenters(k, colors)
...
}
function quantize(k, colors) {
if (k > colors.length) {
throw Error(`K (${k}) is greater than colors (${colors.length}).`)
}
...
}
@perfectmak
perfectmak / image-color-quantization.js
Last active January 26, 2018 18:06
Simple Implementation of Color Quantization in Javascript (Node.js)
function quantize(k, colors) {
if (k > colors.length) {
throw Error(`K (${k}) is greater than colors (${colors.length}).`)
}
const centers = getRandomKCenters(k, colors)
let centerDistances = []
for(let i = 0; i < colors.length; i++) {
for(let j = 0; j < centers.length; j++) {
const pinger = require('./ping-bot');
const Botkit = require('botkit');
//require beepboop's library
const BeepBoop = require('beepboop-botkit');
//as usual, initialize a slackbot controller
const controller = Botkit.slackbot();
/**