Skip to content

Instantly share code, notes, and snippets.

@kencoba
kencoba / download_activity.rb
Created August 31, 2020 11:05
Download Moodle activity data.
#!/usr/bin/env ruby
# usage: ruby download_activity.rb https://www.example.com/ app user passWd\! 12 result.csv
# caution : if your password includes bash's special character ,put a '\' before that char (ex: '!' is '\!').
require "tempfile"
require "uri"
moodle_site = ARGV[0]
app_root = ARGV[1]
username = ARGV[2]
@kencoba
kencoba / svnadmin.rb
Created August 30, 2020 11:16
(Experimental) adding user to Subversion.
# usage:
# $ sudo ruby ./svnadmin.rb #{account} #{password}
account=ARGV[0]
password=ARGV[1]
# create user account.
system "sudo adduser --gecos ',,,' --disabled-login --quiet #{account}"
puts "result of adduser"
@kencoba
kencoba / Arithmetic.scala
Created August 17, 2020 10:03
Sample code of "Creating DSL With Antlr4 and Scala" for Scala2.13
import java.io.ByteArrayInputStream
import org.antlr.v4.runtime.{CharStream, CharStreams, CommonTokenStream}
/**
* See original Saumitra's blog.
* https://saumitra.me/blog/creating-dsl-with-antlr4-and-scala/
*
* This code is for Scala 2.13.
*/
@kencoba
kencoba / Vagrantfile
Created August 12, 2020 08:23
Vagrantfile for Haskell.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.10"
@kencoba
kencoba / Vagrantfile
Created August 6, 2020 00:32
Vagrantfile for Jenkins.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
# for Jenkins 8080 -> 8090
config.vm.network "forwarded_port", guest: 8080, host: 8090, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.12"
@kencoba
kencoba / Vagrantfile
Created August 5, 2020 09:44
Vagrantfile for Docker.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.11"
@kencoba
kencoba / Bridge.scala
Created February 21, 2012 10:49
Bridge pattern (Design Patterns in Scala)
// http://en.wikipedia.org/wiki/Bridge_pattern
trait DrawingAPI {
def drawCircle(x:Double, y: Double, radius:Double)
}
class DrawingAPI1 extends DrawingAPI {
override def drawCircle(x: Double, y: Double, radius: Double) = {
printf("API1.circle at %f:%f radius %f\n", x, y, radius)
}
@kencoba
kencoba / データ抽出.vbs
Created May 18, 2020 09:16
Data extraction from from multiple excel books.
Option Explicit
' | | | |cell_name1|cell_name2|...
' |directory_name|book_name|sheet_name|
'
Public Sub データ抽出()
Dim ブック_オリジナル As Workbook: Set ブック_オリジナル = ThisWorkbook
Dim シート_オリジナル As Worksheet: Set シート_オリジナル = ブック_オリジナル.Sheets(1)
@kencoba
kencoba / JpqlExecutor.java
Last active April 9, 2020 01:29
REPL for JPQL
package client;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
@kencoba
kencoba / データ抽出_強調表示.vbs
Last active January 27, 2020 02:12
データ抽出と強調表示を同時に行う
Option Explicit
Private Const 強調色 = 4
' | | | |cell_name1|cell_name2|...
' |directory_name|password|book_name|sheet_name|
'