Skip to content

Instantly share code, notes, and snippets.

View monzou's full-sized avatar

Takuro Monji monzou

  • Tokyo
View GitHub Profile
@monzou
monzou / AESProtector.java
Last active December 19, 2015 02:49
Security Utilities
public final class AESProtector {
private static final Configuration CONFIGURATION;
static {
try {
CONFIGURATION = ConfigurationLoader.load(Configuration.class, "aes-security-policy.yml", "default-aes-security-policy.yml");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@monzou
monzou / users_router.coffee
Last active December 17, 2015 16:49
My little Backbone.js framework's Router sample.
class UsersRouter extends ResourceRouter
path: "users"
layout: "#contents"
routes:
":id": "show"
show: (id) ->
new User({id: id}).fetch success: (model) =>
@layoutView ShowView,
@monzou
monzou / form.coffee
Last active December 17, 2015 15:29
a little backbone-forms patch for supporting warning-level validation.
Form = Backbone.Form
Backbone.Form = class extends Form
commit: (options) ->
validationResults = @validate()
errors = _.filter validationResults, (result) -> result.level is "error"
return errors if errors and errors.length > 0
modelError = undefined
setOptions = _.extend {
error: (model, e) -> modelError = e if e.level is "error"
@monzou
monzou / backbone-select2-editor.coffee
Last active December 17, 2015 12:49
backbone-forms Select2 editor
Backbone.Form.editors.Select2 = class extends Backbone.Form.editors.Select
initialize: (options) ->
options.options or= []
super options
@config = _.extend { placeholder: '', allowClear: true }, @schema.select2 or {}
@$el.on "change", (e) => @focus() # retrieve focus !
@$el.on "select2-focus", (e) => @trigger "focus", @
@$el.on "select2-blur", (e) => @trigger "blur", @
#global-header {
.nav {
li.divider {
*width: 100%;
height: 1px;
margin: 0;
padding: 0;
background-color: darken($inverse, 30%);
&+li {
@monzou
monzou / build.gradle
Last active December 13, 2015 22:48
Gradle + Eclipse WTP でサードパーティライブラリのソースが見えるようにする
eclipse {
classpath {
file {
whenMerged { classpath ->
def webContainer = classpath.entries.find { it.path == 'org.eclipse.jst.j2ee.internal.web.container' }
if (webContainer != null) {
def projects = classpath.entries.findAll { it instanceof org.gradle.plugins.ide.eclipse.model.ProjectDependency }
def others = classpath.entries.findAll { it != webContainer }
others.removeAll(projects);
@monzou
monzou / build.gradle
Created February 17, 2013 09:59
Eclipse + Gradle Multi Project (flat layout)
apply plugin: 'eclipse'
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
jdkVersion = 1.7
sourceCompatibility = jdkVersion
targetCompatibility = jdkVersion
@monzou
monzou / UpdateVersion.groovy
Created December 12, 2012 02:07
tiny script
package xls;
import org.apache.poi.hssf.usermodel.HSSFWorkbook
class UpdateVersion {
static void main(args) {
def versionList = []
@monzou
monzou / GuavaMisc.java
Created November 20, 2012 01:59
guava misc
package sandbox;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@monzou
monzou / SimpleZipCompressor.java
Created October 26, 2012 10:22
SimpleZipFileCompressor
package sandbox;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;