Skip to content

Instantly share code, notes, and snippets.

@kavinyao
kavinyao / readme.md
Created Jul 19, 2020
Enable Ligature in wsltty
View readme.md

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 Jul 27, 2018
Go practice with JSON, TCP networking, file system, command-line flag parsing
View client.go
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"net"
"os"
"strconv"
View 中文编程.py
#!/usr/bin/env python3
from enum import Enum
from random import choice
def 做(事情):
事情()
def 如果(条件成立, 那么做, 动作1, 不然就做, 动作2):
if 条件成立:
View ExecutorServiceExceptionDemo.java
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
* Demo of exception handling in ExecutorService.
*/
public class ExecutorServiceExceptionDemo {
/**
View exercises.rb
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 }
View decimal-zip.cpp
#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;
View find-median.cpp
#include <iostream>
using namespace std;
void swap(int A[], int i, int j)
{
int temp = A[i];
A[i] = A[j];
A[j] = temp;
}
View overlap.c
#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 Nov 14, 2013
Rudimentary BST in Python.
View bst.py
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
View progress_bar.py
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.