Skip to content

Instantly share code, notes, and snippets.

@hellojukay
hellojukay / tomp3.go
Last active December 5, 2022 03:12
转化 wma 格式音频文件为 mp3 格式
package main
import (
"flag"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
@hellojukay
hellojukay / download
Last active February 9, 2023 09:29
下载 m3u8 电视剧
#!/usr/bin/env python
import sys
import os
import re
data = sys.stdin.readlines()
for line in data:
url,name = re.compile("[\s\t]+").split(line.rstrip())
# https://github.com/oopsguy/m3u8 使用这个 golang 写的小工具来下载 m3u8 链接
@hellojukay
hellojukay / git-open
Last active December 8, 2021 02:42
通过命令行在浏览器中打开当前仓库
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
GetOptions("p|pipeline" => \(my $pipeline),
"h|help" => \(my $help));
sub usage($) {
@hellojukay
hellojukay / proxy_server.go
Last active May 12, 2022 08:39
A http(s) proxy server
package main
import (
"bytes"
"fmt"
"io"
"log"
"net"
"regexp"
"strings"
let () =
let sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
let address = Unix.inet_addr_of_string "127.0.0.1" in
let socket_address = Unix.ADDR_INET (address, 22) in
Unix.connect sock socket_address;
let buffer = Bytes.create 1024 in
let len = Unix.read sock buffer 0 (Bytes.length buffer) in
Printf.printf "%d %s" len (Bytes.to_string buffer)
@hellojukay
hellojukay / list.go
Created August 14, 2021 03:56
Use golang to implement linked list in functional style
package main
type Node struct {
Val int
Next interface{}
}
func create() interface{} {
return nil
}
@hellojukay
hellojukay / ocaml_color.ml
Last active August 14, 2021 03:57
OCaml print with color
module Log = struct
type color = Black | Red | Green | Yellow | Blue | Magenta | Cyan | White
let log_with_color c text =
match c with
| Black -> Printf.printf "\027[38;5;%dm%s\027[0m" 0 text
| Red -> Printf.printf "\027[38;5;%dm%s\027[0m" 1 text
| Green -> Printf.printf "\027[38;5;%dm%s\027[0m" 2 text
| Yellow -> Printf.printf "\027[38;5;%dm%s\027[0m" 3 text
| Blue -> Printf.printf "\027[38;5;%dm%s\027[0m" 4 text
@hellojukay
hellojukay / progress.ml
Created June 27, 2021 07:04
progress bar write in Ocaml
;;
#load "unix.cma"
let rec repeat str n =
match n with 0 -> str | 1 -> str | n -> str ^ repeat str (n - 1)
let () =
let sum = ref 1 in
while true do
Printf.printf "[%d%%]%s" !sum (repeat "#" !sum);
@hellojukay
hellojukay / perl_modules.pl
Created June 2, 2021 10:43
perl list installed modules
#!/usr/bin/env perl
sub find_modules {
my $dir = shift;
my @modules = ();
if(-d $dir){
chdir $dir;
my @files = glob "**/*.pm";
foreach (@files) {
$_ =~ s/$\.pm//g;
@hellojukay
hellojukay / Certificates.go
Created August 27, 2020 10:18 — forked from Mattemagikern/Certificates.go
Create x509 certificate chain using Golang. Root CA, Designated CA, server CA
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"math/big"