Skip to content

Instantly share code, notes, and snippets.

View joonro's full-sized avatar

Joon Ro joonro

View GitHub Profile
@joonro
joonro / gist:1227446
Created September 19, 2011 20:04
python pdf import
import re # regular expressions
import pyPdf
filename = '/home/joon/downloads/T1223.pdf'
pdf = pyPdf.PdfFileReader(open(filename, "rb"))
pages = []
@joonro
joonro / gist:1344078
Created November 7, 2011 02:41
matplotlib 3-d plot example
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
# put 0s on the y-axis, and put the y axis on the z-axis
ax.plot(xs=self.grid_s, ys=self.grid_vu, zs=self.p[2][eye(self.grid_s.shape[0], dtype=bool)], zdir='z', label='ys=0, zdir=z')
plt.show()
@joonro
joonro / 0_reuse_code.js
Created November 27, 2013 05:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@joonro
joonro / SublimeLinter.sublime-settings
Created March 31, 2014 21:35
Sublime Text 3 Configuration
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"pep8": {
Sub Remove_Missing()
'Set the range to evaluate to rng.
Set Rng = Range("E2:E20001") 'Rng holds the Range object
'initialize i to 1
i = 1
For counter = 1 To Rng.Rows.Count 'number of rows
@joonro
joonro / Loop speed test.py
Last active May 22, 2018 19:22
[Loop speed test] #python
def summation(arg):
return_val = 0
for i in arg:
return_val += i
return(return_val)
test_range = np.arange(10)
%timeit summation(test_range)
Import-Module posh-git
# customize git prompt display settings
$global:GitPromptSettings.BeforeText = '['
$global:GitPromptSettings.AfterText = '] '
$global:GitPromptSettings.BranchAheadForegroundColor = [ConsoleColor]::Green
$global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Magenta
$global:GitPromptSettings.UntrackedForegroundColor = [ConsoleColor]::DarkGray
Enable-GitColors
@joonro
joonro / str_type-specific_formatting.py
Last active January 15, 2018 19:55
[Convert datetime to string using type-specific formatting] https://docs.python.org/3.6/library/string.html #python #date #string
>>> import datetime
>>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
'2010-07-04 12:15:58'
#+BEGIN_SRC emacs-lisp :results none
(setq properties-list '("Title" "Composer" "Publisher" "NDisks"))
(let ((MATCH t)
(SCOPE 'file)
(SKIP nil)
(spacing nil))
(org-map-entries
(lambda ()
(let ((level (nth 1 (org-heading-components))))
@joonro
joonro / convert_date_int_to_pandas_timestamp.py
Last active June 23, 2018 21:23
[Covert Date in Int to pd.Timestamp] #python #pandas #date #time
import pandas as pd
# convert to datetime
showdates = pd.to_datetime(con_df['showdate'].astype(str))
# if you don't do `to_timedelta`, you will get integer numbers
# so convert it back to timedelta
pd.to_timedelta(showdates.values[1:] - showdates.values[:-1])