This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import os | |
import sys | |
import subprocess | |
import argparse | |
def main(work_dir, target_ext, from_encoding, to_encoding): | |
for current_dir, dirnames, fnames in os.walk(work_dir): |
This file contains hidden or 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
# Transforming the vanilla recursive fib into the iterative DP version | |
# through a series of mechanical steps. | |
# | |
# For more on converting recursive algorithms into iterative ones, see: | |
# http://blog.moertel.com/posts/2013-05-11-recursive-to-iterative.html | |
# original function | |
def fib(n): |
This file contains hidden or 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
def fib(n): | |
if n < 2: | |
return 1 | |
return fib(n-1) + fib(n-2) | |
def tail_fib(n, a=1, b=1): | |
if n < 2: | |
return b | |
This file contains hidden or 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
def isPrime(n): | |
""" | |
naive prime number checker | |
return True if `n` is a prime number, False otherwise | |
""" | |
if n < 2: | |
return False | |
for i in range(2, n-1): |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Example of `futures` module in python3 | |
""" | |
from __future__ import print_function | |
import sys | |
from time import time | |
# check version |
This file contains hidden or 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
-- http://learnyouahaskell.com/functionally-solving-problems | |
-- Reverse Polish notation calculator | |
import System.IO (hFlush, stdout) | |
import Text.Read (readMaybe) | |
main :: IO() | |
main = do | |
putStr "Enter an expression " | |
hFlush stdout | |
userInput <- getLine |
This file contains hidden or 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
from __future__ import print_function | |
from copy import copy, deepcopy | |
l = [[1, 2, 3], [3, 4, 5],[4, 5, 6]] | |
shallow_l = copy(l) | |
deep_l = deepcopy(l) | |
l[0].append(4) | |
print(shallow_l) | |
# >> [[1, 2, 3, 4], [3, 4, 5], [4, 5, 6]] |
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import division, print_function | |
import sys | |
import os | |
import cv2 | |
import numpy as np | |
def hist_eq(img): | |
data = img.copy().flatten() |
This file contains hidden or 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
// | |
// dlib_ios.h | |
// TryDlibVideoStream | |
// | |
// Created by DboyLiao on 13/03/2017. | |
// | |
#ifndef dlib_ios_h | |
#define dlib_ios_h |
This file contains hidden or 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
// | |
// dlib_ios.m | |
// TryDlibVideoStream | |
// | |
// Created by DboyLiao on 13/03/2017. | |
// | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
#include "dlib_ios.h" |