Skip to content

Instantly share code, notes, and snippets.

View 1f0's full-sized avatar
🎯
focusing

Minliang LIN 1f0

🎯
focusing
View GitHub Profile
@1f0
1f0 / read-and-sum.cpp
Last active February 20, 2019 13:45
basic c++ read file
#include <iostream>
#include <exception>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
if (argc < 2) {
cout << "Usage: " << argv[0] << " filename.txt" << endl;
return 0;
@1f0
1f0 / so2-opt.m
Created March 7, 2019 01:53
optimization of quadratic form of [SO_2]^n
%% f2d.m
function f2d(A)
x=0:0.05:3*pi;
[X, Y]=meshgrid(x);
F=zeros(size(X));
min_val = inf;
min_coord = [0 0];
max_val = -inf;
max_coord = [0 0];
%% copy from ocw.mit.edu
%% random matrix theory
%n=20; s=30000; d=.05; %matrix size, samples, sample dist
n=10; s=1000; d=.05; % s=30000 is too slow
e=[]; %gather up eigenvalues
im=1; %imaginary(1) or real(0)
for i=1:s,
a=randn(n)+im*sqrt(-1)*randn(n);a=(a+a')/(2*sqrt(2*n*(im+1)));
<ServerManagerConfiguration>
<ProxyGroup name="filters">
<!-- ================================================================== -->
<SourceProxy name="DistancePolyDataFilter" class="vtkDistancePolyDataFilter" label="DistancePolyDataFilter">
<Documentation
long_help="Computes the signed distance from one vtkPolyData to another."
short_help="vtkDistancePolyDataFilter.">
</Documentation>
<InputProperty
import argparse
# config parser
parser = argparse.ArgumentParser()
parser.add_argument("mesh")
parser.add_argument("-f", "--framefield", default="")
parser.add_argument("-n", "--quadnum", type=int, default=500)
@1f0
1f0 / test-ffmpeg-filter.py
Created July 19, 2019 06:08
example of testing different filter of ffmpeg
import ffmpeg
(
ffmpeg
.input('D:\\P\\ffmpeg-20190702-231d0c8-win64-static\\bin\\xiaoice_360p.mp4', re=None)
.audio
.filter('aderivative')
.output('rtmp://localhost/live/test', f='flv')
.run()
)
import threading
import time
def test(x):
def task():
while 1:
print(x)
time.sleep(x)
y = threading.Thread(target=task)
@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
#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) {}
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
{