Skip to content

Instantly share code, notes, and snippets.

View foreseaz's full-sized avatar
☁️

Chenxi Zh foreseaz

☁️
View GitHub Profile
@foreseaz
foreseaz / gist:3c5a33a54f965a1a35124990eda6c0e9
Created June 10, 2019 09:59
rename extension in folders
ren '*.com' '#1.jpg'
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && ren '*.com' '#1.jpg'" \;
@foreseaz
foreseaz / generator.go
Last active November 6, 2020 09:18
Go Patterns
package main
import "fmt"
func fib(n int) chan int {
out := make(chan int)
go func () {
defer close(out)
for i, j := 0, 1; i < n; i, j = i + j, i {
@foreseaz
foreseaz / main.go
Created November 7, 2020 16:06
Golang Subscriber Pattern
package main
import (
"time"
)
type Event struct {
data int
}
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
@foreseaz
foreseaz / r2.js
Last active March 20, 2023 07:12
Cloudflare R2 request with signature
var crypto = require("crypto-js");
var https = require("https");
var xml = require("xml2js");
main();
// split the code into a main function
function main() {
// this serviceList is unused right now, but may be used in future
const serviceList = ["dynamodb", "ec2", "sqs", "sns", "s3"];