Skip to content

Instantly share code, notes, and snippets.

View gatherheart's full-sized avatar
🤗
Always Gather Heart

Milkybean gatherheart

🤗
Always Gather Heart
View GitHub Profile
@gatherheart
gatherheart / run_coroutine_in_another_thread.py
Created September 29, 2018 08:46 — forked from lars-tiede/run_coroutine_in_another_thread.py
Safely run a coroutine in another thread's asyncio loop and return the result
import threading
import asyncio
async def run_coro_threadsafe(self, coro, other_loop, our_loop = None):
"""Schedules coro in other_loop, awaits until coro has run and returns
its result.
"""
loop = our_loop or asyncio.get_event_loop()
# schedule coro safely in other_loop, get a concurrent.future back
@gatherheart
gatherheart / asyncio_loops.py
Created September 29, 2018 08:46 — forked from lars-tiede/asyncio_loops.py
asyncio + multithreading: one asyncio event loop per thread
import asyncio
import threading
import random
def thr(i):
# we need to create a new loop for the thread, and set it as the 'default'
# loop that will be returned by calls to asyncio.get_event_loop() from this
# thread.
loop = asyncio.new_event_loop()
@gatherheart
gatherheart / Vote.sol
Created April 18, 2019 13:12
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=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity ^0.5.1;
contract Vote{
// structure
struct candidate{
string name;
uint upVote;
}
// variable
@gatherheart
gatherheart / Vote.sol
Created April 27, 2019 08:15
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=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity ^0.5.1;
contract Vote{
// structure
struct candidate{
string name;
uint upVote;
}
// variable
@gatherheart
gatherheart / ENS.sol
Created May 13, 2019 15:10
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=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity >=0.4.22 < 0.6.0;
contract Ownerable {
// event for ownership of contract
event OwnerLogger(address);
address public owner;
constructor() public{
owner = msg.sender;
emit OwnerLogger(msg.sender);
@gatherheart
gatherheart / ArrayUtils.sol
Created November 23, 2019 13: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=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity >=0.4.22 < 0.6.0;
// REFERENCE TO github.com/gatherheart
// support for only uint256 and address array
library ArrayUtils{
using ArrayUtils for uint256 [];
using ArrayUtils for address [];
@gatherheart
gatherheart / ArrayUtils.sol
Created November 23, 2019 14:12
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=soljson-v0.5.13+commit.5b0b510c.js&optimize=false&gist=
pragma solidity >=0.4.22 < 0.6.0;
// REFERENCE TO github.com/gatherheart
// support for only uint256 and address array
library ArrayUtils{
using ArrayUtils for uint256 [];
using ArrayUtils for address [];
@gatherheart
gatherheart / ArrayUtils.sol
Created November 30, 2019 07:28
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=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity >=0.4.22 < 0.6.0;
// REFERENCE TO github.com/gatherheart
// support for only uint256 and address array
library ArrayUtils{
using ArrayUtils for uint256 [];
using ArrayUtils for address [];
@gatherheart
gatherheart / ArrayUtils.sol
Created December 5, 2019 13:04
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=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity >=0.4.22 < 0.6.0;
// REFERENCE TO github.com/gatherheart
// support for only uint256 and address array
library ArrayUtils{
using ArrayUtils for uint256 [];
using ArrayUtils for address [];
@gatherheart
gatherheart / ArrayUtils.sol
Created December 11, 2019 09:28
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=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity >=0.4.22 < 0.6.0;
// REFERENCE TO github.com/gatherheart
// support for only uint256 and address array
library ArrayUtils{
using ArrayUtils for uint256 [];
using ArrayUtils for address [];