Skip to content

Instantly share code, notes, and snippets.

View kavinyao's full-sized avatar

Kavin Yao kavinyao

View GitHub Profile
@kavinyao
kavinyao / readme.md
Created July 19, 2020 01:30
Enable Ligature in wsltty

Here we use wsltty as example. The same options can be applied to mintty too.

  1. Download wsltty
  2. Open properties of WSL Terminal shortcut, add -o LigaturesSupport=1 -o Ligatures=2 options. It should looks like below
C:\Users\<username>\AppData\Local\wsltty\bin\mintty.exe -o LigaturesSupport=1 -o Ligatures=2 --WSL= --configdir="C:\Users\<username>\AppData\Roaming\wsltty" -~  -
@kavinyao
kavinyao / client.go
Created July 27, 2018 08:46
Go practice with JSON, TCP networking, file system, command-line flag parsing
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"net"
"os"
"strconv"
#!/usr/bin/env python3
from enum import Enum
from random import choice
def 做(事情):
事情()
def 如果(条件成立, 那么做, 动作1, 不然就做, 动作2):
if 条件成立:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
* Demo of exception handling in ExecutorService.
*/
public class ExecutorServiceExceptionDemo {
/**
puts "Solution to 1:"
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].each { |num| puts num}
puts
puts "Solution to 2:"
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].each { |num| puts num if num > 5 }
puts
puts "Solution to 3:"
odds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].select {|num| num % 2 == 1 }
#include <iostream>
using namespace std;
class Solution {
public:
// complexity: O(log(A)+log(B)) time, O(1) space
// precondition: 0 <= A, B <= 100,000,000
int zip(int A, int B) {
if (A < 0 || A > 100000000) return -1;
#include <iostream>
using namespace std;
void swap(int A[], int i, int j)
{
int temp = A[i];
A[i] = A[j];
A[j] = temp;
}
#include <stdio.h>
int overlap_count(const char *s1, const char *s2)
{
const char *s1_begin = s1;
const char *p1, *p2;
while(*s1_begin != '\0') {
p1 = s1_begin;
p2 = s2;
@kavinyao
kavinyao / bst.py
Created November 14, 2013 20:06
Rudimentary BST in Python.
class Node(object):
"""A node in BST."""
def __init__(self, value, left_node=None, right_node=None):
self.value = value
self.left_node = left_node
self.right_node = right_node
def set_left(self, left_node):
self.left_node = left_node
import sys
import math
import time
def progress_bar(progress, col_width=80):
"""
Text progress bar in command line.
Pre-condition: the cursor is at a new line.
Post-condition: the cursor is at the end of the same line.