Skip to content

Instantly share code, notes, and snippets.

View mikkkee's full-sized avatar
🐰
Working all day

Jiefu mikkkee

🐰
Working all day
View GitHub Profile
// Package p contains an HTTP Cloud Function.
package p
import (
"encoding/json"
"fmt"
"net/http"
"sort"
"strings"
@mikkkee
mikkkee / vaspsol.out
Created August 20, 2016 07:42
VASPsol compilation error
main.o: In function `MAIN__':
main.f90:(.text+0xf73f): undefined reference to `sol_writer_'
pot.o: In function `pot_mp_potlok_':
pot.f90:(.text+0x1b1e): undefined reference to `sol_vcorrection_'
make: *** [vasp] Error 1
@mikkkee
mikkkee / CPP_SO.md
Last active March 4, 2022 09:23
Helpful C++ questions on stackoverflow

Questions

  • [When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?][1]
  • [What are the basic rules and idioms for operator overloading in C++?][2]
  • [Why would one replace default new and delete operators?][3]
  • [What is the copy-and-swap idiom?][4]
  • [What is the difference between #include and #include “filename”?][5]
  • [What can I use to profile C++ code in Linux?][6]
  • [C++ multithreading?][7]
  • [When and how should dynamic memory allocation and pointers be used?][8]
@mikkkee
mikkkee / HDB_Resale_Price.ipynb
Created December 24, 2015 15:12
Analysis on HDB flat resale price in Singapore from 2000 to 2015.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikkkee
mikkkee / MSVS.OpenCV.setup.md
Created December 7, 2015 05:33
hecklist for setting up MicroSoft Visual Studio to work with OpenCV

Checklist for setting up MicroSoft Visual Studio to work with OpenCV

  1. Download [OpenCV][1] and extract it to desired directory, for example D:\opencv.
  2. Set up environment variables for Windows:
    1. OPENCV_DIR = D:\opencv\build
    2. Add %OPENDC_DIR%\x86\vc12\bin to PATH
  3. Set up properties of MicroSoft Visual Studio project (Only works for OpenCV 3, need to add [more files][2] in step iv for OpenCV 2):
    1. Right click on project name in Solution Explorer and choose Properties.
    2. In Configuration Properties -> C/C++ -> General -> Additional Include Directories,
@mikkkee
mikkkee / spinning_cursor.py
Created November 12, 2015 07:48
Spinning cursor and progress bar in console (Python)
"""
Create a spinning cursor or progress bar in terminal can be useful
for some scripts.
1. Use '\r' to move cursor back to the line beginning. Or use '\b'
to erase the last character.
2. The standard out of Python is buffered, which means it will
collect some data written to standard out before it actually
writes to the terminal.
The code snippet
@mikkkee
mikkkee / 1-overview.md
Created November 10, 2015 11:39
6.028 lecture notes

6.828 2014 L1: O/S overview

Overview

  • 6.828 goals
    • Understand operating systems in detail by designing and implementing a small O/S
    • Hands-on experience with building systems ("Applying 6.033")
@mikkkee
mikkkee / requests_TLSv1.py
Created November 5, 2015 11:21
Force requests to usd TLSv1
# SSLError: EOF occurred in violation of protocol
# https://github.com/kennethreitz/requests/issues/1083#issuecomment-11853729
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
import ssl
class MyAdapter(HTTPAdapter):
def init_poolmanager(self, connections, maxsize):
self.poolmanager = PoolManager(num_pools=connections,
@mikkkee
mikkkee / read_n.py
Last active July 14, 2016 02:23
Read file N lines at a time
import string
from itertools import islice
def next_n_lines(file_opened, N, strip='right'):
'''
Each call of this function returns next N lines of fileopen.
Usage:
strip='right' -> remove trailing whitespace characters in each line,
strip='left' -> remove leading whitespace characters in each line,
@mikkkee
mikkkee / chunks.py
Created August 25, 2015 15:44
Cut list into chunks
# Cut list into chunks.
def chunk(to_cut,piece_number):
'''
Cut list into equalily distributed pieces.
'''
piece_len = len(to_cut)/piece_number
for i in xrange(0,len(to_cut),piece_len):
yield to_cut[i:i+piece_len]