Skip to content

Instantly share code, notes, and snippets.

View khirvy019's full-sized avatar

Jeff Kyell Sarmen khirvy019

  • SciBiz Informatics
  • Tacloban City, Philippines
View GitHub Profile
@khirvy019
khirvy019 / escrow-v2.cash
Created November 21, 2023 02:55
Escrow Contract V2 for commerce-hub
View escrow-v2.cash
// pragma cashscript ^0.7.5;
pragma cashscript ^0.8.0;
contract Escrow(
bytes20 buyer, // 20 B
bytes20 seller, // 20 B
bytes20 servicer, // 20 B
bytes20 arbiter, // 20 B
bytes deliveryFeePool, // 23 B
@khirvy019
khirvy019 / chat-app.vue
Created September 27, 2023 00:24
WebRTC Example in VueJS
View chat-app.vue
<template>
<div id="app-container" :class="[darkMode ? 'text-white pt-dark' : 'text-black']">
<HeaderNav
title="WebRTC Audio Call"
backnavpath="/apps"
/>
<div class="q-mx-md">Local peer id: {{ localPeerId }}</div>
<div class="q-mx-md row items-center">
<q-toggle
:model-value="darkMode"
@khirvy019
khirvy019 / escrow.cash
Last active July 4, 2023 00:46
Escrow Contract
View escrow.cash
// pragma cashscript ^0.7.5;
pragma cashscript ^0.8.0;
contract Escrow(
bytes20 buyer, // 20 B
bytes20 seller, // 20 B
bytes20 servicer, // 20 B
bytes20 arbiter, // 20 B
bytes deliveryFeePool, // 23 B
@khirvy019
khirvy019 / 1.json
Created May 31, 2023 06:36
Cashtoken test nft metadata
View 1.json
{
"name": "Test Raccoon NFT #1",
"description": "Raccoon NFT. For testing purposes",
"uris": {
"image": "https://images.watchtower.cash/32ba95aef37a41659876064bc4e598e6c788b62b854a9082d211b70fb9fb577f_thumbnail.png"
},
"extensions": {
"attributes": {
"Background": "Green",
"Fur": "Red",
@khirvy019
khirvy019 / aerial_distance.py
Last active May 22, 2023 00:06
Annotating distance of each row in queryset between a reference coordinate
View aerial_distance.py
from math import sin, cos, sqrt, atan2, radians
# Test function
def aerial_distance(origin, destination):
# approximate radius of earth in m
R = 6373000.0
if isinstance(origin, dict):
origin = [origin.get('lat'), origin.get('lng')]
elif isinstance(origin, str):
origin = origin.split(",", 1)
@khirvy019
khirvy019 / reverse_relation.py
Last active May 18, 2023 02:19
Functions for concerning checking reverse relations. Example use case is pruning instances of model
View reverse_relation.py
import inspect
from django.db.models import Q, QuerySet
from django.db.models import Model, OneToOneRel, ForeignKey, ManyToManyRel
from django.db.models.fields.related_descriptors import (
ReverseOneToOneDescriptor,
ReverseManyToOneDescriptor,
ManyToManyDescriptor
)
def get_reverse_relations(value):
@khirvy019
khirvy019 / aerial_distance.py
Created May 9, 2023 05:27
Returns approximate distance from origin to destination in a straight line in meters
View aerial_distance.py
from math import sin, cos, sqrt, atan2, radians
def aerial_distance(self, origin, destination):
# approximate radius of earth in m
R = 6373000.0
if isinstance(origin, dict):
origin = [origin.get('lat'), origin.get('lng')]
elif isinstance(origin, str):
origin = origin.split(",", 1)
View Anyhedge.md

Anyhedge formulas

SATS_PER_BCH = 10 ** 8
long_bch = 0.00999985
hedge_bch = 0.03081633

low_liquidation_mult = 0.755
high_liquidation_mult = 5
start_price = 10294
@khirvy019
khirvy019 / paymentrequest.proto
Created December 15, 2022 03:49
JPP protobuf
View paymentrequest.proto
// source: https://github.com/Electron-Cash/Electron-Cash/blob/master/electroncash/paymentrequest.proto
//
// Simple Bitcoin Payment Protocol messages
//
// Use fields 1000+ for extensions;
// to avoid conflicts, register extensions via pull-req at
// https://github.com/bitcoin/bips/bip-0070/extensions.mediawiki
//
@khirvy019
khirvy019 / aes.js
Created December 2, 2022 06:35
aes-256-cbc encryption & decryption
View aes.js
import * as crypto from 'crypto'
export const aes = {
generateKey() {
return {
password: crypto.randomBytes(16).toString('hex'),
iv: crypto.randomBytes(8).toString('hex'),
}
},
encrypt(data, password, iv) {