Skip to content

Instantly share code, notes, and snippets.

@axelchalon
axelchalon / index.ts
Last active March 12, 2020 16:49
TxWrapper example
/*
yarn init
yarn add @substrate/txwrapper @polkadot/types
touch index.ts
npx ts-node index.ts
*/
import {
deriveAddress, methods, createSigningPayload, getTxHash,
createSignedTx, decode, importPrivateKey, KeyringPair
} from '@substrate/txwrapper';
@axelchalon
axelchalon / keybase.md
Created February 11, 2018 12:51
Keybase verification

Keybase proof

I hereby claim:

  • I am axelchalon on github.
  • I am xaxel (https://keybase.io/xaxel) on keybase.
  • I have a public key whose fingerprint is 10CA 4F9D 09AB 4B96 3269 14E4 7FE4 ABA8 8EA3 F7BF

To claim this, I am signing this object:

// [OUTDATED]
// EthabiFunction
@axelchalon
axelchalon / eip20_file.rs
Last active February 16, 2018 15:19
eip20_file.rs
use ethabi;
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";
#[doc = r" Contract"]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Eip20 {}
impl Eip20 {}
pub mod events {
use ethabi;
use ethabi::ParseLog;
#[derive(Debug, Clone, PartialEq)]
@axelchalon
axelchalon / spell.rs
Last active June 7, 2017 12:07
Spell out a number
use std::io::prelude::*;
use std::collections::LinkedList;
const COMMA_SEPARATOR: bool = true;
fn spell(number: u64) -> String {
#![allow(overflowing_literals)]
match number {
// 0-9
0 => String::from("zero"),
@axelchalon
axelchalon / touchRotate.js
Last active June 15, 2017 21:14
Rotate an element with touch events
/**
* @param DOMElement touchElement The element whose center we use for the rotation, and on which the touch events occur; musn't be an svg element
* @param function callbacks {move: function, end (optional): function}
*/
var TouchRotate = function (touchElement, callbacks) {
// Does not work with SVG, hence touchElement mustn't be an SVG
function getElementCenterCoordinates(el) {
return {
centerX: el.offsetLeft + el.offsetWidth / 2,
@axelchalon
axelchalon / spacer.js
Created February 18, 2016 13:47
Spacer – Grid helper to get cell coordinates
var Spacer = function() {
this.width = null;
this.height = null;
this.columns = 0;
this.rows = 0;
this.xSpacing = 0;
this.ySpacing = 0;
@axelchalon
axelchalon / rss2diskWithImagesInBase64.rb
Last active October 31, 2015 15:17
Retrieves every page from a WP feed; for each page, saves every article onto disk with image links replaced by inline base64 (useful for offline use) – style suggestions welcome
class Fixnum
def one?
return self == 1
end
end
require 'nokogiri'
require 'net/http'
require 'openssl'
require 'base64'