Skip to content

Instantly share code, notes, and snippets.

@halm
halm / file0.py
Created March 11, 2015 14:01
plt.ion() すると描画されないことがある ref: http://qiita.com/halm/items/becdc1e1a456562f21c8
>>> import matplotlib.pyplot as plt
>>> plt.ion()
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> ax.plot([1, 2, 3])
>>> plt.show()
@halm
halm / bar.py
Created March 1, 2015 11:03
Stacked bar graph by pyproffx module
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import pyproffx as pfx
fp = '~/Dropbox/work/dgemm/autoparallel/'
p, d = pfx.load_pa(fp, 'dgemm')
el= pfx.ElapsedTime(p, d)
@halm
halm / find_file.py
Created January 19, 2014 09:47
Find a file from a given directory recursively.
#!/usr/bin/env python3.3
# Find a file from a given directory recursively.
"""
The MIT License (MIT)
Copyright (c) 2014 Haruhiko Matsuo.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@halm
halm / rgb2hex
Last active December 24, 2015 08:48
Convert RGB to hex.
rgb = ((99,170,254), (221,8,6), (153,204,0), (31,183,20), (255,124,128),
(134,83,87), (204,204,255), (0,0,144), (204,153,255), (255,0,255),
(252,243,5), (255,153,0), (70,0,165), (128,0,0), (0,0,212),
(0,204,255))
for c in rgb:
h = "{0:02x}{1:02x}{2:02x}".format(*c)
print( h+','),
print('')
@halm
halm / sum
Created September 19, 2013 01:05
one-liner series: Sum of Field 21.
awk '{if (NF == 21) sum += $21} END { print sum }'
@halm
halm / factorization
Created September 18, 2013 05:37
Find prime factors of a number in Python.
import sympy
sympy.factorint(524288)
@halm
halm / mean
Created September 18, 2013 01:19
one-liner series: calculate a mean value by AWK.
awk '{sum += $8} END {print sum/NR}'