Skip to content

Instantly share code, notes, and snippets.

@nickfogle
nickfogle / custom_hide.css
Created February 25, 2022 21:34
Hide Cancel Link
#ck-app .cancel-sub-link {
display: none;
}
@nickfogle
nickfogle / get_customer.py
Last active September 9, 2021 17:09
Get Stripe Customer - Example Python
import stripe
stripe.api_key = "sk_test_XXXXXXX"
# Pass customer email to API endpoint
customers = stripe.Customer.list(email='customer@email.com')
print(customers)
print([cus.id for cus in customers.data])
# take cus.id and pass as CUSTOMER_ID in hmac function here https://gist.github.com/nickfogle/82dba67f7e1f730ca2f147a263e35508
@nickfogle
nickfogle / hmac_python.py
Created September 9, 2021 17:02
Sample HMAC Hash Function
import hmac
import hashlib
email_hash = hmac.new(
API_KEY, # Your API Key (keep safe)
CUSTOMER_ID, # Stripe Customer ID
digestmod=hashlib.sha256
).hexdigest() # Send to front-end
@nickfogle
nickfogle / handleCustomFlow.js
Created July 21, 2021 17:16
Churnkey Sample Code for Vue.js Implementation
import moment from 'moment';
import { Notification } from 'element-ui';
import UserService from '@/api/user.service';
import { IS_PRODUCTION } from '@/config';
import store from '@/store';
export default async function launchChurnkey(user) {
const customerId = user.stripe.id;
try {
const { authHash } = await UserService.getChurnKeyHash(customerId);
@nickfogle
nickfogle / launch-churnkey.vue
Created July 21, 2021 17:03
Churnkey vue.js sample template
<template>
<div>
<h1>Click to launch Churnkey</h1>
<!-- show button if user can cancel and loading finished -->
<div>
<button id="ck-cancel" @click="cancelFlow()" v-if="user.canCancel && !isLoading">Cancel</el-button>
</div>
</template>
<script>
@nickfogle
nickfogle / loadChurnkey.js
Created July 21, 2021 16:53
Load 3rd party Churnkey script
export default function loadChurnKey() {
if (!window.churnkey || !window.churnkey.created) {
window.churnkey = { created: true };
const a = document.createElement('script');
a.src = 'https://assets.churnkey.co/js/app.js';
a.async = true;
const b = document.getElementsByTagName('script')[0];
b.parentNode.insertBefore(a, b);
}
}
const crypto = require("crypto");
const user_hash = crypto.createHmac(
"sha256",
"CK_SECRET" // API KEY
).update(req.user.stripeId).digest("hex"); // Send to front-end
@nickfogle
nickfogle / snippet.html
Created February 12, 2019 02:44
Lightning Link Example
<div class="order-pr--value">
<span>lntb17u1pwxyvjzpp553g62xe3vywy6ep7lunyjjpk8l020gyh4j0xkm409yyty9sfu7zsdpzxysy2umswfjhxum0yppk76twypgxzmnwvycqp2dufsu4kt6th9vdnq7j788dulp42250nz5aanc3eyucchaatlur2j5tvy6clktdeutwqujud0zlkwkzv0gxedp3cg2fepzax9qtve8hcqumfhg2</span></div>
<!-- NOTICE FORMAT OF HREF -->
<!-- 'lightning:lnxxxxx' -->
<a href="lightning:lntb17u1pwxyvjzpp553g62xe3vywy6ep7lunyjjpk8l020gyh4j0xkm409yyty9sfu7zsdpzxysy2umswfjhxum0yppk76twypgxzmnwvycqp2dufsu4kt6th9vdnq7j788dulp42250nz5aanc3eyucchaatlur2j5tvy6clktdeutwqujud0zlkwkzv0gxedp3cg2fepzax9qtve8hcqumfhg2" target="_blank" class="button ocher">Open with your wallet</a>
<button type="button" title="Copy to clipboard" class="button copy ocher">
<svg width="10" height="10" aria-label="Copy" class="svg-icon lg undefined">
<title>Copy</title>
<use xlink:href="#icon_copy"></use>
</svg>
@nickfogle
nickfogle / Iridium-Modem.md
Created October 13, 2018 18:50
Iridium Modem and Attention Code Cheatsheet

Project Overview

Hardware

RockBlock uses an Iridium 9602 SBD Transceiver. The 9602 only supports short burst data.

Goal

Broadcast bitcoin transaction from a remote location. (a) Split up the raw transaction to meet sbd limitations (b) Send each segment to a relay server (c) The relay server assembles the transaction chunks and pushes to BTC network

@nickfogle
nickfogle / Stats
Created September 11, 2018 17:58
Get Device Statistics
#!/bin/bash
# Collects system performance statistics such as CPU, memory, and disk
# usage as well as top processes ran by users.
#
# All size values are in KiB (memory, disk, etc).
# Takes these command line arguments:
# $1 - cpuThreshold in % of total across all CPUs. Default is provided in no-args option.