Skip to content

Instantly share code, notes, and snippets.

View ExpandOcean's full-sized avatar

Zhang Yang ExpandOcean

  • Shanghai, China
View GitHub Profile
@ExpandOcean
ExpandOcean / trace.c
Created June 25, 2014 07:50
Enable printf() with trace
#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))
#define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
#define TRCENA 0x01000000
struct __FILE { int handle; /* Add whatever is needed */ };
FILE __stdout;
FILE __stdin;
socat -v tcp-l:9000,fork exec:'/bin/cat'
@ExpandOcean
ExpandOcean / kivy_cv.py
Created January 7, 2015 06:48
kivy and opencv work together demo
# coding:utf-8
from kivy.app import App
from kivy.uix.image import Image
from kivy.clock import Clock
from kivy.graphics.texture import Texture
import cv2
class KivyCamera(Image):
def __init__(self, capture, fps, **kwargs):
@ExpandOcean
ExpandOcean / opencv_pyqt_camera.py
Created January 12, 2015 01:22
Operate a camera using opencv and pyqt
# coding=utf-8
import sys
from PyQt4 import QtGui
import cv
from PyQt4 import QtCore
class CameraDevice(QtCore.QObject):
_DEFAULT_FPS = 30
@ExpandOcean
ExpandOcean / gist:683028dd14975186d275
Created March 19, 2015 02:40
static var in python's function
def _update_avg_fps(self,dt,L=[20 for _ in range(30)]):
L.pop(0)
L.append(1.0/dt)
self.avg_fps = sum(L) / 30.0
@ExpandOcean
ExpandOcean / Caddyfile
Created August 28, 2018 03:16
Reverse proxy a HTTPS django server with caddy
xxxx.com {
proxy / https://yyyy.com {
header_upstream Referer https://yyyy.com
}
}
.container {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100%;
}
.message1 {
margin-left: auto; margin-right: auto;