Skip to content

Instantly share code, notes, and snippets.

View DavidYKay's full-sized avatar

David Young-Chan Kay DavidYKay

View GitHub Profile
@DavidYKay
DavidYKay / simple_cb.py
Last active June 26, 2023 00:52
Simple color balance algorithm using Python 2.7.8 and OpenCV 2.4.10. Ported from: http://www.morethantechnical.com/2015/01/14/simplest-color-balance-with-opencv-wcode/
import cv2
import math
import numpy as np
import sys
def apply_mask(matrix, mask, fill_value):
masked = np.ma.array(matrix, mask=mask, fill_value=fill_value)
return masked.filled()
def apply_threshold(matrix, low_value, high_value):
@DavidYKay
DavidYKay / Car.cpp
Created July 7, 2016 21:10
C++ Class / Header file example
#import "Car.h"
const int ACCELERATION_FACTOR = 10;
const int BRAKING_FACTOR = 30;
Car::Car() {
speed = 0;
}
void Car::accelerate(float intensity) {
@DavidYKay
DavidYKay / peg_cpu.cpp
Last active August 13, 2022 13:11
Run an infinite loop at max/FIFO thread priority. OS: Linux, w/ pthread.
#include <pthread.h>
#include <sched.h>
#include <iostream>
void infLoop() {
int i = 0;
while (true) {
i = (i + 1) % 1024;
}
}
@DavidYKay
DavidYKay / dualhead-xorg.conf
Last active August 2, 2022 18:25
X11 Config for dual / single screen NVIDIA TwinView.
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 280.13 (buildd@rothera) Fri Aug 5 12:28:41 UTC 2011
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "0"
@DavidYKay
DavidYKay / gist:912765
Created April 10, 2011 21:52
"Can Code Be Like Literature" - Jeremy Ashkenas
Jeremy
Absolutely brilliant
both technically
and oratorically
He wrote CoffeeScript
1st place 5k
21 min, 3 seconds
<7min mile
Big picture
package printtextlocations;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.pdfbox.exceptions.InvalidPasswordException;
@DavidYKay
DavidYKay / watershed.py
Created March 2, 2015 17:49
watershed example from Python OpenCV
#!/usr/bin/python
import urllib2
import sys
import cv2.cv as cv
class Sketcher:
def __init__(self, windowname, dests):
self.prev_pt = None
self.windowname = windowname
self.dests = dests
@DavidYKay
DavidYKay / Ogre.log
Last active December 3, 2019 07:58
OGRE 2.2: Callstack for HlmsComputeJob crash in Tutorial_OpenVR (After passing in the Compute Shader) - "Case 3"
23:39:51: Creating resource group General
23:39:51: Creating resource group Internal
23:39:51: Creating resource group Autodetect
23:39:51: SceneManagerFactory for type 'DefaultSceneManager' registered.
23:39:51: Registering ResourceManager for type Material
23:39:51: Registering ResourceManager for type Mesh
23:39:51: Registering ResourceManager for type Mesh2
23:39:51: Registering ResourceManager for type OldSkeleton
23:39:51: MovableObjectFactory for type 'ParticleSystem' registered.
23:39:51: ArchiveFactory for archive type FileSystem registered.
@DavidYKay
DavidYKay / Callstack
Last active December 3, 2019 07:58
OGRE 2.2: Callstack for HlmsComputeJob crash in Tutorial_OpenVR (8579b3508300ab3450c556c3aae0a5a22f95468e) - "Case 1"
#0 Ogre::HlmsCompute::findComputeJob (this=<optimized out>, datablockName=...) at /home/dk/workspace/current/mccarthy/subprojects/ogre2/OgreMain/src/OgreHlmsCompute.cpp:553
#1 0x00007ffff69a33da in Ogre::CompositorPassCompute::CompositorPassCompute (this=0x555556a02410, definition=0x5555567a2200, defaultCamera=0x5555568626c0, parentNode=0x5555569c02b0, rtv=<optimized out>) at /home/dk/workspace/current/mccarthy/subprojects/ogre2/OgreMain/src/Compositor/Pass/PassCompute/OgreCompositorPassCompute.cpp:112
#2 0x00007ffff69885f7 in Ogre::CompositorNode::createPasses (this=0x5555569c02b0) at /home/dk/workspace/current/mccarthy/subprojects/ogre2/OgreMain/src/Compositor/OgreCompositorNode.cpp:730
#3 0x00007ffff6994cb8 in Ogre::CompositorWorkspace::connectAllNodes (this=this@entry=0x5555569b2690) at /home/dk/workspace/current/mccarthy/subprojects/ogre2/OgreMain/src/Compositor/OgreCompositorWorkspace.cpp:344
#4 0x00007ffff69956b2 in Ogre::CompositorWorkspace::recreateAllNodes (this=this@entry=0x5555569b2690) at /h
@DavidYKay
DavidYKay / Speech.md
Created June 10, 2018 00:35
Nick Wong wedding speech

Nick Wong: wedding toast

Introduction

I'm David Kay.
I'm Nick's first client in his new career as a coach. They say there's a sucker born every minute, and [pointing at self] now you know they're telling the truth! [Smile] What I'd like to do today is to take a moment to celebrate Dr. Nick Wong through the lens of a painful and candid story.

Beginning - Boy meets girl

Apple

When I met Nick, I was down on my luck.