Skip to content

Instantly share code, notes, and snippets.

View jiacai2050's full-sized avatar
:atom:
Focusing

Jiacai Liu jiacai2050

:atom:
Focusing
View GitHub Profile
@jiacai2050
jiacai2050 / tmux-cheatsheet.markdown
Created June 12, 2016 03:02 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@jiacai2050
jiacai2050 / gist:00ba4f8bdd6c9c37c812803ca7af846b
Created July 13, 2016 12:51 — forked from drorata/gist:146ce50807d16fd4a6aa
Minimal Working example of Elasticsearch scrolling using Python client
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from datetime import datetime
from os import path
import smtplib
import sys
@jiacai2050
jiacai2050 / reflect.py
Created August 11, 2016 02:06 — forked from mgoodness/reflect.py
Python HTTP server that echos GET requests
#!/usr/bin/env python
# Reflects the requests from HTTP GET methods
# Written by Nathan Hamiel (2010), modified by Michael Goodness (2015)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from argparse import ArgumentParser
from urlparse import urlparse
import daemon
import socket
#!/usr/bin/env python
#-*- coding=utf-8 -*-
import requests
import re
import os
import copy
host = 'v2ex.com'
headers = {
@jiacai2050
jiacai2050 / 0. description.md
Created November 21, 2016 15:55 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.

Note: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,

@jiacai2050
jiacai2050 / gist:13b1b45af7349a3ff6d2a79bdd37f7f5
Created May 16, 2017 10:09 — forked from daviesian/gist:4517859
Code to redirect output nrepl output to a particular client repl.
;; After connecting an nrepl client repl to an nrepl server, some
;; output will still appear on stdout from the server.
;; Try these snippets - they will both produce output on the nrepl server
;; Java libraries commonly do both these things.
(.println System/out "Hello stdout.")
(.start (Thread. #(println "Hello from a new thread.")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@jiacai2050
jiacai2050 / CacheTest.java
Created September 6, 2017 04:10
guava caffeine 性能测试
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.yahoo.ycsb.generator.NumberGenerator;
import com.yahoo.ycsb.generator.ScrambledZipfianGenerator;
import junit.framework.TestCase;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.text.NumberFormat;
(ns demo.record
(:require [criterium.core :refer [bench with-progress-reporting]]))
(def a-z-ks (map (comp keyword str) (seq "abcdefghijklmnopqrstuwvxyz")))
(def dummy-map (zipmap a-z-ks (range)))
(defmacro alphabet-macro []
`(do
(defrecord ~'Alphabet [~@(map (comp symbol str) a-z-ks)])
(def ~'dummy-record (~'Alphabet. ~@(range 26)))))