Skip to content

Instantly share code, notes, and snippets.

View geyang's full-sized avatar
🤖
I finish papers.

Ge Yang geyang

🤖
I finish papers.
View GitHub Profile
@geyang
geyang / shared folder logging setup.md
Last active June 30, 2019 19:51
How to setup shared folder writing with ml-logger.md

firs create a group, add users to that group se the folder to this group, recursively if this takes too long, use glob patterns to select the top k-levels

  1. sudo chgrp -R /checkpoint/geyang
  2. sudo chmod -R 2777 /checkpoint/geyang
  3. when running logger, use umask 0 to make sure all files are written with 777 permission.

For all instances writing, really need to umask 0 to make sure that files are writable from multible accounds. For exisiting files written by different user accounts, use chmod -R 2777 to amend the permissions.

#!/bin/bash
echo "Restarting bluetooth service..."
blueutil -p 0 && sleep 1 && blueutil -p 1
echo "Waiting bluetooth service to be restored..."
until blueutil -p | grep "1" >/dev/null; do sleep 1; done
echo "Searching for devices not connected..."
devices=($(blueutil --paired | grep "not connected" | awk -F '[ ,]' '{print $2}'))
@geyang
geyang / transformer.py
Last active March 13, 2020 00:47
quick sketch of a transformer layer.
class MultiHeadedMlp(nn.Module):
def __init__(self, input_dim, *out_dims):
super().__init__()
self.out_dims = out_dims
self.heads = nn.ModuleList([nn.Linear(input_dim, dim) for dim in out_dims])
def forward(self, i):
return [h(i) for h in self.heads]
@geyang
geyang / mac_vanilla.diff
Created May 13, 2020 00:02
diff for the mac implementation
diff --git a/mac/mac_vanilla.py b/mac/mac_vanilla.py
index 1565db7..28d5970 100644
--- a/mac/mac_vanilla.py
+++ b/mac/mac_vanilla.py
@@ -1,3 +1,5 @@
+from copy import deepcopy
+
import torch
from torch import nn
from torch import optim
@geyang
geyang / iterm.bash
Created July 14, 2020 01:48
bash function for opening up iterm form current directory
#!/usr/bin/env bash
#
# Open new iTerm window from the command line using v3 syntax for applescript as needed in iTerm2 Version 3+
# This script blocks until the cmd is executed in the new iTerm2 window. It then leaves the window open.
# TODO Add option to close iTerm2 after cmd execs
# See also https://www.iterm2.com/documentation-scripting.html
#
# Usage:
@geyang
geyang / crop_image.bash
Created July 15, 2020 05:33
use ffmpeg to crop mp4 files
ffmpeg -i input.mp4 -filter:v "crop=674:64:0:0" output.mp4
@geyang
geyang / README.md
Last active August 26, 2020 19:49
CommonMark-X Landmark Example

Example for Rendering the Landmarks

@geyang
geyang / instrumentation server setup script
Created September 6, 2020 03:49
ML-Dash and ML-Logger Setup Script
1 df
2 ls /dev/sdh
3 cd /dev/sdh
4 sudo mount /dev/sdb1 ~/runs
5 mkdir runs
6 sudo mount /dev/sdb1 ~/runs
7 sudo mount /dev/sh~/runs
8 sudo mount /dev/sdh ~/runs
9 ls
10 cd runs
@geyang
geyang / watch.py
Created December 10, 2020 04:31
Watch script
import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')