Skip to content

Instantly share code, notes, and snippets.

View XSAM's full-sized avatar

Sam Xie XSAM

  • Cisco/AppDynamics
View GitHub Profile
@XSAM
XSAM / main.py
Last active July 17, 2021 10:52
Py image
from PIL import Image
from PIL.ExifTags import TAGS
# read the image data using PIL
# A image that should be read.
# 300*200
image = Image.open("sample.png")
exifdata = image.getexif()
# Move iterator.
# Virtual memory won't impact this.
# 600 pixels.
@XSAM
XSAM / cipher.py
Last active July 10, 2021 12:44
1Key
import base64
import getpass
from cryptography.fernet import Fernet
BLOCK_SIZE = 32
# the character used for padding--with a block cipher such as AES, the value
# you encrypt must be a multiple of BLOCK_SIZE in length. This character is
# used to ensure that your value is always a multiple of BLOCK_SIZE
PADDING = b'{'
cd $GOPATH/src
mkdir -p github.com/vektra && cd github.com/vektra && git clone https://github.com/corentone/mockery.git
cd mockery && git checkout in-place-differentfolder && make install
# Test
cd $GOPATH/src
mkdir JyBP
git clone https://github.com/JyBP/keeptree.git && cd keeptree
mockery -all -keeptree -output ./cmd/mocks -dir ./
@XSAM
XSAM / cVimrc
Last active November 19, 2019 05:10
cVim config
set smoothscroll
let scrollstep = 100
let blacklists = ["https://aidn.jp/*","https://patatap.com/*","https://typatone.com/*"]
@XSAM
XSAM / dump_socket.sh
Created March 15, 2018 08:16 — forked from jhass/dump_socket.sh
Capture unix socket to pcap file with socat and tshark
#!/bin/bash
# Parameters
socket="/run/foo.sock"
dump="/tmp/capture.pcap"
# Extract repetition
port=9876
source_socket="$(dirname "${socket}")/$(basename "${socket}").orig"
@XSAM
XSAM / ingress-rbac.yaml
Last active December 19, 2019 13:10
Traefik In Kubernetes Ingress Sample
apiVersion: v1
kind: ServiceAccount
metadata:
name: ingress
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: ingress
subjects:
@XSAM
XSAM / MaterialColor.json
Created April 19, 2017 16:20
Material Design Color Json
{
"MaterialColor":[
{ "ColorName":"Red 50", "ColorValue": "#FFEBEE" },
{ "ColorName":"Red 100", "ColorValue": "#FFCDD2" },
{ "ColorName":"Red 200", "ColorValue": "#EF9A9A" },
{ "ColorName":"Red 300", "ColorValue": "#E57373" },
{ "ColorName":"Red 400", "ColorValue": "#EF5350" },
{ "ColorName":"Red 500", "ColorValue": "#F44336" },
{ "ColorName":"Red 600", "ColorValue": "#E53935" },
{ "ColorName":"Red 700", "ColorValue": "#D32F2F" },
@XSAM
XSAM / Play&Pause
Last active May 8, 2023 12:36
Control Netease Music via AppleScript
tell application "System Events" to tell process "NeteaseMusic"
tell menu bar 1
tell menu bar item "Controls"
tell menu 1
if menu item "Play" exists then
click menu item "Play"
display notification "Play Music" with title "NeteaseMusic"
else
click menu item "Pause"
display notification "Pause Music" with title "NeteaseMusic"