Skip to content

Instantly share code, notes, and snippets.

View exaos's full-sized avatar

Exaos Lee exaos

View GitHub Profile

Keybase proof

I hereby claim:

  • I am exaos on github.
  • I am vivodo (https://keybase.io/vivodo) on keybase.
  • I have a public key whose fingerprint is 39CC FE5D 8738 24A1 6ECB 0210 346A 5402 D477 E89E

To claim this, I am signing this object:

@exaos
exaos / get_geant4.py
Created May 20, 2015 07:51
Geant4 Fetcher
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@Exaos
'''
import os
import os.path as path
import yaml
import subprocess as sp
(defadvice org-html-paragraph (before fsh-org-html-paragraph-advice
(paragraph contents info) activate)
"Join consecutive Chinese lines into a single long line without
unwanted space when exporting org-mode to html."
(let ((fixed-contents)
(orig-contents (ad-get-arg 1))
(reg-han "[[:multibyte:]]"))
(setq fixed-contents (replace-regexp-in-string
(concat "\\(" reg-han "\\) *\n *\\(" reg-han "\\)")
"\\1\\2" orig-contents))
@exaos
exaos / get-geant4-packages.py
Created April 26, 2013 11:25
Get Geant4 packages from CERN. 从 CERN 网站下载 Geant4 安装包的 Python 脚本程序。
#!/usr/bin/env python
import os, os.path
import yaml
baseurl = 'http://geant4.cern.ch/support/source/'
datadir = os.getcwd() + "/../Data/"
urls = yaml.load(open("urls.yaml"))
for k in urls:
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@exaos
exaos / FindROOT.mk
Created January 17, 2013 08:34
Better way to find installed ROOT (CERN) in Makefile.
# Find ROOT
ifndef ROOTSYS
ROOT_CONFIG := $(shell which root-config 2> /dev/null)
ifdef ROOT_CONFIG
ROOTSYS := $(shell root-config --prefix)
else
missroot::
@echo "ROOT system is not found!"
endif
else
@exaos
exaos / getpeaks.py
Created January 11, 2013 03:59
A example of using ROOT::TSpectrum in Python. (http://root.cern.ch/)
#!/usr/bin/env python
'''
'''
from ROOT import TH1F, TH1, TSpectrum, TFile
from pprint import pformat
def get_gpeaks(h,lrange=[1000,3800],sigma=2,opt="",thres=0.05,niter=20):
s = TSpectrum(niter)
h.GetXaxis().SetRange(lrange[0],lrange[1])
@exaos
exaos / ReadMCA.py
Created January 11, 2013 03:36
ReadMCA: Convert spectra gathered by MCA8000 into ROOT format (http://root.cern.ch/)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''Read data acquired by MCA8000A through software "pcma".
File extension: .mca'''
import re
def readmca(fm):
sraw=[l.strip() for l in open(fm,'r').readlines()]
kidx=[]
@exaos
exaos / isodate-to-subdir.py
Created January 10, 2013 09:14
Split ISO-date to subdirs: e.g. 2012-12-12/*.* ==> 2012/12/12/*.*
import shutil, os, sys
def dest_name(d_name):
d_tmp = d_name.split('-')
if d_tmp and d_tmp[0] != d_name:
return os.path.join('.',*d_tmp)
return None
names = os.listdir(ur'.')
@exaos
exaos / el-emacs-zh-face.el
Last active March 21, 2022 10:27
My emacs face settings for Chinese environment. Emacs 字体设置,中英文同步缩放,大字符集显示。
;; mode: emacs-lisp; coding: utf-8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; By: Exaos Lee
;; URL: https://gist.github.com/4493582
;; References:
;; - http://baohaojun.github.com/perfect-emacs-chinese-font.html
;; - http://fonts.jp/hanazono/
;; - http://ergoemacs.org/emacs/emacs_n_unicode.html
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;