This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/ugly-number-ii/ | |
class Solution(object): | |
def nthUglyNumber(self, n): | |
""" | |
:type n: int | |
:rtype: int | |
""" | |
if n < 5: | |
return n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import pybel | |
def squared_distance(coordsA, coordsB): | |
"""Find the squared distance between two 3-tuples""" | |
sqrdist = sum((a - b)**2 for a, b in zip(coordsA, coordsB)) | |
return sqrdist | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = u'(-1.234, 12]' | |
import re | |
print re.findall(r'[+-]?\d+\.*\d*', s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- thanks to https://github.com/Saynah --> | |
<script> | |
var code_show=true; //true -> hide code at first | |
function code_toggle() { | |
$('div.prompt').hide(); // always hide prompt | |
if (code_show){ |
OlderNewer