Skip to content

Instantly share code, notes, and snippets.

@youwen21
youwen21 / getfreeport.go
Created August 21, 2024 22:53 — forked from sevkin/getfreeport.go
get free port in golang
// GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreePort() (port int, err error) {
var a *net.TCPAddr
if a, err = net.ResolveTCPAddr("tcp", "localhost:0"); err == nil {
var l *net.TCPListener
if l, err = net.ListenTCP("tcp", a); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
}
@youwen21
youwen21 / HOWTODMG.md
Created May 26, 2024 22:57 — forked from jadeatucker/HOWTODMG.md
How to create a "DMG Installer" for Mac OS X

Creating a "DMG installer" for OS X

A DMG Installer is convenient way to provide end-users a simple way to install an application bundle. They are basically a folder with a shortcut to the Applications directory but they can be customized with icons, backgrounds, and layout properties. A DMG file (.dmg) is a Mac OS X Disk Image file and it is used to package files or folders providing compression, encryption, and read-only to the package.

##Creating the DMG file #Disk Utility

@youwen21
youwen21 / README.md
Created March 26, 2024 22:04 — forked from denilsonsa/README.md
Embed VTT subtitles into HTML

Objective

I have a video file on my local disk. I also have some subtitles (in HTML5's [WebVTT][] format).

I want to create an HTML file to play that video with subtitles, all from the local filesystem.

Problem

Loading an external VTT file from the local filesystem [fails due to same-origin policy][q].

@youwen21
youwen21 / create_init_sql.sh
Created December 26, 2018 07:11
a script use to recover data from innodb's frm and ibd file.
#!/bin/bash
#
# File: create_init_sql.sh
#
# Author: huxing1985@gmail.com
# blog: www.colorfuldays.org
#
# Purpose: This script is a part of an tool to recover mysql data from .frm and .idb file.
# This script is read the db data dir's file, generate an script to create the tables.
#