Skip to content

Instantly share code, notes, and snippets.

View lotabout's full-sized avatar

Jinzhou Zhang lotabout

View GitHub Profile
@lotabout
lotabout / crawler_dribbble.py
Created January 17, 2016 14:08
A crawler for dribbble.com
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import re
import os
import json
import logging
import traceback
@lotabout
lotabout / prophet-links.js
Last active September 21, 2020 09:47
Add links to prophet
@lotabout
lotabout / SpringApplication.java
Created August 26, 2019 06:42
How to add an additional connector in spring boot's application?
import org.apache.catalina.connector.Connector;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class SpringApplication {
@lotabout
lotabout / MyBenchmark.java
Created May 26, 2019 10:07
Java UUID Benchmark
package me.lotabout;
import com.fasterxml.uuid.Generators;
import com.fasterxml.uuid.impl.RandomBasedGenerator;
import com.fasterxml.uuid.impl.TimeBasedGenerator;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class SyncTest {
private enum TestType {
SYNCHRONIZED, VOLATILE, ATOMIC, LOCK, FAIR_LOCK
@lotabout
lotabout / ConcurrencyTest.java
Last active August 20, 2018 14:41
Test the performance of different concurrency mechanism.
import sun.misc.Unsafe;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;
public class ConcurrencyTest {
private enum TestType {
@lotabout
lotabout / neural-network.py
Created March 14, 2018 07:43
implementation of backpropogation algorithm
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# implementation of backpropogation algorithm based on
# http://neuralnetworksanddeeplearning.com/chap1.html
#
# note that mini-batches are calculated in matrix form
import numpy as np
import random
@lotabout
lotabout / timed-log.py
Created May 2, 2018 05:10
Add timestamp to log
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from datetime import datetime
import fileinput
for line in fileinput.input():
print(f'[{datetime.now()}] {line}', end='')
@lotabout
lotabout / DCWGAN.py
Created March 29, 2018 08:53
WGAN implementation
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import torch.nn as nn
import torch
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from torch.autograd import Variable, grad
import torch.optim as optim
import torchvision.utils as vutils
@lotabout
lotabout / decision-tree.py
Last active March 15, 2018 01:42
Implement decision tree
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
class DecisionTree(object):
def __init__(self, data, method="naive"):
"""Learn a decision tree from data and label
:data: List[List[val]], a list contains M sample, each sample is represented by a List
The last column of the sample is the label