Skip to content

Instantly share code, notes, and snippets.

@scheakur
scheakur / array.sh
Created March 7, 2016 09:49
array.sh
a1=(
hoge
fuga
piyo
)
a2=(foo "${a1[@]}")
echo ${#a2[@]} # => 4
echo ${a2[1]} # => hoge
@scheakur
scheakur / like-ruby-new.js
Created February 8, 2015 07:29
like-ruby-new.js
#! 6to5-node
'use strict';
class Struct {
static new(...props) {
return class {
static new(...args) {
return new this(...args);
@scheakur
scheakur / like-ruby-struct-new.js
Last active August 29, 2015 14:15
like-ruby-struct-new.js
#! iojs --harmony
'use strict';
class Struct {
static new() {
var props = Array.prototype.slice.call(arguments);
return class {
constructor() {
@scheakur
scheakur / build.gradle
Created July 12, 2014 00:15
Spring Boot + Spring Loaded + Gradle + IntelliJ IDEA = Awesome
buildscript {
repositories {
mavenCentral()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.4.RELEASE")
classpath("org.springframework:springloaded:1.2.0.RELEASE")
}
function git() {
if [[ $1 == "clone" ]]; then
shift
ghq get $@
else
command git $@
fi
}
function! s:complete_log(findstart, base)
if a:findstart == 1
return col('.')
endif
let cmd = '\git log --pretty=format:%s --author=`\git config user.name` -30'
return split(system(cmd), '\n')
endfunction
MY=~/Applications/MyFirefoxNightly.app
ORIG=/Applications/FirefoxNightly.app
mkdir -p $MY/Contents/MacOS
mkdir -p $MY/Contents/Resources
cp $ORIG/Contents/Resources/firefox.icns $MY/Contents/Resources
cat <<EOS > $MY/Contents/MacOS/firefox.sh
#!/bin/sh
open -a $ORIG --args -P Nightly -no-remote
EOS
chmod +x $MY/Contents/MacOS/firefox.sh
@Grapes(@Grab('org.jsoup:jsoup:1.7.3'))
import org.jsoup.Jsoup;
def text = Jsoup.parse('''
<div>
<div class="foo">hoge</div>
<div class="bar">fuga</div>
<div class="foo">piyo</div>
</div>
''').select('.foo').text()
import java.net.URL;
import java.security.Security;
public class Test3 {
public static void main(String... args) throws Exception {
Security.setProperty("networkaddress.cache.ttl" , "0");
URL url = new URL("http://google.com");
for (int i = 0; i < 100; i++) {
System.out.println(url.equals(new URL("http://google.com")));
import sun.net.InetAddressCachePolicy;
import java.lang.reflect.Field;
public class Test2 {
public static void main(String... args) throws Exception {
Field f = InetAddressCachePolicy.class.getDeclaredField("cachePolicy");
f.setAccessible(true);
System.out.println(f.get(null));
}