Skip to content

Instantly share code, notes, and snippets.

@xhh
xhh / HTMLLayout.java
Created January 23, 2010 14:45
Fix html-not-escaped bug with logback's HTMLLayout
import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
import org.apache.commons.lang.StringEscapeUtils;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.pattern.Converter;
/**
* Extend the {@link ch.qos.logback.classic.html.HTMLLayout} to escape HTML content.<br/>
* TODO remove when the bug if fixed by logback. See http://jira.qos.ch/browse/LBCLASSIC-180
@xhh
xhh / .Xdefaults
Created June 20, 2011 14:43
i3 config and Xdefaults samples
! ~/.Xdefaults
! xhh config for terminals e.g. urxvt
! For the latest version, check
! http://github.com/cooky/dotfiles_archlinux/blob/master/.Xdefaults
! normal settings
Xft.dpi: 96
Xft.antialias: true
Xft.rgba: rgb
Xft.hinting: true
@xhh
xhh / app.js.coffee
Created August 4, 2012 00:59
ember.js routing problem
window.App = Ember.Application.create
rootElement: '#container'
ApplicationController: Ember.ObjectController.extend()
ApplicationView: Ember.View.extend
templateName: 'application'
Router: Ember.Router.extend
root: Ember.Route.extend
home: Ember.Route.extend
@xhh
xhh / github.css
Created November 1, 2013 03:21
Github Markdown CSS - for Markdown Editor Preview (from https://gist.github.com/andyferra/2554919)
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@xhh
xhh / my_error.rb
Created June 16, 2015 13:37
Ruby - store custom attributes in extended error class
class MyError < StandardError
attr_reader :my_attr1, :my_attr2
# Usage examples:
# fail MyError.new
# fail MyError, "error message"
# fail MyError.new("error message")
# fail MyError.new(:my_attr1 => "hello", :my_attr2 => "world")
# fail MyError.new(:my_attr1 => "hello"), "error message"
# fail MyError.new(:message => "error message", :my_attr1 => "hello")
@xhh
xhh / keybase.md
Created September 23, 2015 08:17

Keybase proof

I hereby claim:

  • I am xhh on github.
  • I am xhh (https://keybase.io/xhh) on keybase.
  • I have a public key whose fingerprint is DA39 792E 3E51 743A 5BCA 49E1 F703 4D9F 9D65 BD6E

To claim this, I am signing this object:

@xhh
xhh / errocodeNX.md
Created March 11, 2017 03:01 — forked from dietmarkuehl/errocodeNX.md
error_code article

Defining and Using a Symbol Analogue for Error Reporting in C++

Abstract

The use of exceptions isn't a viable error handling approach in all cases and returning codes for error handling is sometimes preferable. However, using integral types for error identification is problematic as there is no good mechanism to guarantee that each value uniquely

@xhh
xhh / clojure_misc.clj
Last active March 1, 2020 13:07
some clojure code
(defmacro comp*
"The left-to-right version of comp.
Takes a set of functions and returns a fn that is the composition
of those fns. The returned fn takes a variable number of args,
applies the leftmost of fns to the args, the next
fn (left-to-right) to the result, etc."
[& fns]
`(comp ~@(reverse fns)))
@xhh
xhh / openpgp.md
Last active December 29, 2020 07:10
@xhh
xhh / ssl.rules
Created March 31, 2021 14:04 — forked from konklone/ssl.rules
nginx TLS / SSL configuration options for konklone.com
# Basically the nginx configuration I use at konklone.com.
# I check it using https://www.ssllabs.com/ssltest/analyze.html?d=konklone.com
#
# To provide feedback, please tweet at @konklone or email [email protected].
# Comments on gists don't notify the author.
#
# Thanks to WubTheCaptain (https://wubthecaptain.eu) for his help and ciphersuites.
# Thanks to Ilya Grigorik (https://www.igvita.com) for constant inspiration.
server {