Skip to content

Instantly share code, notes, and snippets.

View aunyks's full-sized avatar
Increasing potential

Gerald Nash aunyks

Increasing potential
View GitHub Profile
@aunyks
aunyks / tune.js
Created June 20, 2020 20:18
A quick Node script for generating a couple MIDI files that make a tune, together.
const {
clip,
scale,
midi,
arp,
getChordsByProgression
} = require('scribbletune')
const progression = getChordsByProgression('d2 major', 'I VI ii V')
@aunyks
aunyks / translate-codons.js
Last active March 3, 2020 15:12
This file exports a function that converts a RNA codon into the Amino Acid it encodes. Do your own due diligence to ensure you're processing the right codons.
const isRNANucleotide = n => {
const lowerN = n.toLowerCase()
return (
lowerN === 'a' || // adenine
lowerN === 'u' || // uracil
lowerN === 'c' || // cytosine
lowerN === 'g' // guanine
)
}
function setup() {
frameRate(30)
}
const numParticles = 20
const numGradientParts = 20
let particles =
[...(new Array(numParticles)).keys()]
.map(i => {
@aunyks
aunyks / web3-snitch.html
Created September 11, 2019 14:25
Web3 Snitch detects whether your web3 provider discloses identifying information to dapps without your permission.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>Web3 Snitch</title>
<style>
html,
def to_bin(n):
return bin(n)[2:] if n >= 0 else bin(n)[3:]
def to_int(b):
return int(b, 2)
def ones_complement(b):
return b.replace('1', '2').replace('0', '1').replace('2', '0')
def twos_complement(b):
@aunyks
aunyks / utils.py
Last active May 2, 2018 21:03
Simple utility functions used throughout my research.
import datetime
import json
import requests
def unix_to_date(unix_int):
if type(unix_int) == type(''):
return datetime.datetime.fromtimestamp(int(unix_int)).strftime('%Y-%m-%d %H:%M:%S')
elif type(unix_int) == type(0):
return datetime.datetime.fromtimestamp(unix_int).strftime('%Y-%m-%d %H:%M:%S')
else:
@aunyks
aunyks / metamine.sol
Created April 30, 2018 01:44
A minable ERC20 token.
pragma solidity ^0.4.0;
// event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber);
// event Transfer(address indexed _from, address indexed _to, uint256 _value);
// event Approval(address indexed _owner, address indexed _spender, uint256 _value);
contract Metamine {
uint256 public constant MAX_TARGET = 2**256 - 1;
uint256 public constant totalSupply = 21000000; // max 21M tokens

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@aunyks
aunyks / erc721-example.sol
Last active April 12, 2024 00:56
My implementation of the ERC721 token standard. WARNING: THIS CODE IS FOR EDUCATIONAL PURPOSES. DO NOT DEPLOY TO THE NETWORK.
pragma solidity ^0.4.19;
contract ERC721 {
string constant private tokenName = "My ERC721 Token";
string constant private tokenSymbol = "MET";
uint256 constant private totalTokens = 1000000;
mapping(address => uint) private balances;
mapping(uint256 => address) private tokenOwners;
mapping(uint256 => bool) private tokenExists;
mapping(address => mapping (address => uint256)) private allowed;
mapping(address => mapping(uint256 => uint256)) private ownerTokens;
contract ERC721 {
// ERC20 compatible functions
function name() constant returns (string name);
function symbol() constant returns (string symbol);
function totalSupply() constant returns (uint256 totalSupply);
function balanceOf(address _owner) constant returns (uint balance);
// Functions that define ownership
function ownerOf(uint256 _tokenId) constant returns (address owner);
function approve(address _to, uint256 _tokenId);
function takeOwnership(uint256 _tokenId);