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
@mikkkee
mikkkee / down_from_remote.py
Created October 20, 2014 08:22
Download files from a remote VPS and then download it to local machine.
#!/usr/bin/env python
from __future__ import print_function
import sys
import argparse
import shlex
import subprocess
def main(argv):
DOWNLOAD_DIR = 'LOCAL_DOWNLOAD_DIR'
USER = 'REMOTE_USER_NAME'
@mikkkee
mikkkee / cpp_oj_settings
Created May 22, 2015 04:39
Abbreviations used for C++
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
@mikkkee
mikkkee / balls_and_pockets.py
Last active August 29, 2015 14:23
A combination problem. Put balls into pockets, each can hold up to 2 balls, randomly. Get the average percentage of balls that are inside full pockets.
import random
class Pocket(object):
"""A pocket can hold up to 2 balls."""
def __init__(self, num):
self.num = num
self.member = []
self.limit = 2
@property
@mikkkee
mikkkee / commit_message_conventions.md
Last active August 29, 2015 14:23
How to write idiomatic git commit messages

How to Write a Git commit message

Define a commit message convention

  1. Style. Markup syntax, wrap margins, grammar, capitalization, punctuation. Spell these things out, remove the guesswork, and make it all as simple as possible. The end result will be a remarkably consistent log that's not only a pleasure to read but that actually does get read on a regular basis.
  2. Content. What kind of information should the body of the commit message (if any) contain? What should it not contain?
@mikkkee
mikkkee / text_parse.ipynb
Created July 1, 2015 03:42
How to parse a file using Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikkkee
mikkkee / Online_Resources_Web_Basics.md
Last active August 29, 2015 14:25
A collection of online resources (tutorials, online courses) to start as a Web Developer.
@mikkkee
mikkkee / running_time.ipynb
Created July 29, 2015 07:35
Running time of several search algorithms
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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]
@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 / 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")