Skip to content

Instantly share code, notes, and snippets.

View leimao's full-sized avatar
🦭
Hello Underworld. Hello 人工稚能.

Lei Mao leimao

🦭
Hello Underworld. Hello 人工稚能.
View GitHub Profile
@leimao
leimao / singleton_class.cpp
Last active February 27, 2018 22:44
C++ singleton class example
// Source: https://sourcemaking.com/design_patterns/singleton/cpp/1
class GlobalClass
{
int m_value;
static GlobalClass *s_instance;
GlobalClass(int v = 0)
{
m_value = v;
}
@leimao
leimao / unary_operator_overloading.cpp
Last active February 27, 2018 22:43
Extremely clear code on unary operator overloading (both prefix and postfix) in C++
// http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/
class Digit
{
private:
int m_digit;
public:
Digit(int digit=0)
: m_digit(digit)
{
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leimao
leimao / tqdm_download.py
Created June 12, 2018 03:41
Tqdm Download Example
"""
Tqdm Download Hook
Lei Mao
University of Chicago
Modified from https://github.com/tqdm/tqdm/blob/master/examples/tqdm_wget.py
"""
import os
@leimao
leimao / tqdm_process.py
Created June 12, 2018 03:41
Tqdm Process Example
"""
Tqdm Process Hook
Lei Mao
University of Chicago
"""
from tqdm import tqdm
def addup():
# Check blog details:
# https://yerevann.github.io/2016/06/26/combining-cnn-and-rnn-for-spoken-language-identification/
# TensorFlow sample code
# http://nicholaspropes.com/entries/general/updated-cnn-rnn-tensorflow-example-code
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import math
@leimao
leimao / typedef.cpp
Created April 8, 2019 22:01
C++ typedef Advanced Usages
#include <iostream>
// more complicated typedef
typedef int int_t, *intp_t, (&fp)(int, float), arr_t[10];
int my_int_func(int x, float y)
{
return x;
}
@leimao
leimao / reorg_simulation.py
Last active April 8, 2020 07:24
This is a simulation for the reorg layer in YOLO v2 model.
import numpy as np
stride_MACRO = 2
batch_MACRO = 2
C_MACRO = 4
H_MACRO = 6
W_MACRO = 6
"""
@leimao
leimao / function_pointers_kernel.cu
Last active May 3, 2019 20:29
Alchemy on passing functional pointers to kernel in CUDA programming. https://leimao.github.io/blog/Pass-Function-Pointers-to-Kernels-CUDA/
#include <iostream>
// Since C++ 11
template<typename T>
using func_t = T (*) (T, T);
template <typename T>
__device__ T add_func (T x, T y)
{
return x + y;
@leimao
leimao / GitHub-Forking.md
Created April 30, 2019 20:30 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j