Skip to content

Instantly share code, notes, and snippets.

View gokulsan's full-sized avatar
🐙
Polyglot Programming in Poetic Prismatics

Gokul Alex gokulsan

🐙
Polyglot Programming in Poetic Prismatics
View GitHub Profile
@gokulsan
gokulsan / Ocaml_Expressions.ml
Created July 26, 2020 14:27
Enchanting Expressions in OCaml
# A Boolean True Expression Between Special Characters
{|"\\"|}="\"\\\\\"";;
# A Boolean True Expression Between Strong Literals
{delimiter|the end of this|}quoted string is here|delimiter}
= "the end of this|}quoted string is here";;
/// @dev given a number get a slice of any bits, at certain offset
/// @param _n a number to be sliced
/// @param _nbits how many bits long is the new number
/// @param _offset how many bits to skip
function _sliceNumber(uint256 _n, uint256 _nbits, uint256 _offset) private pure returns (uint256) {
// mask is made by shifting left an offset number of times
uint256 mask = uint256((2**_nbits) - 1) << _offset;
// AND n with mask, and trim to max of _nbits bits
return uint256((_n & mask) >> _offset);
}
@BjornvdLaan
BjornvdLaan / BLSExample.sol
Last active April 10, 2023 07:49
Verification of BLS signatures and BGLS aggregate signatures in Ethereum
pragma solidity ^0.4.14;
/*
Example of how to verify BLS signatures and BGLS aggregate signatures in Ethereum.
Signatures are generated using https://github.com/Project-Arda/bgls
Code is based on https://github.com/jstoxrocky/zksnarks_example
*/
contract BLSExample {
@ntamvl
ntamvl / install-multiple-jdk-on-macos-high-sierra.md
Last active February 21, 2024 11:12
Install Multiple Java Versions on macOS High Sierra

Install Multiple Java Versions on macOS High Sierra

Install Homebrew Cask

On Mac, Homebrew is the de-facto package manager, and Homebrew Cask is the app manager. I’m going to use Cask to install Java 7 and 8.

Install Homebrew Cask first if you haven’t:

brew update
brew tap caskroom/cask
0x00 0 STOP
0x01 3 ADD
0x02 5 MUL
0x03 3 SUB
0x04 5 DIV
0x05 5 SDIV
0x06 5 MOD
0x07 5 SMOD
0x08 8 ADDMOD
0x09 8 MULMOD
@vijayanandrp
vijayanandrp / Baby Step Giant Step DLP problem .py
Created June 14, 2017 21:28
10 line python code to solve DLP (Discrete Logarithmic Problem) using Baby Step Giant Step Algorithm
# Baby Step Giant Step DLP problem y = a**x mod n
# Example 70 = 2**x mod 131
# Use SAGE for complex operations
y = 70
a = 2
n = 131
@bitgord
bitgord / Escrow-Smart-Contract
Created December 5, 2016 04:13
Example of an escrow smart contract
// package.json
{
"dependencies": {
"web3": "0.17.0-alpha",
"solc": "^0.4.4"
}
}
//Create file Ecrow.sol and create 3 variables: a buyer, a seller, and an arbiter
contract Escrow {
@chriseth
chriseth / 0 README.md
Last active November 6, 2022 19:55
Formal verification for re-entrant Solidity contracts

This gist shows how formal conditions of Solidity smart contracts can be automatically verified even in the presence of potential re-entrant calls from other contracts.

Solidity already supports formal verification of some contracts that do not make calls to other contracts. This of course excludes any contract that transfers Ether or tokens.

The Solidity contract below models a crude crowdfunding contract that can hold Ether and some person can withdraw Ether according to their shares. It is missing the actual access control, but the point that wants to be made

@pirapira
pirapira / auction00.sol
Last active November 4, 2021 13:32
An auction contract written in Solidity
contract auction {
// An auction contract written in Solidity
// Can be deployed similarly to what is described at:
// https://dappsforbeginners.wordpress.com/tutorials/your-first-dapp/
// Initialization.
// Remembering bids from each address.
mapping (address => uint) bids;
// Also remembering the max_bid and the max_bidder to easily determine the winner.
uint max_bid = 0;
@evanscottgray
evanscottgray / docker_kill.sh
Last active November 7, 2023 03:40
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt