Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* @return Generator
*/
function fib()
{
[$a, $b] = [0, 1];
while (true) {
yield $b;
[$a, $b] = [$b, $a + $b];
@jamesBan
jamesBan / main.go
Created June 19, 2021 02:59
分批执行
package main
import (
"fmt"
"sync"
"time"
)
const num = 10
func main() {
@jamesBan
jamesBan / go-context-cancel.go
Created June 19, 2021 03:08
context timeout routine泄漏问题
package main
import (
"fmt"
"golang.org/x/net/context"
"log"
"math/rand"
"runtime"
"time"
)
@jamesBan
jamesBan / check-ssl-expire.php
Created June 25, 2021 08:56
检查证书过期
<?php
function getSslExpireTime(string $url): int
{
if(!filter_var($url, FILTER_VALIDATE_URL)) {
throw new \RuntimeException('invalidate url:'.$url);
}
$domain = parse_url($url, PHP_URL_HOST);
$context = stream_context_create([
"ssl" => ["capture_peer_cert" => true]
@jamesBan
jamesBan / curl-resolve.php
Created August 10, 2021 10:00
指定域名对应ip请求
<?php
$data = [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RESOLVE, ['api.example.com:80:127.0.0.1']);
curl_setopt($ch, CURLOPT_PORT, 80);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
@jamesBan
jamesBan / Activate Office 2019 for macOS VoL.md
Created June 18, 2022 02:58 — forked from zthxxx/Activate Office 2019 for macOS VoL.md
crack activate office on mac with license file

Activate MS Office 2019/2016 for macOS - Microsoft_Office_2019_VL_Serializer

Office 2019 above

2019-06-03

Note that Office2019 DO NOT support activate via simple copy/paste plist license file which is the simplest way to activate Office 2016. Fortunately, you can also use the VL Serializer tool, just install Office 2019 and Serializer, then run Serializer to activate.

Ref