Skip to content

Instantly share code, notes, and snippets.

View kosuke-zhang's full-sized avatar

Kosuke kosuke-zhang

View GitHub Profile
@alimovlex
alimovlex / TCP_Communicator.swift
Last active June 9, 2023 21:50
The TCP connection demo for iOS
/*
* Copyright (C) 2023 Recompile.me.
* All rights reserved.
*/
class TCP_Communicator: NSObject, StreamDelegate {
var readStream: Unmanaged<CFReadStream>?
var writeStream: Unmanaged<CFWriteStream>?
var inputStream: InputStream?
@lhlyu
lhlyu / client.js
Last active February 2, 2023 08:21
微信小程序云开发 grpc simple & stream
// protoc ./*.proto --js_out=import_style=commonjs:./ --grpc-web_out=import_style=typescript,mode=grpcweb:./
var pb = require('./grpc_pb');
var svc = require('./grpc_grpc_pb');
var grpc = require('@grpc/grpc-js');
// 证书
const tls = `-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----`
@PierreJanineh
PierreJanineh / SocketDelegate.swift
Last active October 24, 2024 07:19
Connect to socket using Swift 5
protocol SocketDelegate: class {
/**
Called when `StreamDelegate` calls `stream(,eventCode)` with `.hasBytesAvailable` after all bytes have been read into a `Data` instance.
- Parameter result: `Data` result from InputStream.
*/
func socketDataReceived(result: Data?)
/**
Called when `StreamDelegate` calls `stream(,eventCode)` with `.hasBytesAvailable` after all bytes have been read into a `Data` instance and it was nil.
@larsneo
larsneo / viewer.html
Last active November 5, 2024 11:30 — forked from jsprpalm/viewer.html
Pinch zoom implementation for PDF.js viewer
<!-- Goes into viewer.html just before ending </body> -->
<script>
let pinchZoomEnabled = false;
function enablePinchZoom(pdfViewer) {
let startX = 0, startY = 0;
let initialPinchDistance = 0;
let pinchScale = 1;
const viewer = document.getElementById("viewer");
const container = document.getElementById("viewerContainer");
const reset = () => { startX = startY = initialPinchDistance = 0; pinchScale = 1; };
@pohzipohzi
pohzipohzi / walg-pitr.md
Last active April 25, 2023 15:47
PostgreSQL Point-In-Time-Recovery (PITR) with WAL-G

WAL-G PITR

This gist summarises a way to simulate point-in-time recovery (PITR) using WAL-G. Most of the material is adapted from Creston's tutorial.

Setup

First we initialize a database cluster

pg_ctl init -D cluster