Skip to content

Instantly share code, notes, and snippets.

@KavinHan
KavinHan / waya-dl-setup.sh
Created November 14, 2017 14:24 — forked from mjdietzx/waya-dl-setup.sh
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
@KavinHan
KavinHan / getScript.js
Created May 18, 2017 01:07
load script using javascript
/**
* https://github.com/zzyss86/LunarCalendar
* 动态加载js文件
* @param {string} url js文件的url地址
* @param {Function} callback 加载完成后的回调函数
*/
var _getScript = function(url, callback) {
var head = document.getElementsByTagName('head')[0],
js = document.createElement('script');
@KavinHan
KavinHan / detectMobile.js
Last active May 18, 2017 01:07
detect mobile using javascript
// https://github.com/zzyss86/LunarCalendar
var mobile = {
platform: '',
version: 0,
Android: function () {
return this.platform === 'Android';
},
iOS: function () {
return this.platform === 'iOS';
},

disable touch callout

https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-touch-callout

Keyword values

The -webkit-touch-callout CSS property controls the display of the default callout shown when you touch and hold a touch target. When a target is touched and held on iPhone OS, Safari displays a callout information about the link. This property allows disabling that behavior.

-webkit-touch-callout: default;
// https://forum.openframeworks.cc/t/best-way-to-create-vertices-on-a-circle/15400/2
float startAngle = ofGetElapsedTimef() * TWO_PI/2.0; // angle = time (in seconds) * speed (in radians/second);
for (int i=0; i<originalPolyline.size(); i++) {
float angleOffset = float(i)/originalPolyline.size() * (4.0*TWO_PI);
float angle = startAngle + angleOffset;
float scale = sin(angle*2.0) * 10.0;
modifiedPolyline[i].x = originalPolyline[i].x + scale * cos(angle);
modifiedPolyline[i].y = originalPolyline[i].y + scale * sin(angle);
}
@KavinHan
KavinHan / of_rotate_image.h
Last active May 31, 2016 09:34
openframeworks rotate an image from its center
// http://stackoverflow.com/questions/12516550/openframeworks-rotate-an-image-from-its-center-through-opengl-calls
ofPushMatrix();
ofTranslate(leafImg.width/2, leafImg.height/2, 0);//move pivot to centre
ofRotate(ofGetFrameNum() * .01, 0, 0, 1);//rotate from centre
ofPushMatrix();
ofTranslate(-leafImg.width/2,-leafImg.height/2,0);//move back by the centre offset
leafImg.draw(0,0);
ofPopMatrix();
ofPopMatrix();
@KavinHan
KavinHan / of-class-template.h
Created May 27, 2016 03:08
openFrameworks custom class template
#pragma once
#include "ofMain.h"
class MyClass {
public:
MyClass() {
// Reference:
// http://stackoverflow.com/questions/11874029/how-to-bring-up-the-windows-8-on-screen-keyboard-in-a-desktop-app
C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe
osk.exe
@KavinHan
KavinHan / of_GetAngleABC.cpp
Last active May 31, 2016 09:34
Get angle from three point at openframeworks
// http://stackoverflow.com/questions/3486172/angle-between-3-points
int GetAngleABC(ofVec2f a, ofVec2f b, ofVec2f c) {
ofVec2f ab = { b.x - a.x, b.y - a.y };
ofVec2f cb = { b.x - c.x, b.y - c.y };
float dot = (ab.x * cb.x + ab.y * cb.y); // dot product
float cross = (ab.x * cb.y - ab.y * cb.x); // cross product
float alpha = atan2(cross, dot);
@KavinHan
KavinHan / image_sequence2video.cmd
Last active June 5, 2016 06:36
ImageMagick convert image sequence to video
convert -quality 100 *.jpg video.mov
ffmpeg -framerate 30 -i frame_%4d.jpg contour.mov