Skip to content

Instantly share code, notes, and snippets.

@nantsou
nantsou / MergeSort.java
Created October 22, 2015 04:41
Merge Sort Practice
package openhome.algorithm.sorting;
import java.util.*;
public class MergeSort {
private static void merge(int[] first, int[] second, int[] result) {
int iFirst = 0;
int iSecond = 0;
int j = 0;
import java.util.Comparator;
import java.util.PriorityQueue;
class MedianFinder {
private PriorityQueue<Integer> lH;
private PriorityQueue<Integer> rH;
public MedianFinder() {
lH = new PriorityQueue<Integer>(11, new Comparator<Integer>() {
@Override
import java.util.Map;
public class Trie {
private TrieNode root;
public Trie() {
root = new TrieNode();
}
public void insert(String word) {
Map<Character, TrieNode> children = root.children;
for (int i = 0; i < word.length(); i++) {
import java.util.HashMap;
import java.util.Map;
public class TrieNode {
char c;
Map<Character, TrieNode> children = new HashMap<Character, TrieNode>();
boolean isWord;
public TrieNode() {}
public TrieNode(char c) {this.c = c;}
}
import java.util.Map;
import java.util.HashMap;
//public class DoubleLinkedListNode {
// public int val;
// public int key;
// public DoubleLinkedListNode pre;
// public DoubleLinkedListNode next;
// public DoubleLinkedListNode(int key, int value) {
// this.key = key;
// val = value;
@nantsou
nantsou / github.py
Created March 30, 2017 16:30
pygments github style
# -*- coding: utf-8 -*-
"""
github
~~~~~~
Port of the github color scheme.
Based upon the pygments-style-railscasts_ of Marcus Fredriksson.
.. _pygments-style-railscasts: http://github.com/DrMegahertz/pygments-style-railscasts
.codehilite pre .hll { background-color: #ffffcc }
.codehilite pre { background: #f6f8fa; font-family: Monaco, Menlo, "Ubuntu Mono", Consolas, source-code-pro, monospace !important;}
.codehilite pre .c { color: #999988; font-style: italic } /* Comment */
.codehilite pre .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.codehilite pre .k { color: #000000; font-weight: bold } /* Keyword */
.codehilite pre .o { color: #000000; font-weight: bold } /* Operator */
.codehilite pre .ch { color: #999988; font-style: italic } /* Comment.Hashbang */
.codehilite pre .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.codehilite pre .cp { color: #999999; font-weight: bold; font-style: italic } /* Comment.Preproc */
.codehilite pre .cpf { color: #999988; font-style: italic } /* Comment.PreprocFile */
@nantsou
nantsou / blocks.py
Last active July 10, 2018 13:29
Code Block with Pygments and Ace editor for Wagtail
# django
from django import forms
from django.utils.safestring import mark_safe
from django.utils.functional import cached_property
# wagtail
from wagtail.wagtailcore.blocks import (TextBlock,
StructBlock,
CharBlock,
ChoiceBlock)
# 3rd party
upstream example_server {
server unix:/the/path/to/the/applicatoin/sock/example.sock fail_timeout=0;
}
server {
listen 80;
server_name example.com;
client_max_body_size 4G;
upstream example_server {
server unix:/the/path/to/the/applicatoin/sock/example.sock fail_timeout=0;
}
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}