Skip to content

Instantly share code, notes, and snippets.

@hxhc
hxhc / merge.py
Last active July 13, 2017 08:32
merge some data files into one
import pandas as pd
import os
import glob
import numpy as np
# This script is used to calculate the mean of spectra of every 3 jdx files, thus combining 3 data files into one.
# get all filenames
path = os.getcwd()
all_files = glob.glob(os.path.join(path, "*.txt"))
@hxhc
hxhc / Compiling Vim with Anaconda.md
Last active January 30, 2020 21:03
Compiling Vim with Anaconda

Compiling Vim with Anaconda

Vim is a powerful editor with no doubt, and the jedi-vim plugin is powerful for pythoners. However, jedi-vim can't work with Anaconda. This is because

  • Ubuntu's (14.04) python is located at /usr/bin
  • Anaconda' python is at ~/Anaconda3/bin

There is a tricky but dangerous way to overcome it. Adding the line below to ~/.zshrc or ~/.bashrc.

Our Lab bought a new server to build a web paltform (LAMP maybe, I am not involved in that) whose system is Centos 6.5. Centos maybe a great system yet not for our school's network.

In the campus, we connect to the Internet through l2tp VPN and xl2tpd is usually used. We have customized deb package for xl2tpd containing specific options for the school network on the school forum. Unfortunately, no rpm package is provided.

I found a github project provide a solution for rpm package. But the problem is the package version is too new for Centos 6.5, or rather too new for glibc. So the solution for Centos 6.5 is to use the xl2tp-1.2.8-1 package (or lower, I haven't test lower versions). On pkgs.org/, we can find other xl2tpd versions.

@hxhc
hxhc / GlitterDrag-2018-1-6-14-54.json
Created January 6, 2018 06:56
GlitterDrag settings for Firefox
{
"Actions": {
"textAction": {
"DIR_U": {
"act_name": "ACT_SEARCH",
"tab_active": false,
"tab_pos": "TAB_CRIGHT",
"engine_name": "default",
"engine_url": "https://www.google.com/search?q=%s",
"open_type": "OPEN_TEXT",
@hxhc
hxhc / Linux服务器安装Matlab2017_多镜像文件版本.md
Created January 12, 2018 08:11
Linux服务器安装Matlab2017_多镜像文件版本

实验室服务器为Ubuntu 14.04.5系统,性能自然不用说,Matlab却只有2013b和2012a的版本,让本地使用2016a的同志们感到不舒服,因为有些函数还是有很大修改的(比如matlabpool)。在实验室同志的强烈要求下,给服务器装了Matlab2017a版本(2016a的版本没找到破解版~)。

其实网上已经有很多服务器安装matlab的教程了,不过多少有点差别,以下稍微记录一下安装记录:

  1. 下载,解压,得到两个iso镜像文件和一个Crack文件夹:
.
|-- R2017a_glnxa64_dvd1.iso
|-- R2017a_glnxa64_dvd2.iso
|-- Crack
@hxhc
hxhc / sample_split.py
Last active March 21, 2020 08:25
spectra sample set split methods including random split, Kennard-Stone split and SPXY split. Max minimum distance split which is the core of Kennard-Stone split and SPXY split is also implemented as a function.
# -*- coding=utf-8 -*-
from __future__ import division, print_function
import numpy as np
from sklearn.model_selection import train_test_split
from scipy.spatial.distance import cdist
def random_split(spectra, test_size=0.25, random_state=None, shuffle=True, stratify=None):
"""implement random_split by using sklearn.model_selection.train_test_split function. See

海外恨国党名单:文睿,文昭,老雷,滕彪,虞锐,鲍彤,王丹,柴玲,盛雪,方政,尹胜,赵岩,萧茗,石涛,石平,何平,路德,安红,谢田,何频,王剑,胡平,吕朴,张洵,lnty(阴蒂),vlog心声(刘大圣),方的言,周周侃,蒋罔正,stone(屎洞记),秦伟平,万延海,周锋锁,李一平,吴建明,黄明珍,曹旭云,苏晓康,严家祺,邱家军,李沐阳,裴毅然,郭岩华,邱岳首,齐家贞,任松林,俞万利,章天亮,宋永毅,唐元隽,章家墩,夏业良,郑旭光,曹雅学,廖天琪,林培瑞,陈小平,陈晓天,李恒青,赵云龙,顾为群,翁寒松,李兰斯,李伟东,张博树,李南央,曹长青,江森哲,艾未未,Av Daniel violin (陈丹九),陈破空,郭文贵,郭宝胜,吕京花,魏京生,杨建利,辛灝年,王军涛,胡正军,吴仁华,李洪宽,龚小夏,袁红斌,程晓农,何清莲,周来友,陈奎德,纪硕鸣,郝毅博,林林七,面具人,Leonard(莱昂纳德),小民之心,老黑公民,吾尔开希,江峰时刻,公子时评,书香夜话,冷眼财经,悉尼奶爸,移民访谈录,徐杰慢半拍,裤论徐思远,lisa在英国,老北京茶馆,加州姜太公,大康有话说,旗袍体验派,猫眼看中国,小西看世界,大师兄则席,看中国的狗哥,苏小和批评书,新闻拍案惊奇大宇。

跪舔公知:陈秋实,袁腾飞,梁艳萍,高晓松,周孝正,郝海东,叶钊颖,向松祚,李承鹏,方舟子,崔永元,潘石屹,任志强,刘晓波,许章润,徐晓东,茅于轼,方方,马东,

港独自媒体名单:大J,鱷魚,城寨,陶杰,吴志森,梁锦祥,曾志豪,张坚庭,黃毓民,蕭若元,吴明德,李慧玲,关庆宁,李达宁,杜汶泽,笑波子,啤梨晚报,苹果日报,香港花生,高清本土台,升旗易得道,852邮报,赵氏读书生活。

港独汉奸名单:黄之锋,黄台仰,何韵诗,黄秋生,陈浩天,周浩辉,钟翰林,梁颂恒,毛孟静,李卓人,黎智英,李柱明,陈方安生,陈日君,游蕙祯,罗冠聪,涂谨申,梁国雄,张倩盈,朱凯迪,李柱铭,周庭,

台独自媒体名单:佐拉,呱吉,唐浩,波特王,不要闹,阿滴仔,阿兜仔,钟明轩,明居正,范世平,王瑞德,彭文正,沈富雄,郑弘仪,周玉蔻,余莓莓,李家宝,胡婉玲,王时齐,李四端,张雅琴,安幼琪,丁学伟,陈雅琳,陈凝观,黄创夏,刘宝洁,曾建元,曾博恩,马西屏,张铭佑,长男次男,摄徒日记,志祺七七,台湾基进,3Q陈柏惟,馆长陈痴汉,鸡排郑家纯,Thesis taiwan(老外看台湾)。

@hxhc
hxhc / scienceplot.mplstyle
Last active August 13, 2022 08:04
The customized matplotlib style for scientific plot with large font size, linewidth and scatter size
# It is a modified version of garrettj403/SciencePlots/science.mplstyle
# (https://github.com/garrettj403/SciencePlots/blob/master/styles/science.mplstyle)
# Set color cycle: using vibrant palette
axes.prop_cycle : cycler('color', ['EE7733', '0077BB', '009988', 'CC3311', '33BBEE', 'EE3377', 'BBBBBB'])
# Set default figure size
figure.figsize : 8, 6
# Set font size
@hxhc
hxhc / ReadSPA.py
Created September 2, 2021 11:47 — forked from ZGainsforth/ReadSPA.py
Read an SPA file from Omnic
# Created 2015, Zack Gainsforth
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import struct
from numpy.fft import fft, fftfreq
def LoadSPAInterferogram(FileName):
# Open the SPA file.
@hxhc
hxhc / CUSim.cpp
Last active May 6, 2022 11:31
CUSim
#include "CUTest.hpp"
#include <omp.h>
std::vector<Eigen::ArrayXd> sim_sd(double mu, double start, double end, int sd_num=61, int sim_num = 10000, double low_lvl = 85.0, double upp_lvl = 115.0,
double ck1 = 2.2, double ck2 = 0.25, double ck3 = 1.7, double cL = 15.0, double uk1 = 2.4, double uk2 = 2.0, double uL1 = 15.0, double uL2 = 25.0) {
int batch = 20000; // simulate 20k tablets in one batch
Eigen::ArrayXd failrate = Eigen::ArrayXd::Zero(sd_num);
Eigen::ArrayXd chp_fail_s1 = Eigen::ArrayXd::Zero(sd_num);
Eigen::ArrayXd chp_fail_s2 = Eigen::ArrayXd::Zero(sd_num);
Eigen::ArrayXd chp_pass_s1 = Eigen::ArrayXd::Zero(sd_num);