Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Hello Underworld. Hello 人工稚能.

Lei Mao leimao

🦄
Hello Underworld. Hello 人工稚能.
View GitHub Profile
@leimao
leimao / unary_operator_overloading.cpp
Last active Feb 27, 2018
Extremely clear code on unary operator overloading (both prefix and postfix) in C++
View unary_operator_overloading.cpp
// 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)
{
@leimao
leimao / singleton_class.cpp
Last active Feb 27, 2018
C++ singleton class example
View singleton_class.cpp
// 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;
}
View spectral_param.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leimao
leimao / tqdm_process.py
Created Jun 12, 2018
Tqdm Process Example
View tqdm_process.py
"""
Tqdm Process Hook
Lei Mao
University of Chicago
"""
from tqdm import tqdm
def addup():
View CNN-RNN and ASR
# 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 Apr 8, 2019
C++ typedef Advanced Usages
View typedef.cpp
#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 / GitHub-Forking.md
Created Apr 30, 2019 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow
View GitHub-Forking.md

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

@leimao
leimao / inheritance.cpp
Last active May 2, 2019
C++ Class Inheritance Guidance
View inheritance.cpp
#include <iostream>
// https://stackoverflow.com/questions/860339/difference-between-private-public-and-protected-inheritance
class A
{
public:
int x = 1;
// Constructor
A() {}
@leimao
leimao / function_pointers_kernel.cu
Last active May 3, 2019
Alchemy on passing functional pointers to kernel in CUDA programming. https://leimao.github.io/blog/Pass-Function-Pointers-to-Kernels-CUDA/
View function_pointers_kernel.cu
#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 / friend.cpp
Last active May 4, 2019
Friend Class and Function Usages
View friend.cpp
#include <iostream>
/*
* Modified from
* https://www.geeksforgeeks.org/friend-class-function-cpp/
*/
class A;
class B;