Skip to content

Instantly share code, notes, and snippets.

@mingfang
mingfang / skopeo-sync.sh
Last active January 23, 2024 15:19
Use skopeo to sync all images across private Docker registries
View skopeo-sync.sh
export SRC="10.0.4.5:5000"
export DEST="10.0.4.5:6000"
curl -s http://${SRC}/v2/_catalog | jq .repositories[] | xargs -I {} \
skopeo sync \
--src-tls-verify=false --src docker --src-creds ${DOCKER_USER}:${DOCKER_PASS} \
--dest-tls-verify=false --dest docker --dest-creds ${DOCKER_USER}:${DOCKER_PASS} \
${SRC}/{} ${DEST}
@mingfang
mingfang / ReactAdapter.svelte
Last active August 9, 2023 18:58
Svelte component to use React components
View ReactAdapter.svelte
<script>
import {onDestroy, onMount} from "svelte"
export let component
let container
let root
onMount(async ()=> {
const {createRoot} = await import('react-dom/client')
const {createElement} = await import('react')
@mingfang
mingfang / gist:689258d4499d3aeb7ed174fdfc8d9521
Created September 27, 2020 03:17
Set Devialet Speakers to Optical Direct Mode
View gist:689258d4499d3aeb7ed174fdfc8d9521
volume=70
speakers="192.168.2.103 192.168.2.60"
for host in $speakers; do
echo $host
# enable optical direct mode
curl -s http://$host/opticaldirect/enabled -XPOST
# name must be Left or Right
curl -s http://$host/device/name | jq .
role=$(curl -s http://$host/device/name | jq -r .data.name)
curl -s http://$host/opticaldirect/role -d "{\"role\":\"Front$role\"}" -H "Content-Type: application/json"
@mingfang
mingfang / phoenix_live_view_example-devfile.yaml
Last active March 9, 2020 03:27
Run phoenix_live_view_example in Eclipse Che
View phoenix_live_view_example-devfile.yaml
metadata:
name: phoenix_live_view_example
projects:
- name: phoenix_live_view_example
source:
location: 'https://github.com/chrismccord/phoenix_live_view_example.git'
type: git
branch: master
components:
- mountSources: true
View devfile.yaml
apiVersion: 1.0.0
metadata:
name: terraform-provider-k8s
projects:
- name: terraform-provider-k8s
source:
location: 'https://github.com/mingfang/terraform-provider-k8s.git'
type: git
clonePath: src/github.com/mingfang/terraform-provider-k8s/
- name: terraform-k8s-modules
@mingfang
mingfang / shell.go
Created November 10, 2019 04:12
Cadence activity to execute shell commands
View shell.go
package main
import (
"context"
"flag"
"os"
"os/exec"
"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
"go.uber.org/cadence/activity"
View Alluxio.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mingfang
mingfang / screensaver.sh
Created August 31, 2017 05:22
script to turn off and on Raspberry Pi Display by detecting IP or bluetooth device
View screensaver.sh
#!/bin/bash
while true
do
if ping -c 1 -w 3 192.168.2.67 &> /dev/null || hcitool scan | grep -q -E "ming-macbook|Ming's iPhone" ; then
echo "welcome back. turning screen on"
echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
else
echo "you're gone. turning screen off"
echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
@mingfang
mingfang / pgcalc.sh
Created August 31, 2017 04:01
script to calculate ceph pg number
View pgcalc.sh
#!/bin/bash
#Computes the suggested PG count similar to this http://ceph.com/pgcalc/
#Reguirements:
# - must run on ceph admin
# - depends on awk, wc and bc commands
#Limitations:
# - Assumes same OSD# for all pools
@mingfang
mingfang / gulpfile.js
Created March 9, 2016 16:00
gulpfile.js
View gulpfile.js
// DO NOT CHANGE //
const gulp = require('gulp');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const gwebpack = require('webpack-stream');
const browserSync = require('browser-sync');
const runSequence = require('run-sequence');
const debug = require('gulp-debug');
const cache = require('gulp-cached');