This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// change to your hatena user name!!! | |
var HATENA_USERNAME = 'petitviolet'; | |
liberator.modules.commands.addUserCommand( | |
["hatena[bookmark]", "hb"], | |
"search from my hatena bookmarks", | |
function(args){ | |
if (args.length === 0) { | |
liberator.echo('input a query!'); | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: | |
# Show vim help anywhere! | |
# | |
# Commands: | |
# :help <keyword> - Show <keyword> vim help | |
require 'util' | |
module.exports = (robot) -> | |
robot.hear /:help\s*(.*)$/i, (msg) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object fizzbuzz { | |
def fizzbuzz(n: Int): Unit = { | |
} | |
def main(args: Array[String]) = { | |
val n: Int = args(0).toInt | |
for (i <- 1 to n){ | |
i match { | |
case i if i % 15 == 0 => println("fizzbuzz") | |
case i if i % 3 == 0 => println("fizz") | |
case i if i % 5 == 0 => println("buzz") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DATE_TIME=`date +"%Y%m%d-%H%M%S"` | |
FILE_NAME=${DATE_TIME}.png | |
TARGET_PATH="./" | |
SIZE="x480" | |
USAGE=" | |
Usage: "`basename $0`" -t [target_path] -s [size]\n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
loading() { | |
local count=30 | |
if [ $# -eq 1 ]; then | |
count=$1 | |
fi | |
for i in `seq 1 1 $count` | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// リフレクション使ってもともとsetしてあるonScrollのlistenerを取ってくる | |
AbsListView listView = (AbsListView) mParentScrollableView; | |
AbsListView.OnScrollListener onScrollListener = null; | |
Class<?> listViewClass = mParentScrollableView.getClass(); | |
try { | |
while (listViewClass != AbsListView.class) { | |
listViewClass = listViewClass.getSuperclass(); | |
} | |
// field名は決め打ち | |
Field field = listViewClass.getDeclaredField("mOnScrollListener"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReflectionUtil { | |
private Field extractField(Object target, String name) { | |
for (Field field : target.getClass().getDeclaredFields()) { | |
field.setAccessible(true); | |
if (name.equals(field.getName())) { | |
return field; | |
} | |
} | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.hamcrest.BaseMatcher; | |
import org.hamcrest.Description; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
class RegexStringMatcher extends BaseMatcher { | |
private final Pattern mExpectedPattern; | |
public RegexStringMatcher(String expected) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isPrime :: Integer -> Bool | |
isPrime n | |
| n <= 1 = False | |
isPrime n = not $ elem 0 [n `mod` x | x <- [2..floor $ fromIntegral n ** 0.5]] | |
primes :: [Integer] | |
primes = f[2..] where | |
f(p : ns) = p : f(filter isPrime ns) | |
-- f(p : ns) = p : f(filter ((/=0) . (`mod` p)) ns) |
OlderNewer