Skip to content

Instantly share code, notes, and snippets.


Donny donnior

View GitHub Profile
donnior / logback.xml
Created Jun 24, 2019
For one package with logback, error only for console appender, but support info for file appender.
View logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="ErrorOnlyConsole" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">


git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done


find . -name '*.java' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
donnior /
Last active Dec 25, 2015
Benchmark for safe incrementing a long value with Lock And Atomic
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
public class LockVsAtomic {
protected final ReentrantLock lock = new ReentrantLock();
private volatile long l1 = 0l;
private AtomicLong l2 = new AtomicLong(0l);
donnior / gist:4123259
Created Nov 21, 2012 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts
View gist:4123259

Sublime Text 2 – Useful Shortcuts (Mac OS X)


⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
donnior /
Created Feb 24, 2012 — forked from JeanMertz/
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: """
def on_load(self, view):
filename = view.file_name()
donnior / gist:1588907
Created Jan 10, 2012
View gist:1588907
Mime::Type.register_alias "text/html", :iphone
#Make a copy of app/views/layouts/application.html.erb calling it application.iphone.erb
#Make copies of the necessary view files in your controllers, calling them things like index.iphone.erb
#in Controller
respond_to :html, :iphone
donnior / gist:1531947
Created Dec 29, 2011 — forked from JeffreyWay/gist:1525217
Instant Server for Current Directory
View gist:1531947
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
donnior / How to change Application's language under Mac.applescript
Created Dec 16, 2011
How to change Application's language under Mac
View How to change Application's language under Mac.applescript
#change some specific application's interface language
defaults write AppleLanguages "(zh_CN,en_US)"
defaults write AppleLanguages "(zh_CN,en_US)"
defaults write AppleLanguages "(zh_CN,en_US)"
#change all applications' interface language, don't recommend.
defaults write NSGlobalDomain AppleLanguages "(en_US,zh_CN)"
defaults write NSGlobalDomain AppleLanguages "(zh_CN,en_US)"
View Html Parse with Nokogiri.rb
require 'rubygems'
require 'nokogiri'
require 'open-uri'
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.854.0 Safari/535.2"
html = ""
@doc = Nokogiri::HTML(open(html, 'User-Agent' => user_agent), nil, "UTF-8")
@doc.xpath("//li[a[text()='Home']]/following-sibling::li").each do |link|