Skip to content

Instantly share code, notes, and snippets.

View anonymouss's full-sized avatar
🐱
meow~

meow1234 anonymouss

🐱
meow~
  • 家里蹲
  • Shanghai
View GitHub Profile
@anonymouss
anonymouss / test.cpp
Created April 21, 2021 12:27
test bind
#include <type_traits>
#include <utility>
#include <iostream>
#include <tuple>
#include <functional>
template <typename T, bool Enable, typename ...Args>
class Closure;
// for function
@anonymouss
anonymouss / atm.cpp
Created March 25, 2021 05:55
Full impl of an ATM machine example introduced in book: C++ Concurrency in Action, chapter 4.
/**
* 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>
@anonymouss
anonymouss / Stringer.go
Last active August 27, 2019 15:48
a tour of go
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])
}
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];
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>,
}
// 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;
}
@anonymouss
anonymouss / cmd.reg
Created February 18, 2019 05:53
add `open command prompt here` on right click option for Windows 10
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]
@anonymouss
anonymouss / mycat.sh
Last active December 5, 2018 16:56
cat with syntax highlight
#!/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"
#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"
@anonymouss
anonymouss / hlsFetcher.py
Created January 24, 2018 04:58
download hls segments from m3u8
#!/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'