Skip to content

Instantly share code, notes, and snippets.

@noman-land
noman-land / LinkedList.sol
Created April 4, 2018 06:49
Push and pop to the end
pragma solidity ^0.4.21;
contract LinkedList {
bool public isEmpty = true;
uint public length = 0;
bytes32 public head;
bytes32 public tail;
struct LinkNode {
string value;
@noman-land
noman-land / paillier.js
Last active April 18, 2018 06:48
Example of additive and multiplicative homomorphic encryption
// Reference: https://radicalrafi.github.io/posts/homomorphic-encryption/
// npm i --save big-integer
const bigInt = require('big-integer');
const L = (x, n) => x.minus(1).divide(n);
function createEncryptor({ n, g }) {
return (m, r) => g.pow(m).times(r.pow(n)).mod(n.pow(2));
}
@noman-land
noman-land / GCDLCMCache.sol
Created April 19, 2018 16:53 — forked from 3esmit/GCDLCMCache.sol
hacky gcd lcm solidity with cache
pragma solidity ^0.4.21;
contract GCDLCMCache {
mapping (bytes32 => uint256) public cache;
enum CacheType { GCD, LCM }
function gcd(uint256[] input)
@noman-land
noman-land / BattleHash.sol
Last active April 21, 2018 20:58
Board is 2x2 for testing purposes, it will be 10x10 eventually.
pragma experimental ABIEncoderV2;
pragma solidity ^0.4.23;
contract BattleHash {
uint256 public numGames;
modifier validShot(uint256 gameId) {
Game storage game = games[gameId];
address lastShooter = getLastShooter(game);
pragma solidity ^0.4.24;
contract IdeaRegistry {
struct Idea {
address owner;
uint[] links;
}
mapping(uint => Idea) registry;
pragma solidity ^0.4.24;
contract IdeaRegistry {
function registerIdea(uint hash) public;
}
contract IdeaValidator {
address owner;
address registryAddress;
mapping (address => bool) validators;
@noman-land
noman-land / WorkAgreement.sol
Last active December 29, 2018 01:14
Work agreement and taxes smart contracts
pragma solidity ^0.4.11;
contract TaxAuthority {
address public owner;
mapping (address => uint) public taxesCollected;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
from network import Bluetooth
from network import LoRa
import socket
## CONSTANTS ##
# Increment this to setup more devices
VERSION = 1
@noman-land
noman-land / deploy.yml
Created August 5, 2022 22:58 — forked from miguelmota/deploy.yml
Github actions deploy to IPFS and update Cloudflare TXT _dnslink subdomain example
name: deploy
on:
push:
branches:
- master
jobs:
set_environment:
outputs:
env_name: ${{ steps.setenv.outputs.env_name }}
@noman-land
noman-land / 1337.js
Created December 9, 2022 01:57
1337
((_,[t,a],x=[3])=>
((z, ...w)=>t[t[a]`Y29uc29sZQ`][t[a]`bG9n`](z[t[a]`bWFw`](t[a]), ...w))`SQ${~~!''}YW0${x[0]}d2hhdA${x[~~'']}dGhleQ${x[~~""]+++x[~~``]++}Y2FsbA`)`${[this,((j,t)=>`${j[t]}t${j[-``]}`)`ob${1}a`]}`