Skip to content

Instantly share code, notes, and snippets.

@losingle
losingle / TxDontLoseMessages.java
Created May 4, 2012 08:57 — forked from scvalex/TxDontLoseMessages.java
Don't lose messages with RabbitMQ Transactions
// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
@losingle
losingle / ejabberd_auth.rb
Created June 25, 2012 16:52 — forked from abarringer/ejabberd_auth.rb
ejabberd external authentication in ruby
#!/usr/bin/env ruby
require 'logger'
require 'rest_client'
$stdout.sync = true
$stdin.sync = true
path = "/usr/local/var/log/ejabberd/auth.log"
file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
@losingle
losingle / wawammseg.py
Created June 30, 2012 09:45 — forked from onlytiancai/wawammseg.py
写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码
# -*- coding:utf-8 -*-
'写了一个简单的支持中文的正向最大匹配的机械分词,其它不用解释了,就几十行代码'
'搜狗词库下载地址:http://vdisk.weibo.com/s/7RlE5'
import string
__dict = {}
def load_dict(dict_file='words.dic'):
'加载词库,把词库加载成一个key为首字符,value为相关词的列表的字典'
@losingle
losingle / upyun.rb
Created August 11, 2012 13:50 — forked from huobazi/upyun.rb
upyun-ruby-api
# -*- coding: utf-8 -*-
#
# :author yugi
# :email gccyugi@gmail.com
# :update 2012/5/18 14:56
module UpyunHttpMixin
def md5(s)
require 'digest/md5'
@losingle
losingle / zsh.md
Created August 21, 2012 03:14 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu

Install zsh

apt-get install zsh

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

and then you change your shell to zsh

@losingle
losingle / data.json
Created September 11, 2012 09:57
javascript mentions(模拟新浪微博@功能)
[{"uname":"中文"},{"uname":"hello"}]
@losingle
losingle / squirrel.custom.yaml
Created September 19, 2012 09:50 — forked from lotem/squirrel.custom.yaml
【鼠鬚管】定製檔
# 適用於【鼠鬚管】0.9.6+
# 位置:~/Library/Rime/squirrel.custom.yaml
# 用法:想要哪項生效,就刪去該行行首的#字符,但注意保留用於縮進的空格
patch:
# us_keyboard_layout: true # 鍵盤選項:應用美式鍵盤佈局
# style/horizontal: true # 候選窗横向顯示
# style/font_face: "儷黑 Pro" # 我喜歡的字體名稱
# style/font_point: 21 # 字號
# style/corner_radius: 10 # 窗口圓角半徑
@losingle
losingle / README.markdown
Created September 21, 2012 16:29 — forked from greypants/README.markdown
RAILS 3: nav_link helper for adding 'selected' class to navigation elements

#Behold, the nav_link:

The nav_link helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link.

For full usage details, see: http://viget.com/extend/rails-selected-nav-link-helper

Drop nav_link_helper.rb into app/helpers in your Rails 3.x app and enjoy.

@losingle
losingle / debugger.markdown
Created September 21, 2012 19:06 — forked from jcasimir/debugger.markdown
Ruby Debugger

Ruby Debugger

Most of the time simple output statements using warn, raise, or a logger will help you find your issue. But sometimes you need the big guns, and that means ruby-debug.

Ruby-Debug

The ruby-debug package has had some rocky times during the transition from Ruby 1.8.7 to 1.9.2 and beyond. But now, finally, the debugger is reliable and usable.

Installation

/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {