Skip to content

Instantly share code, notes, and snippets.

@kevinclcn
kevinclcn / webcrawler.go
Last active March 18, 2018 01:06
golang tutorial web crawler
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@kevinclcn
kevinclcn / check_mysql.sh
Created March 9, 2018 05:29 — forked from lefred/check_mysql.sh
MySQL InnoDB Cluster Consul check
# script used in consul
# the following addition to sys is required:
# https://gist.github.com/lefred/153448f7ea0341d6d0daa2738db6fcd8
# v.0.1 - lefred 2018-02-14
read -r mysql_primary mysql_readonly mysql_tx mysql_cert <<<$(mysql -h 127.0.0.1 -P 6446 -BNe "select * from sys.gr_member_routing_candidate_status")
if [[ "${mysql_primary}" == "YES" ]] && [[ "${mysql_readonly}" == "NO" ]]
then
@kevinclcn
kevinclcn / check_async_mysql.sh
Created March 9, 2018 05:29 — forked from lefred/check_async_mysql.sh
Consul Asynchronous Slave Check
# script used in consul to check if mysql is primary master and asynchronous slave
# v.0.1 - lefred 2018-02-16
SLAVEOFDC="dc2"
SLAVEUSER="async_repl"
SLAVEPWD="asyncpwd"
# check if we are the primary one
ROLE=$(mysql -h 127.0.0.1 -BNe "select MEMBER_ROLE from performance_schema.replication_group_members where MEMBER_HOST=@@hostname")
/*
* Main.java
*
* Created on 27 August 2007, 11:11
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package hotthread;

Go vs. Scala (Akka) Concurrency

A comparison from 2 weeks using Go.

Actors vs. Functions

Akka's central principle is that there you have an ActorSystem which runs Actors. An Actor is defined as a class and it has a method to receive messages.

@kevinclcn
kevinclcn / CacheConfig.java
Created February 16, 2016 14:45 — forked from snicoll/CacheConfig.java
Guava cache with spring boot and clear cache method
import com.google.common.cache.CacheBuilder;
import org.springframework.cache.Cache;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCache;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
@Configuration
@kevinclcn
kevinclcn / CacheConfig.java
Created February 16, 2016 14:37 — forked from anataliocs/CacheConfig.java
Guava cache with spring boot and clear cache method
import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCache;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
@kevinclcn
kevinclcn / curl.md
Last active September 18, 2015 01:36 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@kevinclcn
kevinclcn / gist:d9855da3fb8368f02800
Last active September 14, 2015 14:01 — forked from javiervidal/gist:1433880
To access url helpers (url_for, etc) from Rails console (Rails 3)
include Rails.application.routes.url_helpers
default_url_options[:host] = "localhost"
@kevinclcn
kevinclcn / README.md
Last active August 26, 2015 14:02 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default and default-ssl to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/