Skip to content

Instantly share code, notes, and snippets.

@miyakawataku
miyakawataku / webrick.sh
Last active August 29, 2015 13:57
Bash function to launch WEBrick HTTP Server
#!/usr/bin/env bash
# vim: et sw=2 sts=2
# Copyright (c) 2014 Miyakawa Taku
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# VBoxManage guestproperty set tigermilk "/VirtualBox/GuestAdd/VBoxService/-timesync-set-threshold" 2000
env LANG=C xdg-user-dirs-gtk-update
sudo apt-get update
sudo apt-get install puppet-module-puppetlabs-apt
sudo apt-get install mercurial
@miyakawataku
miyakawataku / Classpath.java
Created October 25, 2011 08:27
Output urls in the classpath
import java.net.URLClassLoader;
import java.net.URL;
class Classpath {
public static void main( String[] args ) {
URLClassLoader ucl = (URLClassLoader) Classpath.class.getClassLoader();
for ( URL url : ucl.getURLs() ) {
System.out.println( url );
}
}
}
@miyakawataku
miyakawataku / gist:1333483
Created November 2, 2011 12:12
Swing example on Kink
#!/usr/bin/env kink
# vim: et sw=4 sts=4
useclass('javax.swing.JFrame')
useclass('javax.swing.JButton')
useclass('javax.swing.JOptionPane')
&BUTTON = JButton.new('Push').via {
__.addActionListener {
JOptionPane.showMessageDialog(null 'You pushed!')
@miyakawataku
miyakawataku / gist:2833908
Created May 30, 2012 05:16
Mount an windows shared directory on /mnt/winhome
sudo /sbin/mount.cifs //192.168.51.1/Taku /mnt/winhome/ -o username=<UserName>,codepage=utf8,iocharset=utf8,uid=taku,gid=taku
@miyakawataku
miyakawataku / Sort.java
Created July 28, 2012 07:21
Sort an array of integers using an anonymous class or a lambda
import java.util.Arrays;
import java.util.Comparator;
public class Sort {
public static void main(String[] args) {
// [0, 1000) の整数列
Integer[] numbers = new Integer[10];
for (int index = 0; index < numbers.length; ++ index)
numbers[index] = (int) (Math.random() * 1000);
@miyakawataku
miyakawataku / gist:3892472
Created October 15, 2012 13:30
Transform a field of a data frame
transform(emp, nation2 = ifelse(nation == 'England', 'Eng', as.character(nation)))
@miyakawataku
miyakawataku / overwrite_dir_link.sh
Last active December 14, 2015 17:28
Overwrite a symbolic link of a directory.
@miyakawataku
miyakawataku / omron-ups.service
Created March 17, 2013 00:21
Systemd .service file for auto shutdown service (SimpleShutdown) of Omron UPS. Deploy the file into /etc/systemd/system and execute following commands. # systemctl enable omron-ups.service # systemctl start omron-ups
[Unit]
Description=Auto Shutdown Service (SimpleShutdown) for Omron UPS
[Service]
Type=forking
ExecStart=/usr/lib/ssd/master/ssdService
KillSignal=SIGUSR1
Restart=on-abort
RestartSec=4
@miyakawataku
miyakawataku / gist:5381972
Created April 14, 2013 08:42
find & grep from Vim commandline
command! -nargs=1 Grep call s:Grep(<f-args>)
function! s:Grep(command)
let orig_grepprg = &l:grepprg
let &l:grepprg = substitute(a:command, '|', '\\|', 'g')
grep
let &l:grepprg = orig_grepprg
endfunction