Skip to content

Instantly share code, notes, and snippets.

View linw1995's full-sized avatar
🎯
Focusing

林玮 (Jade Lin) linw1995

🎯
Focusing
View GitHub Profile
@linw1995
linw1995 / main.scpt
Created October 17, 2024 02:46
AppleScript to get wifi info
use AppleScript version "2.8" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "CoreWLAN"
use scripting additions
set wifiInterface to current application's CWInterface's interfaceWithName:"en0"
-- Require location permission granted
-- Print the entire object
log quoted form of (wifiInterface's interfaceName as string)
@linw1995
linw1995 / Dockerfile
Last active October 11, 2024 06:26
Use Docker or nix to build vector.
ARG RUST_VERSION=1.79.0
FROM rust:${RUST_VERSION}-alpine AS base
RUN apk add --no-cache musl-dev
WORKDIR /workspace
FROM base AS cargo-cross
RUN --mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/cache \
--mount=type=cache,target=/usr/local/cargo/registry/index \
@linw1995
linw1995 / README.md
Created August 18, 2024 13:30
An example of rust dev-container for cross compiling on remote docker.

This currently supports vector development.

@linw1995
linw1995 / clip_magic.py
Created March 29, 2022 07:24
IPython magic for copying into clipboard in zsh shell on macOS.
from IPython.core.magic import needs_local_scope, register_line_magic
@register_line_magic
@needs_local_scope
def clip(line, local_ns):
import json
import os
import subprocess

Usage

python tailwind_auto_prefix.py <tailwind_template.html
@linw1995
linw1995 / main.go
Created October 14, 2021 13:46
json.Unmarshal can parse null into empty array
package main
import (
"fmt"
"encoding/json"
)
func main() {
var (
lst []string
@linw1995
linw1995 / main.py
Created October 14, 2021 13:44
Use sshfs to mount directory of MacOS into podman machine.
"""
https://github.com/containers/podman/issues/8016#issuecomment-920015800
"""
import getpass
import os
import re
import shlex
import subprocess
from pathlib import Path
@linw1995
linw1995 / go.mod
Last active September 7, 2021 03:00
Get keyValue history of ETCD in golang.
module github.com/linw1995/etcd_learning
go 1.16
replace (
github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.6
google.golang.org/grpc => google.golang.org/grpc v1.26.0
)
require (
@linw1995
linw1995 / day.go
Created August 27, 2021 02:37
get begin time and end time in Golang.
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now()
fmt.Println(
@linw1995
linw1995 / csv.go
Created August 20, 2021 09:54
Golang read csv data row into struct
package main
import (
"bytes"
"encoding/csv"
"fmt"
"io"
"reflect"
)