This file contains hidden or 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
fn main() { | |
println!("{n}P{r} = {x}", n = 5, r = 2, x = permutation(5, 2)); | |
println!("{n}C{r} = {x}", n = 5, r = 2, x = combination(5, 2)); | |
} | |
pub fn permutation(n: i64, r: i64) -> i64 { | |
let mut result = 1; | |
for i in (n - r + 1)..=n { | |
result *= i; | |
} |
This file contains hidden or 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
use std::collections::HashMap; | |
struct Checker { | |
memo: HashMap<(i64, i64), i64>, | |
max_seat_at_one_table: i64, | |
} | |
impl Checker { | |
pub fn check(&mut self, remain: i64, pre: i64) -> i64 { | |
match &self.memo.get(&(remain, pre)) { |
This file contains hidden or 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 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] |
This file contains hidden or 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
# 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" |
This file contains hidden or 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 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. | |
*/ |
This file contains hidden or 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
# -*- 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" |
This file contains hidden or 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
# -*- 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" |
This file contains hidden or 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
# -*- 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" |
This file contains hidden or 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
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) |
This file contains hidden or 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 Sub パスワード付きファイルを開く() | |
Dim path As String | |
With Application.FileDialog(msoFileDialogFolderPicker) | |
If .Show = True Then | |
path = .SelectedItems(1) | |
End If | |
End With | |
Dim passwd As String | |
passwd = InputBox("読み取りパスワード", "読み取りパスワード", "") |