Skip to content

Instantly share code, notes, and snippets.

@shortthefomo
shortthefomo / ntfDeriveSale.js
Last active November 5, 2022 01:35
XTPL NFT deriveSale
//pass tx as returned from ledger
ntfDeriveSale(tx) {
let hash = tx.hash || tx.transaction.hash
let trade = {}
let taker = tx.Account
for(let affected of (tx.meta || tx.metaData).AffectedNodes){
let node = affected.DeletedNode
if(!node || node.LedgerEntryType !== 'NFTokenOffer')
continue
@WietseWind
WietseWind / index.mjs
Last active July 4, 2022 23:35
Fun with Generator Functions. First backfill XRPL Ledgers, then keep up with current Ledgers closing, fall back to backfilling if needed to sync gaps.
import { XrplClient } from 'xrpl-client'
const config = { backfillLedgers: 20, lastLedger: null }
const client = new XrplClient(['wss://xrplcluster.com'])
await client.ready()
config.lastLedger = client.getState().ledger.last - config.backfillLedgers
function getLedgerTransactions(ledger_index) {
return client.send({ command: 'ledger', transactions: true, expand: true, ledger_index })
@s3rvac
s3rvac / gcc-10-debian-buster.sh
Created October 31, 2020 10:39
Steps to build GCC 10 on Debian Buster.
#!/bin/bash
#
# Steps to build GCC 10 on Debian Buster.
#
set -e -x
# Install all dependencies.
export DEBIAN_FRONTEND=noninteractive
apt update
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@SamJakob
SamJakob / smoothscroll.js
Created October 22, 2018 17:10
A vue-js supported smooth-scroll module based on a Stack Overflow answer by Manuel Otto.
const SmoothScroll = (target, speed, smooth) => {
if (target === document)
target = (document.documentElement || document.body.parentNode || document.body) // cross browser support for document scrolling
let moving = false;
let pos = target.scrollTop;
target.addEventListener('mousewheel', scrolled, false)
/* target.addEventListener('DOMMouseScroll', scrolled, false) */
function scrolled(e) {
@markknol
markknol / how-to-draw-circle-oval-with-haxe-javascript.md
Last active August 16, 2021 11:28
Create oval / circle with bezierCurveTo in Haxe / Javascript

How to draw a circle or oval with Haxe/JavaScript

public static function oval(g:Graphics, w:Float, h:Float, cx:Float = 0, cy:Float = 0):Graphics {
	var lx = cx - w * .5;
	var rx = cx + w * .5;
	var ty = cy - h * .5;
	var by = cy + h * .5;

	var magic = 0.551915024494; 
@batFINGER
batFINGER / process_files.py
Created November 24, 2016 13:05
Process multi files (ImportHelper) in blender.
import bpy
def process_files(context, directory, files):
import os
for file in files:
path = os.path.join(directory, file.name)
print("process %s" % path)
return {'FINISHED'}
# ImportHelper is a helper class, defines filename and
@codingcarpenter
codingcarpenter / key-codes.js
Created February 24, 2016 21:26
JavaScript KeyCodes in a JSON object.
var keys={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pausebreak:19,capslock:20,esc:27,space:32,pageup:33,pagedown:34,end:35,home:36,leftarrow:37,uparrow:38,rightarrow:39,downarrow:40,insert:45,delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,leftwindowkey:91,rightwindowkey:92,selectkey:93,numpad0:96,numpad1:97,numpad2:98,numpad3:99,numpad4:100,numpad5:101,numpad6:102,numpad7:103,numpad8:104,numpad9:105,multiply:106,add:107,subtract:109,decimalpoint:110,divide:111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,semicolon:186,equalsign:187,comma:188,dash:189,period:190,forwardslash:191,graveaccent:192,openbracket:219,backslash:220,closebracket:221,singlequote:222};
@candycode
candycode / image-arraybuffer.js
Created March 7, 2014 15:24
Create a jpg image from ArrayBuffer data
// Simulate a call to Dropbox or other service that can
// return an image as an ArrayBuffer.
var xhr = new XMLHttpRequest();
// Use JSFiddle logo as a sample image to avoid complicating
// this example with cross-domain issues.
xhr.open( "GET", "http://fiddle.jshell.net/img/logo.png", true );
// Ask for the result as an ArrayBuffer.
xhr.responseType = "arraybuffer";
@rosszurowski
rosszurowski / lerp-color.js
Last active January 28, 2025 16:38
Linear interpolation for hexadecimal colors.
/**
* A linear interpolator for hexadecimal colors
* @param {String} a
* @param {String} b
* @param {Number} amount
* @example
* // returns #7F7F7F
* lerpColor('#000000', '#ffffff', 0.5)
* @returns {String}
*/