Skip to content

Instantly share code, notes, and snippets.

View sunng87's full-sized avatar
👑
keep calm and git push -f

Ning Sun sunng87

👑
keep calm and git push -f
View GitHub Profile
@sunng87
sunng87 / summary.py
Created November 15, 2011 09:58
simple hg extension to aggregate commit history by week
"""Display commit summary by week."""
import time
def summary(ui, repo, fs='', **opts):
"""Display commit summary by week"""
buckets = []
init_date = repo[0].date()[0]
now = time.time()
@sunng87
sunng87 / clspark.lisp
Created November 18, 2011 02:37
spark in common lisp
#!/usr/bin/clisp
(defconstant ticks (list "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"))
(defun spark (data-list)
(let ((max-value (apply #'max data-list))
(ticks-length (length ticks)))
(let ((ticks-unit (/ max-value (- ticks-length 1))))
(map 'list (lambda (x) (elt ticks (ceiling (/ x ticks-unit)))) data-list))))
[global]
### Display ###
# Which monitor should the notifications be displayed on.
monitor = 0
# Display notification on focused monitor. Possible modes are:
# mouse: follow mouse pointer
# keyboard: follow window with keyboard focus
# none: don't follow anything
@sunng87
sunng87 / results
Created July 19, 2012 06:31
TOP github users in China
imakewebthings | Caleb Troughton | #{"JavaScript" "CoffeeScript" "Ruby" "Python"} | 6840.0
flyerhzm | Richard Huang | #{"Java" "JavaScript" "Ruby"} | 3407.5
fredwu | Fred Wu | #{"JavaScript" "CoffeeScript" "PHP" "Ruby" "Python"} | 3226.0
kissyteam | kissyteam | #{"Java" "JavaScript" "PHP"} | 2138.0
JeffreyZhao | Jeffrey Zhao | #{"C#" "Java" "JavaScript" "CoffeeScript" "Ruby"} | 1943.0
livid | Xin Liu | #{"JavaScript" "Ruby" "Python"} | 1928.5
thoughtworks | ThoughtWorks Inc. | #{"Java" "C++" "JavaScript" "Objective-C" "Ruby" "Python"} | 1392.5
sofish | sofish | #{"Ja
(defn camelcase-to-delimitered [k delimeter]
(->> (clojure.string/split k #"(?=[A-Z])")
(map clojure.string/lower-case)
(clojure.string/join delimeter)))
(defn camelcase-to-delimitered-keys [m delimiter]
(let [trans (fn [[k v]]
(let [[strfn keyfn] (if (keyword? k)
[name keyword]
[identity identity])
INFO [epollEventLoopGroup-2-6] 2018-08-26 11:33:10,003 Message.java:623 - Unexpected exception during request; channel = [id: 0xf72d6e2f, L:/10.233.66.7:9042 - R:/10.233.65.7:48742]
io.netty.channel.unix.Errors$NativeIoException: readAddress() failed: Connection timed out
at io.netty.channel.unix.Errors.newIOException(Errors.java:117) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.unix.Errors.ioResult(Errors.java:138) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.unix.FileDescriptor.readAddress(FileDescriptor.java:175) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.epoll.AbstractEpollChannel.doReadBytes(AbstractEpollChannel.java:238) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:926) ~[netty-all-4.0.44.Final.jar:4.0.44.Final]
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:397
@sunng87
sunng87 / i3blocks_openweathermap.md
Last active August 21, 2018 22:54
i3blocks openweathermap

openweathermap for i3blocks

dependencies

  • i3blocks
  • httpie
  • jq
  • ttf-font-icons (aur)

configuration

@sunng87
sunng87 / Disney Wiki Crawler.cljs
Last active August 15, 2018 13:57
ClojureScript to download pages from Disney Wiki. Target to nodejs.
(ns crawler.core
(:require [cljs.nodejs :as node]))
(def http (node/require "http"))
(def fs (node/require "fs"))
(def local-path-root "out/")
(.mkdir fs local-path-root (fn [e]))
(defn start-req [url res-fn]
@sunng87
sunng87 / InfQueue.java
Created April 24, 2016 02:53
A file base blocking queue
import com.squareup.tape.FileObjectQueue;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
@sunng87
sunng87 / ip_only.py
Created June 29, 2013 09:45
Displaying IP address of wlan0 on LCD.
#!/usr/bin/python
from Adafruit_CharLCD import Adafruit_CharLCD
from subprocess import *
from time import sleep, strftime
from datetime import datetime
lcd = Adafruit_CharLCD()
cmd = "ip -4 addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1"