Skip to content

Instantly share code, notes, and snippets.

@miracle2k
miracle2k / example.js
Created September 26, 2015 10:42
Simplify relay using decorators
@relayRoot
@relayContainer({
client: () => Relay.QL`
fragment on Client {
id,
menuitems(first: 50) {
}
}
`
})
@miracle2k
miracle2k / convert.js
Created June 15, 2018 04:45
Convert Ethereum private keys to EOS private keys (the "Fallback method" to access your EOS tokens).
// Extracted from https://github.com/eoscafe/eoskeyio
const ecc = require('eosjs-ecc');
const eth = require('ethereumjs-util');
let ethereumPrivateKey = 'FILL THIS IN';
if(eth.isValidPrivate(Buffer.from(ethereumPrivateKey, 'hex'))) {
let ethereumAddress = '0x' + eth.privateToAddress(Buffer.from(ethereumPrivateKey, 'hex')).toString('hex')
let ethereumPublicKey = eth.privateToPublic(Buffer.from(ethereumPrivateKey, 'hex')).toString('hex')
@miracle2k
miracle2k / .bashrc
Created July 6, 2014 12:19
Convert an existing docker container into a "docker run" command line
# Convert an existing docker container into a "docker run" command line.
#
# This is useful when trying to debug containers that have been created
# by orchestration tools.
#
# Install jq: stedolan.github.io/jq/
function format_run() {
cid=$1
@miracle2k
miracle2k / web3py_aio.py
Created April 28, 2021 13:52
Using web3py with asyncio
"""
Inspired by this approach:
- https://twitter.com/zzzeek/status/1279069782533386247
- https://gist.github.com/zzzeek/2a8d94b03e46b8676a063a32f78140f1
- https://gist.github.com/zzzeek/33943060f7a08cf9e82bf8df1f0f75de, https://gist.github.com/zzzeek/4e89ce6226826e7a8df13e1b573ad354#file-asyncio_plus_greenlet-py-L28
Essentially we use greenlets to make the IO layer async and the top layer uses async/await, but everything in
between can be regular sync code.
# Tweak the existing Logging integration to work with Logbook.
# Mostly copy-paste from https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/logging.py
#
# Usage:
#
# StreamHandler(sys.stdout, level="INFO").push_application()
# SentryErrorHandler(bubble=True, level='ERROR').push_application()
# SentryBreadcrumbHandler(bubble=True, level='INFO').push_application()
#
@miracle2k
miracle2k / kucoin-fetch-fees.py
Last active May 31, 2021 18:30
Fetch fees and precisions for all currencies from kucoin
import ccxt
import json
import time
import re
import decimal
import math
kucoin = ccxt.kucoin({
"apiKey": "",
"secret": ""
@miracle2k
miracle2k / plugin.js
Created August 18, 2013 13:40
CKEditor 3/4 plugin that adds a new "internal link" option to the Link dialog window. This is an adaption of Henri Medot's Drupal integration plugin (https://drupal.org/project/ckeditor_link) to a custom CMS system. I'm publishing it here because the original code includes no comments, which meant I had to figure out the CKEditor API and what th…
/**
* Add an "CMS internal link" option to the Link plugin.
*
* This was adapted from a similar plugin for Drupal (version 7.x-2.3):
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
* http://www.absyx.fr
* https://drupal.org/project/ckeditor_link
*
* Portions of code:
* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
@miracle2k
miracle2k / jsonalchemy.py
Last active March 26, 2021 05:19 — forked from dbarnett/jsonalchemy.py
Support Raw json objects, OrderedDict, dates.
import json
import sqlalchemy
from sqlalchemy import UnicodeText
from sqlalchemy.ext.mutable import Mutable
from datetime import datetime
from collections import OrderedDict
__all__ = ('JSON', 'JsonRaw')
@miracle2k
miracle2k / .block
Created December 21, 2020 00:23 — forked from johnburnmurdoch/.block
Watercolour affect using HTML5 canvas
license: mit
height: 620
scrolling: no
border: no
@miracle2k
miracle2k / .block
Last active December 21, 2020 00:21 — forked from johnburnmurdoch/.block
Tool for creating virtual spray paint / masking tape art
height: 700