This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Http Live Streaming -- fetcher/downloader | |
# A simple script to download ts segments/m3u8 files from given url, including variant streams from master m3u8 | |
# require: python3 | |
import sys | |
import os | |
import urllib.request | |
TEST_URL = 'https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define LOG_LEVEL_VERBOSE 0 | |
#define LOG_LEVEL_DEBUG 1 | |
#define LOG_LEVEL_INFO 2 | |
#define LOG_LEVEL_WARNING 3 | |
#define LOG_LEVEL_ERROR 4 | |
#define DEBUG_LEVEL LOG_LEVEL_INFO | |
#define LOG_TAG "TEST_LOG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# prerequisition: pygments, `sudo pip install pygments` | |
# usage: copy this file to /usr/bin or create symlink in /usr/bin links to this file. | |
# remember add `x` permission. | |
echo "" | |
function mycat() { | |
local style="monokai" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
; add `open command prompt here` on right click option for Windows 10 | |
; copy and paste to new created text file `cmd.reg` | |
; file must be saved as `ANSI` encoding | |
[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere] | |
@="Open command prompt here" | |
"Icon"="cmd.exe" | |
[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere\command] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1, 类内声明同时定义 | |
template <typename T> | |
class VectorWrapper { | |
public: | |
VectorWrapper(const std::initializer_list<T> &list) { mVector = list; } | |
friend std::ostream &operator<<(std::ostream &os, const VectorWrapper<T> &vec_w) { | |
vec_w.print_l(os); | |
return os; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::thread; | |
use std::time::Duration; | |
use std::collections::HashMap; | |
struct Cacher<T> | |
where T: Fn(u32) -> u32 | |
{ | |
calculate: T, | |
map: HashMap<u32, u32>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! hashmap { | |
($($key: expr => $val: expr), *) => {{ | |
let mut map = ::std::collections::HashMap::new(); | |
$(map.insert($key, $val);)* | |
map | |
}}; | |
} | |
fn main() { | |
let counts = hashmap!['A' => 0, 'C' => 1, 'G' => 2, 'T' => 3]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type IPAddr [4]byte | |
func (addr IPAddr) String() string { | |
return fmt.Sprintf("\"%v.%v.%v.%v\"", addr[0], addr[1], addr[2], addr[3]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Full impl of an ATM machine example introduced in book: C++ Concurrency in Action, chapter 4. | |
*/ | |
#include <thread> | |
#include <iostream> | |
#include <string> | |
#include <mutex> | |
#include <condition_variable> | |
#include <queue> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <utility> | |
#include <iostream> | |
#include <tuple> | |
#include <functional> | |
template <typename T, bool Enable, typename ...Args> | |
class Closure; | |
// for function |