Skip to content

Instantly share code, notes, and snippets.

View LaserPhaser's full-sized avatar
⛑️
SNAFU

Laser LaserPhaser

⛑️
SNAFU
  • The dark side of the Moon
View GitHub Profile
import pandas as pd
import datetime
import csv
import matplotlib.pyplot as plt
headers = ['Date','time']
def time_convert(x):
h,m,s = map(int,x.split(':'))
return (h*60+m)*60+s
#include <Python.h>
long long
_fib(long long n) {
if (n < 2)
return n;
else
return _fib(n - 1) + _fib(n - 2);
}
static PyObject *
fib(PyObject *self, PyObject *args) {
@LaserPhaser
LaserPhaser / fib.py
Last active February 19, 2018 11:48
def fib_recursive(n):
if n <= 1:
return n
return fib_recursive(n - 1) + fib_recursive(n - 2)
@LaserPhaser
LaserPhaser / tree_drawer.py
Last active January 12, 2018 14:56
Python function that will draw tree structure recursively from the given folder (optionally with/without listing files)
import os
class Node():
def __init__(self):
self.name = None
self.files = []
self.sub_folders = []
self.drawn = False
self.parent = None
@LaserPhaser
LaserPhaser / read_to_stdin.py
Created March 22, 2017 07:07
Read file to STDIN python, amazingly helpful function for Pycharm debug
import sys
from io import StringIO
def read_to_stdin():
"""
Helper function for read file as stdin,
Very helpful for Pycharm debug, because Pycharm does not support input redirection
"""
stdin = "".join(open('filename', "r").readlines())