Skip to content

Instantly share code, notes, and snippets.

View int128's full-sized avatar

Hidetake Iwata int128

View GitHub Profile
def x = {}
def y = {}
def a = [k: x, l: 0, m: 'a']
def b = [k: y, l: 1]
println x
println y
println a
println b
@int128
int128 / gist:10613715
Last active August 29, 2015 13:59
Create an immutable object by a closure instead of the hash constructor
class ImmutableFactory<T> {
private final Map<String, Object> propertiesMap = [:]
private final Class<T> clazz
def ImmutableFactory(Class<T> clazz) {
this.clazz = clazz
}
T create() {
@int128
int128 / immutable.groovy
Last active August 29, 2015 13:59
could not initialize immutable in immutable by map
@groovy.transform.Immutable
class A {
int x
}
@groovy.transform.Immutable
class B {
int y
@Delegate
A a = new A([:])
@int128
int128 / plus-settings.groovy
Last active August 29, 2015 13:59
Enumerate properties of an object using meta class
class S {
def propertiesAsMap() {
this.metaClass.properties.collectEntries { p ->
[(p.name): p.modifiers]
}
}
}
class A extends S {
static int DEFAULT
@int128
int128 / gist:11244516
Created April 24, 2014 07:10
Macro to trim or append trailing LF
Sub TrimTrailingLFInSelection()
Dim c As Range
For Each c In Selection
If Right(c.Text, 1) = vbLf Then
c.Value = Left(c.Text, Len(c.Text) - 1)
End If
Next
@int128
int128 / gist:1be8b651c3f42fa03858
Created May 10, 2014 01:57
@javax.inject.Inject does not work on Gradle plugin
org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'SshTask'.
at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:126)
at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:121)
at org.gradle.api.internal.AbstractTask.injectIntoNewInstance(AbstractTask.java:148)
at org.gradle.api.internal.project.taskfactory.TaskFactory.createTaskObject(TaskFactory.java:121)
at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:81)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.createTask(AnnotationProcessingTaskFactory.java:99)
at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.createTask(DependencyAutoWireTaskFactory.java:39)
at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:52)
at org.gradle.api.internal.project.AbstractProject.task(AbstractProject.java:958)
@int128
int128 / gist:af097d5d5a82bc6dd4b6
Created May 22, 2014 14:43
Adding static property on runtime
@groovy.transform.ToString
class A {
//static final int P = 100
int x
}
A.metaClass.P = 100
def a = new A()
a.with {
@int128
int128 / 1000-policyroute.sh
Created July 5, 2014 13:07
/etc/ppp/ip-up.d/1000-policyroute.sh
#!/bin/sh
#
# This script is called with the following arguments:
# Arg Name Example
# $1 Interface name ppp0
# $2 The tty ttyS1
# $3 The link speed 38400
# $4 Local IP number 12.34.56.78
# $5 Peer IP number 12.34.56.99
@int128
int128 / init.sh
Created July 5, 2014 13:08
/boot/initramfs/content/init
#!/bin/sh
# initramfs script for Linux 2.6 LVM/RAID
echo -e “\x1b[1;32m *\x1b[0m Setting up filesystems”
/bin/mount -t proc none /proc
/bin/mount -t sysfs none /sys
/bin/mount -t tmpfs none /dev
/bin/mount -t tmpfs none /etc
/sbin/mdev -s

environment

  • Gentoo Linux
  • 2.6.31-gentoo-r10 (KVM hypervisor/KVM guest)
  • net-fs/nfs-utils-1.1.4-r1

/etc/auto.misc