Skip to content

Instantly share code, notes, and snippets.

@mrubiosan
mrubiosan / net.reconnect.ts
Created November 18, 2019 04:34
Nodejs Socket wrapper for auto-reconnection
import Timeout = NodeJS.Timeout;
import { Socket, NetConnectOpts } from "net";
function attachReconnectOnError(socket: Socket, options: NetConnectOpts, retryMs: number): void {
let timerId: Timeout | null;
const clear = () => {
if (timerId !== null) {
clearTimeout(timerId);
timerId = null;
}
@mrubiosan
mrubiosan / stripe_copy.php
Created December 13, 2018 05:36
Migrate Stripe Products and Plans
<?php
$fromToken = 'rk_live_abc';
$toToken = 'rk_test_def';
$prodContext = stream_context_create([
'http' => [
'header' => "Authorization: Bearer $fromToken\r\n"
]
]);
$testContext = stream_context_create([