Skip to content

Instantly share code, notes, and snippets.

View shsteven's full-sized avatar

Steven Zhang shsteven

View GitHub Profile
# See https://askubuntu.com/questions/440821/execute-script-when-disk-space-is-low
@daily sh -c "if [ $(df / --output='pcent' | grep -o "[0-9]*") -gt 90 ]; then docker system prune -af; fi
@shsteven
shsteven / find-youtube-channel-id.md
Created July 31, 2022 15:06
How to find Youtube channel ID

Find text like this in the HTML:

<link rel="alternate" href="ios-app://">

The channel ID is in the href.

@shsteven
shsteven / raspbian-docker.md
Last active May 8, 2022 08:31
Preparing a Raspberry Pi with Raspbian and Docker
@shsteven
shsteven / dump-dimensions.txt
Created September 2, 2020 11:13
Dump All Image Dimensions to a Text File
find . -type f -print0 | sort -z | xargs -0 identify -format '%t %w %h\n' > ../images-dimension.txt
@shsteven
shsteven / UIView+AutoLayout.swift
Created June 10, 2020 02:38 — forked from danielgalasko/UIView+AutoLayout.swift
A UIView extension for common auto layout constraints
import UIKit
extension UIView {
func addConstaintsToPinHorizontalEdgesToSuperView(padding: CGFloat = 0) {
prepareForConstraints()
self.superview!.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-(padding)-[view]-(padding)-|",
options: [],
metrics: ["padding":padding],
views: ["view":self]))
}
@shsteven
shsteven / Dockerfile.forego-builder
Last active March 10, 2020 02:02
Forego using Docker Multistage Builder
from golang:buster as builder
RUN go get github.com/ddollar/forego
WORKDIR src/github.com/ddollar/forego
RUN go build
from debian:buster
COPY --from=builder /go/src/github.com/ddollar/forego/forego /usr/local/bin/forego
CMD ["forego"]
@shsteven
shsteven / Cron.txt
Created December 12, 2019 00:48
Cron job to purge docker images every day at 1am, if disk usage is over 80%
0 1 * * * df -Ph / | grep root | awk '{ if($5 > 80) print $0;}' | docker image prune -f
@shsteven
shsteven / user-data-wifi.yml
Last active April 16, 2019 03:23 — forked from DieterReuter/user-data-wifi.yml
HypriotOS cloud-init configuration for RPi3 WiFi Client
#cloud-config
# vim: syntax=yaml
#
# The current version of cloud-init in the Hypriot rpi-64 is 0.7.9
# When dealing with cloud-init, it is SUPER important to know the version
# I have wasted many hours creating servers to find out the module I was trying to use wasn't in the cloud-init version I had
# Documentation: http://cloudinit.readthedocs.io/en/0.7.9/index.html
# Set your hostname here, the manage_etc_hosts will update the hosts file entries as well
@shsteven
shsteven / simd+ext.swift
Created December 10, 2018 05:30 — forked from codelynx/simd+ext.swift
swift: float4x4 extension to scale, rotate, translate 4x4 matrix
//
// simd+ext.swift
//
// Created by Kaz Yoshikawa on 11/6/15.
//
//
import Foundation
import simd
import GLKit
@shsteven
shsteven / GPUImage3.podspec
Last active August 3, 2021 09:15
Podspec for GPUImage3
Pod::Spec.new do |s|
s.name = 'GPUImage3'
s.version = '0.1.0'
s.license = 'BSD'
s.summary = 'An open source iOS framework for GPU-based image and video processing.'
s.homepage = 'https://github.com/BradLarson/GPUImage3'
s.author = { 'Brad Larson' => 'contact@sunsetlakesoftware.com' }
# This commit on that fork of GPUImage should contain just upgrades needed for Swift 4 compatibility. See https://github.com/BradLarson/GPUImage2/pull/212
# Replace with https://github.com/BradLarson/GPUImage2.git when merged