Skip to content

Instantly share code, notes, and snippets.

View josefrichter's full-sized avatar

Josef Richter josefrichter

View GitHub Profile
@josefrichter
josefrichter / stack.ex
Created December 13, 2021 11:10
Genserver: How to return errors from cast?
defmodule Stack do
use GenServer
# Client
def start_link(default) when is_list(default) do
GenServer.start_link(__MODULE__, default)
end
def push(pid, element) do
// doesn't throw error, but doesn't work:
const x = useTransform(
contentOffsetY,
[0, -400],
[0, endX],
[
{
clamp: false,
ease: [0.5],
export function ScaleV2(): Override {
const [endX, endScale, endOpacity] = [-60, 0.5, 0.6] // TODO pass this from outside
const x = useTransform(contentOffsetY, [0, -400], [0, endX], {
clamp: false,
})
const scale = useTransform(contentOffsetY, [0, -400], [1, endScale], {
clamp: false,
})
const opacity = useTransform(contentOffsetY, [0, -400], [1, endOpacity], {
@josefrichter
josefrichter / contracts...MyContract.sol
Created September 9, 2021 17:33
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
uint256 public peopleCount;
// Person[] public people;
mapping(uint => Person) public people;
struct Person {
@josefrichter
josefrichter / contracts...MyContract3.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
uint256 public peopleCount;
mapping(uint => Person) public people;
address owner;
uint256 openingTime = 1631171503;
/// uint256 openingTime = 1631171803;
@josefrichter
josefrichter / contracts...MyContract4.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
mapping(address => uint256) public balances;
address payable wallet;
event Purchase(
address indexed _buyer,
uint256 _amount
@josefrichter
josefrichter / contracts...MuyContract5.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract ERC20Token {
string public name;
mapping(address => uint256) public balances;
function mint() public {
balances[tx.origin] ++;
}
}
@josefrichter
josefrichter / contracts...MyContract5b.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract ERC20Token {
string public name;
mapping(address => uint256) public balances;
constructor(string memory _name) {
name = _name;
}
@josefrichter
josefrichter / contracts...MyContract6.sol
Created September 9, 2021 17:32
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
import "./SafeMath.sol";
// import "./Math.sol";
// library Math {
// function divide(uint256 a, uint256 b) internal pure returns (uint256) {
// require(b > 0);
// uint256 c = a / b;
@josefrichter
josefrichter / contracts...Escrow.sol
Created September 9, 2021 17:30
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract Escrow {
address agent; // nobody else can use this contract
mapping(address => uint256) public deposits;
modifier onlyAgent() {
require(msg.sender == agent);