Skip to content

Instantly share code, notes, and snippets.

@Carolusian
Carolusian / Remword2YouDao.scala
Created July 31, 2012 13:43
Export wordbook from remword to youdao dict
import org.eclipse.swt.SWT
import org.eclipse.swt.widgets.{Shell, Display, ToolItem, ToolBar, Listener, Event}
import org.eclipse.swt.browser.Browser
import org.eclipse.swt.layout._
import scala.util.matching.Regex
import scala.xml._
import org.w3c.tidy.Tidy
import java.io._
object Remword2YouDao {
@Carolusian
Carolusian / vectors_combine_rec.py
Last active August 29, 2015 14:03
A recursive approach to combine arbitrary number of vectors, real use case: compute the combination of SKU
# -*- coding: utf-8 -*-
"""
The is a recusive approach solving the vectors combination problem
"""
# Y for yellow, G for green
# 1 2 3 4 for size
# H for heavy, L for light, O for overweight
vectors = [['Y', 'G'],
[1, 2, 3, 4],
@Carolusian
Carolusian / ImapFolders.scala
Created July 17, 2014 08:16
List imap mail folders with parent and child relationship
/**
* List the with parent and child relationship
*/
object ImapFolders extends App {
val folders = List(
"mail201.udomain.com.hk.Winway",
"mail201.udomain.com.hk.Winway.Quota",
"mail201.udomain.com.hk.Winway.Delivery",
"mail201.udomain.com.hk.Winway.PO",
"mail201.udomain.com.hk.UA",
@Carolusian
Carolusian / backbone-notification.coffee
Last active August 29, 2015 14:04
Backbone.js Notifications: The Quick and Easy Way
window.NotificationView = Backbone.View.extend({
targetElement:'#message'
tagName: 'div'
className: 'notification'
defaultMessages:
'success': 'Success!'
@Carolusian
Carolusian / edgeslide.coffee
Created July 18, 2014 08:15
EShop slide for products: A slide show which, while display the current image, can show a edge of the next image. So users knows there are more images to be checked
$.fn.productSlide = (options) ->
settings =
width: 250
container: "slide-container"
# space left to display part of another photo
edge: 30
imageWidth: 190
settings = $.extend settings, options
@Carolusian
Carolusian / common.yaml
Created July 29, 2014 03:15
hiera configuration for openstack multiple nodes setup with puppetlabs module. Version: icehouse
openstack::region: 'openstack'
######## Networks
openstack::network::api: '192.168.100.0/24'
openstack::network::external: '192.168.100.0/24'
openstack::network::management: '10.10.10.0/24'
openstack::network::data: '10.20.20.0/24'
openstack::network::external::ippool::start: 192.168.100.100
openstack::network::external::ippool::end: 192.168.100.200
@Carolusian
Carolusian / play-app
Created August 5, 2014 03:53
A daemon script for playframework to run on linux
#!/bin/bash
#
# Playframework is amazing
#
# chkconfig: 2345 20 80
# description: Playframework initd script for udomain vmware api
#
# =========================================================================
# Copyright 2014 Rado Buransky, Dominion Marine Media
#
# Template composition with inclusion
Every template language I have seen provides some mechanism for one template to include another, thus supporting the reuse of repeated elements like headers and footers. The included templates are called partials in Mustache parlance:
```html
<!-- home.hbs -->
<html>
<body>
{{> header}}
<p> HOME </p>
{{> footer}}
@Carolusian
Carolusian / s.bash
Last active August 29, 2015 14:22 — forked from dapangmao/s.bash
sudo openvpn --config *.opvn
apt-get update
apt-get install vim
wget http://d3kbcqa49mib13.cloudfront.net/spark-1.3.0-bin-hadoop2.4.tgz | tar zxf
hadoop fs -mkdir /spark
hadoop fs -put spark-1.3.0-bin-hadoop2.4.tgz /spark
hadoop fs -du -h /spark
cp spark-env.sh.template spark-env.sh
@Carolusian
Carolusian / i18n-express-hbs-app.js
Last active August 29, 2015 14:26 — forked from mashpie/i18n-express-hbs-app.js
express + i18n-node + handlebars and avoid concurrency issues
// require modules
var express = require('express'),
i18n = require('i18n'),
hbs = require('hbs'),
app = module.exports = express();
i18n.configure({
locales: ['en', 'fr'],
cookie: 'locale',
directory: "" + __dirname + "/locales"