Skip to content

Instantly share code, notes, and snippets.

View kanhua's full-sized avatar

Kan-Hua Lee kanhua

View GitHub Profile
@kanhua
kanhua / DLFTS calculation.ipynb
Last active October 2, 2018 06:16
Demo of Deep Level Fourier Transient Spectroscopy (DLFTS)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kanhua
kanhua / quarter_polar_plot.py
Created October 1, 2017 14:53
Quarter polar plot with matplotlib
"""
Reference:
1. https://gist.github.com/ycopin/3342888
2. http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axisartist
"""
import numpy as np
import matplotlib.pyplot as plt
@kanhua
kanhua / README.md
Last active February 1, 2023 17:08
A template of writing C or C++ extension for python and numpy

This gist demonstrates how to setup a python project that process a numpy array from C language.

To compile the project, run

make all

To test it, run

make test
@kanhua
kanhua / pandas_groupby
Created July 3, 2015 13:14
pandas groupby
{
"cells": [
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
@kanhua
kanhua / monte_carlo_pi.jl
Created October 27, 2014 15:01
Calculate Pi using monte carlo method
# Calculate Pi using monte carlo method
function estimate_pi_vec()
# Vectorized way of calculating Pi
# This style is commonly seen in python or Matlab/Octave to avoid for loops
samplenum=100000000
mc_x=rand(samplenum,1)
mc_y=rand(samplenum,1)
@kanhua
kanhua / titanicSubmit
Created October 23, 2014 15:03
Submit Kaggle Titanic results (not optimised!)
{
"metadata": {
"language": "Julia",
"name": "",
"signature": "sha256:999e48e1cfeb072e56d4089a89783a9483f6c014acc704990d74ba7079a57434"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
@kanhua
kanhua / titanicAnalysis
Last active August 29, 2015 14:07
Explore the Titanic data on Kaggle
{
"metadata": {
"language": "Julia",
"name": "",
"signature": "sha256:6394928c631f491d9b3776e1af071144d00c1446e0ec4d032c094af7b3d8edd6"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
@kanhua
kanhua / julia2048_basic.jl
Created October 9, 2014 14:44
A simple terminal 2048 game written in julia language
const ContinueGame=999
const WinGame=777
const LoseGame=444
const QuitGame=-99
function move(line,direction)
lineLen=length(line)
nonZeroLine=line[line.>0]
@kanhua
kanhua / .gitignore
Last active August 29, 2015 14:06 — forked from octocat/.gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #