Skip to content

Instantly share code, notes, and snippets.

@mingrui
mingrui / SmoothFollow.cs
Last active July 28, 2017 02:13 — forked from Hamcha/SmoothFollow.cs
Stupid Unity scripts : "Smooth Follow" from Standard Assets With Angle Offset
using UnityEngine;
using System.Collections;
public class SmoothFollow : MonoBehaviour {
// The target we are following
public Transform target;
// The target angle offset, 180 is in front of the target, 0 is behind the target
public float angleOffset;
// The distance in the x-z plane to the target
@mingrui
mingrui / CleanupMissingScripts.cs
Created July 28, 2017 02:15
Unity Editor Script to help cleaning up missing script references on gameobjects
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class CleanupMissingScriptsHelper{
[MenuItem("Edit/Cleanup Missing Scripts")]
static void CleanupMissingScripts() {
for (int i = 0; i < Selection.gameObjects.Length; i++) {
var gameObject = Selection.gameObjects[i];
@mingrui
mingrui / abc_test.py
Created February 13, 2018 16:06
testing abc
import abc
#class Base1(metaclass=abc.ABCMeta):
class Base1():
class_variable_one = 0
@abc.abstractmethod
def test_func(self):
pass
Verifying my Blockstack ID is secured with the address 16kTL3Le9AAX8A2nc4oUZ7VKVb5G4DKPHG https://explorer.blockstack.org/address/16kTL3Le9AAX8A2nc4oUZ7VKVb5G4DKPHG
@mingrui
mingrui / gist:187f0e629007443268ce8c1414012ed5
Created April 29, 2018 14:42
docker-ce : Depends: libseccomp2 (>= 2.3.0) but 2.2.3-3ubuntu3 is to be installed
When installing latest docker-ec 18, I encountered libseccomp2 version problem
https://www.ubuntuupdates.org/ppa/ubuntu_sdk_release?dist=xenial
add this to update libseccomp2
then install docker-ce
class DICELossMultiClass(nn.Module):
def __init__(self):
super(DICELossMultiClass, self).__init__()
def forward(self, output, mask):
probs = output[:, 1, :, :]
mask = torch.squeeze(mask, 1)
@mingrui
mingrui / test_dice.py
Created May 18, 2018 09:40
test dice
# source: https://github.com/shreyaspadhy/UNet-Zoo
def test(train_accuracy=False, save_output=False):
test_loss = 0
correct = 0
if train_accuracy:
loader = train_loader
else:
loader = test_loader

total: 64000 cny

config:
gtx 1080 ti * 4
server motherboard with dual cpu slot * 1
cpu * 2
ram 128gb * 1
hhd 10tb * 1
server case * 1
power supply * 1

@mingrui
mingrui / pre-commit
Created July 5, 2018 05:57
pre commit hook for git secret
#!/bin/sh
echo "# git secret hide!"
exec git secret hide
@mingrui
mingrui / load_async.py
Created August 9, 2018 10:45
slide runner map_async load test
def load_async(arg):
print('load_async')
tick = time.time()
filename, reader_location, level, reader_size, location, size = arg
slide = openslide.open_slide(filename)
region = slide.read_region(location=reader_location, level=level, size=reader_size)
# Convert to numpy array
cachedImage = np.array(region, dtype=np.uint8)