Skip to content

Instantly share code, notes, and snippets.

View mechinn's full-sized avatar

Michael Chinn mechinn

View GitHub Profile
public class Hello {
public static void main(String[] args) {
//for each word in args
for(String word : args) {
//print the word on the same line with a space after
System.out.print(word+" ");
}
//print a newline
System.out.println();
}
@mechinn
mechinn / clever.py
Created May 29, 2013 22:28
Playing with the Clever API, it gives the average number of students per section
import requests
def get_error_code(x):
return {
400: 'Bad Request',
401: 'Unauthorized. Bad API key or not authorized to access a resource.',
404: 'Not found. The resource requested doesn\'t exist.',
500: 'Server errors. Oops!',
}.get(x, 'Error')
@mechinn
mechinn / cloud-config.yaml
Created October 5, 2017 02:47
rancherOS cloud-config
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDITaFsj93N0j8Z7i9NyI4V3xS+NBGkAMzyzdA6vw6Wn5IKazEo/rQBKTtk4EzDynTJ7WA2fYUVVxeGXmFPYifrZ6jyc6NWfnkOQdASqSBlYbigStviKpUYN+zpf8fKlqXgA7Xs70mEcFOCi3y8VVFxTp7Uq7t7e51MqkNo7eOSGuRI3GrLUEgVaHe0AopFxEFy9d38619AmKPckWZaTpju7mIWWQZv6c/k/aLDNcviYMtE8fK0gnC8mrXsg0dmxKeXiedyIRqekLiGs67BPNkhT659Klimi7WEHViidTsPF7e6CpNar8D5oIlqoGBV97+5RHPUtj6rdwsyG3iqMBkCaneGCOK9hUrNZI2wPAIfSt6vrZHkIKfSbp2w5GSwxIi4TyqMebqqfDnGhj8VK5DlxA0i/spNjjLwM6nCvgiwnYxeINEh/rhqGocEewKpzMNPmOeYxPTNp4bwbT7b1ZvLvUiDYDi1bSxOJ+8Wiood4AGZjI60kCLrMNRqQnZBREpYehczv3zEh2K2I1Jog6dX0022hVvLYSrIStwAkB9EtPpb2l1kEazC8U07lvP84HIRkoX3Zy3KX4o+DeV1dlhb44OVJcw1WYtznoS1HEq9LbzgHbnccLTjEdZ9/8qLiCsnLvoyEwWsfEyRz20lRTNlC4gGZ/Ua3W9+h4GIk+5Nvw== mechinn-macbook
hostname: rancher
@mechinn
mechinn / keybase.md
Created April 26, 2019 03:46
keybase.md

Keybase proof

I hereby claim:

  • I am mechinn on github.
  • I am mechinn (https://keybase.io/mechinn) on keybase.
  • I have a public key ASBY5AHGAkHPb98koLUQbMvnU6wLKGnhpZDv47BGWasipgo

To claim this, I am signing this object:

package main
import (
"archive/tar"
"compress/gzip"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
@mechinn
mechinn / img2zvol.sh
Last active April 5, 2023 03:28
bash script that will use qemu-img read the "virtual-size" of an image, create a zvol of the full size, and convert the file to the zvol
#!/bin/bash -x
file=$1
destination=$2
size=$(qemu-img info $file --output json | jq '."virtual-size"')
zfs create -V $size $destination
qemu-img convert -O raw $file /dev/zvol/$destination
@mechinn
mechinn / 0 tailscaled
Last active August 14, 2024 02:00
Tailscale batocera service
#!/bin/bash
set -a
source /userdata/tailscale/systemd/tailscaled.defaults
set +a
command="/userdata/tailscale/tailscaled"
command_args="--state /userdata/tailscale/state/tailscaled.state --port=${PORT} --socket=/var/run/tailscale/tailscaled.sock $FLAGS"
command_background=true
pidfile="/run/tailscaled.pid"