Skip to content

Instantly share code, notes, and snippets.

View zhangyangjing's full-sized avatar

Yangjing Zhang zhangyangjing

View GitHub Profile
@zhangyangjing
zhangyangjing / aria2.conf
Created December 8, 2019 16:24
aria2-docker
dir=/data
continue=true
input-file=/conf/aria2.session
save-session=/conf/aria2.session
save-session-interval=60
force-save=true
enable-mmap=true
disk-cache=512M
file-allocation=falloc
@zhangyangjing
zhangyangjing / start_tmux.sh
Last active November 18, 2019 13:53
start Tmux shell
#!/bin/sh
# see: https://gist.github.com/todgru/6224848
session="one1"
tmux start-server
tmux new-session -d -s $session
tmux send-keys C-m # ignore errors. see:https://github.com/tmux/tmux/issues/1173#issuecomment-347496
#include <time.h>
static long currentTimeInNs() {
struct timespec res;
clock_gettime(CLOCK_MONOTONIC, &res);
return (res.tv_sec * 1e9) + res.tv_nsec;
}
static long currentTimeInMs(void) {
struct timespec res;
@zhangyangjing
zhangyangjing / WaveHelper.java
Last active September 18, 2017 07:55
save pcm to wav format
public class WaveHelper {
private File mFile;
private int mSample;
private int mChannel;
private int mSampleBits;
private LittleEndianDataOutputStream mDos;
public WaveHelper(File file, int channel, int sample, int encoding) {
mFile = file;
mSample = sample;
@zhangyangjing
zhangyangjing / timing.cpp
Created January 18, 2017 14:43
timing_cpp
#include <chrono>
typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::milliseconds ms;
typedef std::chrono::nanoseconds ns;
auto start = Time::now();
ns d1 = std::chrono::duration_cast<ns>(Time::now() - start);
ms d2 = std::chrono::duration_cast<ms>(Time::now() - start);
@zhangyangjing
zhangyangjing / FpsMonitor.java
Last active January 18, 2017 03:18
FpsMonitor
public class FpsMonitor {
private static final int SAMPLE_COUNT = 10;
private ArrayBlockingQueue<Long> mQueue;
private long mLastUpdateTime;
public FpsMonitor() {
mQueue = new ArrayBlockingQueue<>(SAMPLE_COUNT);
mLastUpdateTime = System.currentTimeMillis();
}
@zhangyangjing
zhangyangjing / port_id.txt
Created November 15, 2016 05:54
port id for tide info @ http://ocean.cnss.com.cn
亚洲 中国 辽宁 丹东 1
亚洲 中国 辽宁 丹东新港 2
亚洲 中国 辽宁 石山子 3
亚洲 中国 辽宁 大鹿岛 4
亚洲 中国 辽宁 小长山岛 5
亚洲 中国 辽宁 大窑湾(南大圈) 6
亚洲 中国 辽宁 大连(老虎滩) 7
亚洲 中国 辽宁 旅顺新港 8
亚洲 中国 辽宁 金县 9
亚洲 中国 辽宁 葫芦岛 10
@zhangyangjing
zhangyangjing / concat.py
Last active October 14, 2016 07:22
subtitles_concat
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
if 2 != len(sys.argv):
print 'bad argument'
exit(1)
Installing collected packages: requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import requests
from datetime import datetime
@zhangyangjing
zhangyangjing / hn.py
Created February 4, 2016 07:30
hack news rss generator
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.