Skip to content

Instantly share code, notes, and snippets.

View GeauxEric's full-sized avatar

GeauxEric GeauxEric

  • Nvidia
  • CA USA
  • 04:50 (UTC -08:00)
View GitHub Profile
@GeauxEric
GeauxEric / uglyNum2.py
Last active November 13, 2015 22:02
Write a program to find the n-th ugly number
# https://leetcode.com/problems/ugly-number-ii/
class Solution(object):
def nthUglyNumber(self, n):
"""
:type n: int
:rtype: int
"""
if n < 5:
return n
@GeauxEric
GeauxEric / pdb_line_regx.cpp
Created October 7, 2015 04:54
regular expression in c++ to match a typical ATOM line in pdb format
#include <regex>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string line {"ATOM 1 N ILE C 1 31.399 11.874 36.182 1.00 0.00"};
@GeauxEric
GeauxEric / check_output.cpp
Last active October 2, 2015 18:05
a cpp snippets like the subprocess32.check_output in python
#include <string>
#include <iostream>
#include <stdio.h>
/**
* \file check_output.cpp
* \brief a cpp function just like the subprocess32.check_output() in python
*
* see http://stackoverflow.com/questions/478898/how-to-execute-a-command-and-get-output-of-command-within-c
*
@GeauxEric
GeauxEric / stream.scm
Last active September 5, 2015 07:03
3.53 ~ 3.54 sicp
(define (add-stream s1 s2)
(stream-map + s1 s2))
(define s (cons-stream 1 (add-stream s s)))
(stream-ref s 2)
(stream-ref s 5)
(define (mul-stream s1 s2)
(stream-map * s1 s2))
@GeauxEric
GeauxEric / submit.pbs
Created June 23, 2015 18:15
submit pbs job
#!/bin/bash
#PBS -q workq
#PBS -j oe
## user specified
#PBS -l nodes=1:ppn=16
#PBS -l walltime=72:00:00
#send an email after job aborts or ends
#PBS -M yding8@lsu.edu
@GeauxEric
GeauxEric / readReport.py
Last active August 29, 2015 14:23
read the report of GeauxDock
import re
def readReport(fn):
"""
read the report file generated by running docking and extract the
"""
ifn = fn
lines = open(ifn, 'r').readlines()
pattern = 'temp #'
temps = [float(line.split()[-1]) for line in lines if re.match(pattern, line)]
@GeauxEric
GeauxEric / impute
Created June 4, 2015 05:27
Impute missing value
# see http://stackoverflow.com/questions/25239958/impute-categorical-missing-values-in-scikit-learn/25562948#25562948
import pandas as pd
import numpy as np
from sklearn.base import TransformerMixin
class DataFrameImputer(TransformerMixin):
def __init__(self):