Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / .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 / 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