Skip to content

Instantly share code, notes, and snippets.

View 1f0's full-sized avatar
🎯
focusing

Minliang LIN 1f0

🎯
focusing
View GitHub Profile
def partition(n):
# x: current coin, y: remain value
def helper(x, y):
if y <= 0:
return int(y == 0)
# use x and not use x
z = helper(x, y-x)
if x < y:
z += helper(x+1, y)
return z
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
n = 25
q = n * n
A = np.eye(q)
import argparse
p = argparse.ArgumentParser(description='off to obj.')
p.add_argument('input')
p.add_argument('out')
args = p.parse_args()
with open(args.input) as f:
lines = f.readlines()
meta = lines[1].split()
@1f0
1f0 / obj2vtk.py
Created October 12, 2019 10:31
convert obj to vtk file using python vtk lib
from __future__ import print_function
import sys
if(len(sys.argv) != 3):
print('Usage: ', sys.argv[0], 'input.obj output.vtk')
sys.exit()
import vtk
reader = vtk.vtkOBJReader()
reader.SetFileName(sys.argv[1])
@1f0
1f0 / readvideo.py
Created August 26, 2019 15:27
cv2 read video
import numpy as np
import cv2
cap = cv2.VideoCapture('rtmp://localhost/live/stream')
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
using System;
using System.Net;
using System.Text;
using System.Threading;
namespace SimpleHttp
{
// reference: https://www.codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server
class SimpleHttpServer
{
#include <stdio.h>
#include <pthread.h>
void *busy(void *ptr) {
puts("hello");
return NULL;
}
int main() {
pthread_t id;
pthread_create(&id, NULL, busy, "hi");
while (1) {}
@1f0
1f0 / cv2_streamiing.py
Last active April 27, 2023 06:14
cv2 rtmp streaming example
import numpy as np
import cv2
cap = cv2.VideoCapture('rtmp://localhost/live/stream')
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
import threading
import time
def test(x):
def task():
while 1:
print(x)
time.sleep(x)
y = threading.Thread(target=task)