├── ruby ├── .gitignore └── mickey24_bot.rb ├── learn ├── grpc │ ├── .gitignore │ ├── src │ │ └── lib.rs │ ├── build.rs │ └── Cargo.toml ├── http2 │ ├── .gitignore │ └── Cargo.toml └── Cargo.toml ├── rust ├── errno │ ├── .gitignore │ ├── Cargo.toml │ ├── src │ │ └── main.rs │ └── build.rs ├── gyazo │ ├── .gitignore │ ├── infra │ │ ├── .gitignore │ │ ├── aws.tf │ │ └── main.tf │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── rdig │ ├── .gitignore │ └── Cargo.toml ├── s3-du │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── envwarden │ ├── .gitignore │ ├── Cargo.toml │ └── README.md ├── gh-contrib │ ├── .gitignore │ ├── README.md │ ├── Cargo.toml │ └── graphql │ │ └── query_contrib.graphql ├── miam2tf │ ├── .gitignore │ ├── Rakefile │ ├── mrbgem.rake │ ├── src │ │ ├── main.rs │ │ ├── mruby_c.rs │ │ ├── wrapper.c │ │ └── lib.rs │ ├── build_config.rb │ ├── Cargo.toml │ ├── include │ │ └── wrapper.h │ ├── build_config.rb.lock │ ├── README.md │ └── build.rs ├── pfs-unpack │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── ray-tracing-one-weekend │ ├── README.md │ ├── .gitignore │ └── Cargo.toml ├── xft-height │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── agent-proto │ ├── .gitignore │ ├── src │ │ ├── lib.rs │ │ └── bin │ │ │ ├── client.rs │ │ │ └── agent.rs │ ├── build.rs │ ├── proto │ │ └── agent.proto │ ├── README.md │ └── Cargo.toml ├── assert_trait │ ├── .gitignore │ ├── README.md │ ├── Cargo.toml │ ├── examples │ │ └── assert.rs │ └── src │ │ └── lib.rs ├── aws-assume-role │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── grpc-sample │ ├── .gitignore │ ├── src │ │ ├── lib.rs │ │ └── bin │ │ │ ├── greeter_client.rs │ │ │ └── greeter_server.rs │ ├── build.rs │ ├── Cargo.toml │ └── proto │ │ └── hello.proto ├── jrsonnet-lint │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── s3-prefix-get │ ├── .gitignore │ ├── README.md │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── github-api-v4-sample │ ├── .gitignore │ ├── README.md │ ├── latest_tarball_query.graphql │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── go-bridge-sample │ ├── .gitignore │ ├── README.md │ ├── go.mod │ ├── input.cue │ ├── src │ │ ├── lib.rs │ │ └── main.rs │ ├── Cargo.toml │ ├── bridge.go │ └── build.rs ├── tls-cert-expiration │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── ambiwidth │ ├── .gitignore │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── graphql-sample │ ├── sample-server │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ ├── sample-client │ │ ├── .gitignore │ │ ├── index.scss │ │ ├── vendor │ │ │ └── bulma │ │ │ │ ├── sass │ │ │ │ ├── helpers │ │ │ │ │ ├── overflow.sass │ │ │ │ │ ├── position.sass │ │ │ │ │ ├── float.sass │ │ │ │ │ ├── _all.sass │ │ │ │ │ ├── other.sass │ │ │ │ │ ├── color.sass │ │ │ │ │ ├── spacing.sass │ │ │ │ │ ├── flexbox.sass │ │ │ │ │ ├── typography.sass │ │ │ │ │ └── visibility.sass │ │ │ │ ├── grid │ │ │ │ │ ├── _all.sass │ │ │ │ │ └── tiles.sass │ │ │ │ ├── .DS_Store │ │ │ │ ├── base │ │ │ │ │ ├── .DS_Store │ │ │ │ │ ├── _all.sass │ │ │ │ │ ├── animations.sass │ │ │ │ │ ├── helpers.sass │ │ │ │ │ ├── minireset.sass │ │ │ │ │ └── generic.sass │ │ │ │ ├── layout │ │ │ │ │ ├── _all.sass │ │ │ │ │ ├── footer.sass │ │ │ │ │ └── section.sass │ │ │ │ ├── utilities │ │ │ │ │ ├── .DS_Store │ │ │ │ │ ├── animations.sass │ │ │ │ │ ├── _all.sass │ │ │ │ │ ├── extends.sass │ │ │ │ │ ├── controls.sass │ │ │ │ │ └── initial-variables.sass │ │ │ │ ├── elements │ │ │ │ │ ├── form.sass │ │ │ │ │ ├── _all.sass │ │ │ │ │ ├── other.sass │ │ │ │ │ ├── box.sass │ │ │ │ │ ├── container.sass │ │ │ │ │ ├── icon.sass │ │ │ │ │ ├── image.sass │ │ │ │ │ ├── notification.sass │ │ │ │ │ ├── title.sass │ │ │ │ │ └── progress.sass │ │ │ │ ├── form │ │ │ │ │ ├── _all.sass │ │ │ │ │ ├── checkbox-radio.sass │ │ │ │ │ ├── input-textarea.sass │ │ │ │ │ ├── shared.sass │ │ │ │ │ └── select.sass │ │ │ │ └── components │ │ │ │ │ ├── _all.sass │ │ │ │ │ ├── media.sass │ │ │ │ │ ├── level.sass │ │ │ │ │ ├── menu.sass │ │ │ │ │ ├── breadcrumb.sass │ │ │ │ │ ├── dropdown.sass │ │ │ │ │ ├── card.sass │ │ │ │ │ ├── message.sass │ │ │ │ │ ├── modal.sass │ │ │ │ │ └── panel.sass │ │ │ │ └── bulma.sass │ │ ├── src │ │ │ └── graphql │ │ │ │ └── user.graphql │ │ ├── index.html │ │ └── Cargo.toml │ └── README.md ├── dockerhub-login │ ├── src │ │ ├── page.rs │ │ ├── input.rs │ │ ├── target.rs │ │ ├── fetch.rs │ │ ├── dom.rs │ │ ├── cdp.rs │ │ └── browser.rs │ ├── README.md │ └── Cargo.toml ├── curl2ffmpeg │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── git-pkgbuild-commit │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── unused-libsonnet │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── corretto-pkgbuild │ ├── Cargo.toml │ ├── src │ │ └── template │ │ │ └── PKGBUILD │ ├── README.md │ └── test │ │ ├── corretto-11.0.16.8.3.md │ │ └── corretto-8.342.07.4.md └── Cargo.toml ├── packer ├── arch64 │ ├── .gitignore │ ├── Vagrantfile │ ├── README.md │ ├── scripts │ │ └── vagrant.sh │ ├── http │ │ ├── setup.sh │ │ └── setup-chroot.sh │ └── template.json └── ec2-arch64 │ ├── .gitignore │ ├── README.md │ ├── template.json │ ├── template.rb │ └── provisioner.sh ├── cxx ├── gnome-keyring-unlock │ ├── .gitignore │ ├── README.md │ ├── CMakeLists.txt │ └── gnome-keyring-unlock.c ├── fc-find │ ├── .gitignore │ ├── README.md │ ├── CMakeLists.txt │ └── fc-find.cc ├── libssh-exec │ ├── .gitignore │ ├── CMakeLists.txt │ └── libssh-exec.cc ├── pdf-unlock │ ├── .gitignore │ ├── README.md │ ├── CMakeLists.txt │ └── pdf-unlock.cc ├── picross │ └── README.md └── delay-signal │ └── delay-signal.cc ├── gce └── archlinux │ ├── .gitignore │ ├── README.md │ ├── create-image.sh │ └── startup-script.sh ├── .clang-format ├── README.md └── .gitmodules /ruby/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | -------------------------------------------------------------------------------- /learn/grpc/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/errno/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/gyazo/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/rdig/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/s3-du/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /learn/http2/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/envwarden/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/gh-contrib/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/miam2tf/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/pfs-unpack/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/ray-tracing-one-weekend/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rust/xft-height/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /packer/arch64/.gitignore: -------------------------------------------------------------------------------- 1 | packer_cache 2 | -------------------------------------------------------------------------------- /rust/agent-proto/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/assert_trait/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/aws-assume-role/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/grpc-sample/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/jrsonnet-lint/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/s3-prefix-get/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /cxx/gnome-keyring-unlock/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /packer/ec2-arch64/.gitignore: -------------------------------------------------------------------------------- 1 | /variables.json 2 | -------------------------------------------------------------------------------- /rust/github-api-v4-sample/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/tls-cert-expiration/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /gce/archlinux/.gitignore: -------------------------------------------------------------------------------- 1 | /create-image-next-*.sh 2 | -------------------------------------------------------------------------------- /rust/ray-tracing-one-weekend/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/ambiwidth/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /UTF-8-CJK.gz 3 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-server/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust/gyazo/infra/.gitignore: -------------------------------------------------------------------------------- 1 | /.terraform 2 | /tfplan 3 | -------------------------------------------------------------------------------- /rust/miam2tf/Rakefile: -------------------------------------------------------------------------------- 1 | load "./vendor/mruby/Rakefile" 2 | -------------------------------------------------------------------------------- /rust/agent-proto/src/lib.rs: -------------------------------------------------------------------------------- 1 | tonic::include_proto!("agentproto"); 2 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /dist 3 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: Google 3 | Standard: C++11 4 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/index.scss: -------------------------------------------------------------------------------- 1 | @import "./vendor/bulma/bulma.sass"; 2 | -------------------------------------------------------------------------------- /rust/grpc-sample/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod hello { 2 | tonic::include_proto!("hello"); 3 | } 4 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/README.md: -------------------------------------------------------------------------------- 1 | # go-bridge-sample 2 | Sample code that calls a Go function from Rust. 3 | -------------------------------------------------------------------------------- /learn/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | 4 | members = [ 5 | "./grpc", 6 | "./http2", 7 | ] 8 | -------------------------------------------------------------------------------- /learn/grpc/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod protos { 2 | include!(concat!(env!("OUT_DIR"), "/routeguide.rs")); 3 | } 4 | -------------------------------------------------------------------------------- /rust/grpc-sample/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | tonic_build::compile_protos("proto/hello.proto").unwrap(); 3 | } 4 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/overflow.sass: -------------------------------------------------------------------------------- 1 | .is-clipped 2 | overflow: hidden !important 3 | -------------------------------------------------------------------------------- /cxx/fc-find/.gitignore: -------------------------------------------------------------------------------- 1 | fc-find 2 | 3 | CMakeCache.txt 4 | CMakeFiles 5 | Makefile 6 | cmake_install.cmake 7 | install_manifest.txt 8 | -------------------------------------------------------------------------------- /cxx/libssh-exec/.gitignore: -------------------------------------------------------------------------------- 1 | libssh-exec 2 | 3 | CMakeCache.txt 4 | CMakeFiles 5 | Makefile 6 | cmake_install.cmake 7 | install_manifest.txt 8 | -------------------------------------------------------------------------------- /cxx/pdf-unlock/.gitignore: -------------------------------------------------------------------------------- 1 | pdf-unlock 2 | 3 | CMakeCache.txt 4 | CMakeFiles 5 | Makefile 6 | cmake_install.cmake 7 | install_manifest.txt 8 | -------------------------------------------------------------------------------- /rust/dockerhub-login/src/page.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, serde::Serialize)] 2 | pub struct NavigateParams<'a> { 3 | pub url: &'a str, 4 | } 5 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/eagletmt/misc/rust/go-bridge-sample 2 | 3 | go 1.15 4 | 5 | require cuelang.org/go v0.4.3 6 | -------------------------------------------------------------------------------- /rust/assert_trait/README.md: -------------------------------------------------------------------------------- 1 | # assert_trait 2 | Assert the given expression implements the givne trait. 3 | 4 | See [examples](examples) directory. 5 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/src/graphql/user.graphql: -------------------------------------------------------------------------------- 1 | query GetUser($id: Int!) { 2 | user(id: $id) { 3 | id 4 | name 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /rust/miam2tf/mrbgem.rake: -------------------------------------------------------------------------------- 1 | MRuby::Gem::Specification.new('miam2tf') do |spec| 2 | spec.license = 'MIT' 3 | spec.author = 'Kohei Suzuki' 4 | end 5 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/grid/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Grid */ 2 | @charset "utf-8" 3 | 4 | @import "columns" 5 | @import "tiles" 6 | -------------------------------------------------------------------------------- /rust/agent-proto/build.rs: -------------------------------------------------------------------------------- 1 | fn main() -> Result<(), Box> { 2 | tonic_build::compile_protos("proto/agent.proto")?; 3 | Ok(()) 4 | } 5 | -------------------------------------------------------------------------------- /rust/curl2ffmpeg/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "curl2ffmpeg" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | clap.workspace = true 8 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eagletmt/misc/HEAD/rust/graphql-sample/sample-client/vendor/bulma/sass/.DS_Store -------------------------------------------------------------------------------- /rust/github-api-v4-sample/README.md: -------------------------------------------------------------------------------- 1 | # github-api-v4-sample 2 | Get schema.docs.graphql from https://docs.github.com/en/free-pro-team@latest/graphql/overview/public-schema . 3 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/input.cue: -------------------------------------------------------------------------------- 1 | one: 1 2 | two: 2 3 | 4 | // A field using quotes. 5 | "two-and-a-half": 2.5 6 | 7 | list: [ 8 | 1, 9 | 2, 10 | 3, 11 | ] 12 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/base/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eagletmt/misc/HEAD/rust/graphql-sample/sample-client/vendor/bulma/sass/base/.DS_Store -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/layout/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Layout */ 2 | @charset "utf-8" 3 | 4 | @import "hero" 5 | @import "section" 6 | @import "footer" 7 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/base/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Base */ 2 | @charset "utf-8" 3 | 4 | @import "minireset" 5 | @import "generic" 6 | @import "animations" 7 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/base/animations.sass: -------------------------------------------------------------------------------- 1 | @keyframes spinAround 2 | from 3 | transform: rotate(0deg) 4 | to 5 | transform: rotate(359deg) 6 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 5 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/utilities/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eagletmt/misc/HEAD/rust/graphql-sample/sample-client/vendor/bulma/sass/utilities/.DS_Store -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/form.sass: -------------------------------------------------------------------------------- 1 | @warn "The form.sass file is DEPRECATED. It has moved into its own /form folder. Please import sass/form/_all instead." 2 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/base/helpers.sass: -------------------------------------------------------------------------------- 1 | @warn "The helpers.sass file is DEPRECATED. It has moved into its own /helpers folder. Please import sass/helpers/_all instead." 2 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/utilities/animations.sass: -------------------------------------------------------------------------------- 1 | @warn "The animations.sass file has MOVED. It is now in the /base folder. Please import sass/base/animations instead." 2 | -------------------------------------------------------------------------------- /rust/xft-height/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "xft-height" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | [dependencies] 8 | x11-dl = "2.17" 9 | -------------------------------------------------------------------------------- /packer/arch64/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant.configure("2") do |config| 5 | config.vm.box = "arch64" 6 | config.vm.box_url = "file:///tmp/arch64.box" 7 | end 8 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/position.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | .is-overlay 4 | @extend %overlay 5 | 6 | .is-relative 7 | position: relative !important 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # misc 2 | My junk codes. 3 | 4 | All code snippets are licensed under CC0 unless otherwise specified. 5 | [![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/) 6 | -------------------------------------------------------------------------------- /rust/miam2tf/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() -> Result<(), anyhow::Error> { 2 | let miam = miam2tf::loader::load_miam("IAMfile")?; 3 | miam2tf::printer::print_as_hcl2(&mut std::io::stdout().lock(), &miam)?; 4 | Ok(()) 5 | } 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "rust/miam2tf/vendor/mruby"] 2 | path = rust/miam2tf/vendor/mruby 3 | url = https://github.com/mruby/mruby 4 | [submodule "learn/grpc/vendor/grpc"] 5 | path = learn/grpc/vendor/grpc 6 | url = https://github.com/grpc/grpc 7 | -------------------------------------------------------------------------------- /rust/gh-contrib/README.md: -------------------------------------------------------------------------------- 1 | # gh-contrib 2 | Show GitHub contributions of given user. 3 | 4 | ## Usage 5 | ``` 6 | % export GITHUB_ACCESS_TOKEN=ghp_xxxxxxxxx 7 | % gh-contrib -u eagletmt 8 | % gh-contrib -u eagletmt -t 2019-06-28 9 | ``` 10 | -------------------------------------------------------------------------------- /learn/grpc/build.rs: -------------------------------------------------------------------------------- 1 | fn main() -> Result<(), Box> { 2 | prost_build::compile_protos( 3 | &["vendor/grpc/examples/protos/route_guide.proto"], 4 | &["vendor/grpc/examples/protos"], 5 | )?; 6 | Ok(()) 7 | } 8 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/form/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Form */ 2 | @charset "utf-8" 3 | 4 | @import "shared" 5 | @import "input-textarea" 6 | @import "checkbox-radio" 7 | @import "select" 8 | @import "file" 9 | @import "tools" 10 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/float.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | .is-clearfix 4 | +clearfix 5 | 6 | .is-pulled-left 7 | float: left !important 8 | 9 | .is-pulled-right 10 | float: right !important 11 | -------------------------------------------------------------------------------- /packer/arch64/README.md: -------------------------------------------------------------------------------- 1 | # Packer template for ArchLinux Vagrant box 2 | 3 | - http://www.packer.io/ 4 | - http://www.vagrantup.com/ 5 | 6 | ```sh 7 | packer build template.json 8 | mv packer_virtualbox-iso_virtualbox.box /tmp/arch64.box 9 | vagrant up 10 | ``` 11 | -------------------------------------------------------------------------------- /cxx/pdf-unlock/README.md: -------------------------------------------------------------------------------- 1 | # pdf-unlock 2 | 3 | ## Dependencies 4 | - poppler 5 | - with glib binding 6 | - cairo 7 | 8 | ## Install 9 | ```sh 10 | mkdir build 11 | cd build 12 | cmake .. -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr 13 | make install 14 | ``` 15 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/utilities/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Utilities */ 2 | @charset "utf-8" 3 | 4 | @import "initial-variables" 5 | @import "functions" 6 | @import "derived-variables" 7 | @import "mixins" 8 | @import "controls" 9 | @import "extends" 10 | -------------------------------------------------------------------------------- /cxx/picross/README.md: -------------------------------------------------------------------------------- 1 | # picross solver without backtracking 2 | 3 | ## Input Format 4 | ``` 5 | (number of rows: R) (number of columns: C) 6 | (row hint 1) 7 | (row hint 2) 8 | ... 9 | (row hint R) 10 | (column hint 1) 11 | (column hint 2) 12 | ... 13 | (column hint C) 14 | ``` 15 | -------------------------------------------------------------------------------- /packer/ec2-arch64/README.md: -------------------------------------------------------------------------------- 1 | # ec2-arch64 2 | Create a basic AMI for me. 3 | 4 | ## Build 5 | ```sh 6 | vim variables.json 7 | packer build template.json -var-file variables.json 8 | ``` 9 | 10 | ## Update template 11 | ```sh 12 | vim template.rb 13 | ./template.rb > template.json 14 | ``` 15 | -------------------------------------------------------------------------------- /rust/s3-prefix-get/README.md: -------------------------------------------------------------------------------- 1 | # s3-prefix-get 2 | Download all S3 objects under the given prefix. 3 | 4 | s3-prefix-get is similar to `aws s3 cp --recursive`, but it doesn't treat `/` as a delimiter. 5 | It's useful for downloading non-awscli-friendly objects such as S3 access logs, CloudFront access logs, etc.. 6 | -------------------------------------------------------------------------------- /rust/gyazo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gyazo" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | [dependencies] 8 | aws-config.workspace = true 9 | aws-sdk-s3.workspace = true 10 | futures.workspace = true 11 | sha2 = "0.10" 12 | tokio.workspace = true 13 | -------------------------------------------------------------------------------- /rust/agent-proto/proto/agent.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package agentproto; 3 | 4 | service AgentService { 5 | rpc Increment(IncrementRequest) returns (IncrementResponse); 6 | } 7 | 8 | message IncrementRequest { 9 | uint64 n = 1; 10 | } 11 | 12 | message IncrementResponse { 13 | uint64 total = 1; 14 | } 15 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Helpers */ 2 | @charset "utf-8" 3 | 4 | @import "color" 5 | @import "flexbox" 6 | @import "float" 7 | @import "other" 8 | @import "overflow" 9 | @import "position" 10 | @import "spacing" 11 | @import "typography" 12 | @import "visibility" 13 | -------------------------------------------------------------------------------- /rust/jrsonnet-lint/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "jrsonnet-lint" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | jrsonnet-parser.workspace = true 10 | 11 | [dev-dependencies] 12 | indoc = "2" 13 | -------------------------------------------------------------------------------- /rust/grpc-sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "grpc-sample" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | [build-dependencies] 8 | tonic-build.workspace = true 9 | 10 | [dependencies] 11 | tonic.workspace = true 12 | prost.workspace = true 13 | tokio.workspace = true 14 | -------------------------------------------------------------------------------- /rust/errno/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "errno" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | 10 | [build-dependencies] 11 | bindgen.workspace = true 12 | once_cell = "1" 13 | libc.workspace = true 14 | -------------------------------------------------------------------------------- /rust/github-api-v4-sample/latest_tarball_query.graphql: -------------------------------------------------------------------------------- 1 | query LatestTarballQuery($owner: String!, $name: String!) { 2 | repository(owner: $owner, name: $name) { 3 | defaultBranchRef { 4 | target { 5 | __typename 6 | ... on Commit { 7 | tarballUrl 8 | } 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /rust/s3-du/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "s3-du" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | aws-config.workspace = true 10 | aws-sdk-s3.workspace = true 11 | clap.workspace = true 12 | tokio.workspace = true 13 | -------------------------------------------------------------------------------- /packer/arch64/scripts/vagrant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | 4 | mkdir -p -m700 ~/.ssh 5 | curl -o ~/.ssh/authorized_keys https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub 6 | chmod 600 ~/.ssh/authorized_keys 7 | 8 | sudo pacman --noconfirm -S virtualbox-guest-utils 9 | sudo sh -c 'echo vboxsf > /etc/modules-load.d/vagrant-vbox.conf' 10 | -------------------------------------------------------------------------------- /rust/miam2tf/build_config.rb: -------------------------------------------------------------------------------- 1 | MRuby::Build.new do |conf| 2 | conf.toolchain 3 | conf.bins = [] 4 | conf.enable_debug 5 | 6 | conf.gembox 'stdlib' 7 | conf.gem core: 'mruby-compiler' 8 | conf.gem core: 'mruby-struct' 9 | conf.gem github: 'iij/mruby-regexp-pcre' 10 | conf.gem github: 'k0kubun/mruby-hashie' 11 | conf.gem '.' 12 | end 13 | -------------------------------------------------------------------------------- /rust/git-pkgbuild-commit/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "git-pkgbuild-commit" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | anyhow.workspace = true 10 | gix = { version = "0.72", default-features = false, features = ["index"] } 11 | -------------------------------------------------------------------------------- /rust/grpc-sample/proto/hello.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package hello; 4 | 5 | service Greeter { 6 | rpc SayHello(HelloRequest) returns (HelloReply) {} 7 | rpc SayHelloSlow(HelloRequest) returns (HelloReply) {} 8 | } 9 | 10 | message HelloRequest { 11 | string name = 1; 12 | } 13 | 14 | message HelloReply { 15 | string message = 1; 16 | } 17 | -------------------------------------------------------------------------------- /cxx/gnome-keyring-unlock/README.md: -------------------------------------------------------------------------------- 1 | # gnome-keyring-unlock 2 | 3 | ## Dependencies 4 | - libgnome-keyring 5 | 6 | ## Install 7 | ```sh 8 | mkdir build 9 | cd build 10 | cmake .. -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr 11 | make install 12 | ``` 13 | 14 | ## Caveats 15 | All libgnome-keyring functions used in this tiny program are deprecated. 16 | -------------------------------------------------------------------------------- /gce/archlinux/README.md: -------------------------------------------------------------------------------- 1 | # Build ArchLinux image for Google Compute Engine from scratch 2 | 3 | ## Usage 4 | 5 | ```sh 6 | # Launch new instance and start building ArchLinux root 7 | ./create-image.sh 8 | # Wait until startup-script.sh finishes 9 | ssh archlinux-builder-${id} 10 | # Create image and delete resources 11 | ./create-image-next-${id}.sh 12 | ``` 13 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/other.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | .is-radiusless 4 | border-radius: 0 !important 5 | 6 | .is-shadowless 7 | box-shadow: none !important 8 | 9 | .is-clickable 10 | cursor: pointer !important 11 | pointer-events: all !important 12 | 13 | .is-unselectable 14 | @extend %unselectable 15 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/utilities/extends.sass: -------------------------------------------------------------------------------- 1 | @import "mixins" 2 | 3 | %control 4 | +control 5 | 6 | %unselectable 7 | +unselectable 8 | 9 | %arrow 10 | +arrow 11 | 12 | %block 13 | +block 14 | 15 | %delete 16 | +delete 17 | 18 | %loader 19 | +loader 20 | 21 | %overlay 22 | +overlay 23 | 24 | %reset 25 | +reset 26 | -------------------------------------------------------------------------------- /rust/unused-libsonnet/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unused-libsonnet" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | anyhow.workspace = true 8 | clap.workspace = true 9 | jrsonnet-evaluator.workspace = true 10 | jrsonnet-gcmodule.workspace = true 11 | jrsonnet-parser.workspace = true 12 | jrsonnet-stdlib.workspace = true 13 | walkdir = "2" 14 | -------------------------------------------------------------------------------- /rust/pfs-unpack/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pfs-unpack" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | anyhow.workspace = true 10 | byteorder = "1" 11 | ring = "0.17" 12 | tracing-subscriber.workspace = true 13 | tracing.workspace = true 14 | -------------------------------------------------------------------------------- /rust/ambiwidth/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ambiwidth" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | flate2 = "1" 11 | regex-lite = "0.1" 12 | reqwest.workspace = true 13 | tokio.workspace = true 14 | -------------------------------------------------------------------------------- /rust/dockerhub-login/README.md: -------------------------------------------------------------------------------- 1 | # dockerhub-login 2 | Login to Docker Hub with Chrome DevTools Protocol and obtain access token. 3 | 4 | ## Usage 5 | ``` 6 | % DOCKERHUB_PASSWORD=xxx dockerhub-login -u eagletmt 7 | username: eagletmt 8 | profile_url: https://wanko.cc/ 9 | gravatar_url: https://secure.gravatar.com/avatar/dd4cf7c667018939c926a8a930dd3a29.jpg?s=80&r=g&d=mm 10 | ``` 11 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | GraphQL sample 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Components */ 2 | @charset "utf-8" 3 | 4 | @import "breadcrumb" 5 | @import "card" 6 | @import "dropdown" 7 | @import "level" 8 | @import "media" 9 | @import "menu" 10 | @import "message" 11 | @import "modal" 12 | @import "navbar" 13 | @import "pagination" 14 | @import "panel" 15 | @import "tabs" 16 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/_all.sass: -------------------------------------------------------------------------------- 1 | /* Bulma Elements */ 2 | @charset "utf-8" 3 | 4 | @import "box" 5 | @import "button" 6 | @import "container" 7 | @import "content" 8 | @import "icon" 9 | @import "image" 10 | @import "notification" 11 | @import "progress" 12 | @import "table" 13 | @import "tag" 14 | @import "title" 15 | 16 | @import "other" 17 | -------------------------------------------------------------------------------- /rust/gyazo/infra/aws.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | version = "2.53.0" 3 | region = "ap-northeast-1" 4 | } 5 | 6 | provider "aws" { 7 | version = "2.53.0" 8 | region = "us-east-1" 9 | alias = "use1" 10 | } 11 | 12 | terraform { 13 | backend "s3" { 14 | bucket = "terraform-wanko-cc" 15 | key = "gyazo.tfstate" 16 | region = "ap-northeast-1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cxx/fc-find/README.md: -------------------------------------------------------------------------------- 1 | # fc-find 2 | Find fonts which have the given characters. 3 | 4 | ## Build 5 | ```bash 6 | cmake . -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr 7 | make install 8 | ``` 9 | 10 | ## Usage 11 | ``` 12 | % fc-find 🍣 13 | Noto Emoji 14 | Symbola 15 | Noto Color Emoji 16 | 17 | % fc-find U+1F363 18 | Noto Emoji 19 | Symbola 20 | Noto Color Emoji 21 | ``` 22 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "go-bridge-sample" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [build-dependencies] 10 | bindgen.workspace = true 11 | 12 | [dependencies] 13 | libc.workspace = true 14 | -------------------------------------------------------------------------------- /rust/miam2tf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "miam2tf" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2021" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | anyhow.workspace = true 11 | glob = "0.3" 12 | 13 | [build-dependencies] 14 | bindgen.workspace = true 15 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/bulma.sass: -------------------------------------------------------------------------------- 1 | @charset "utf-8" 2 | /*! bulma.io v0.9.3 | MIT License | github.com/jgthms/bulma */ 3 | @import "sass/utilities/_all" 4 | @import "sass/base/_all" 5 | @import "sass/elements/_all" 6 | @import "sass/form/_all" 7 | @import "sass/components/_all" 8 | @import "sass/grid/_all" 9 | @import "sass/helpers/_all" 10 | @import "sass/layout/_all" 11 | -------------------------------------------------------------------------------- /rust/tls-cert-expiration/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tls-cert-expiration" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | [dependencies] 8 | chrono.workspace = true 9 | clap.workspace = true 10 | rustls = { version = "0.23", default-features = false, features = ["std"] } 11 | rustls-native-certs = "0.8" 12 | x509-parser = "0.17" 13 | -------------------------------------------------------------------------------- /rust/envwarden/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "envwarden" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | anyhow.workspace = true 11 | serde.workspace = true 12 | serde_json.workspace = true 13 | serde_repr = "0.1" 14 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/layout/footer.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/derived-variables" 2 | 3 | $footer-background-color: $scheme-main-bis !default 4 | $footer-color: false !default 5 | $footer-padding: 3rem 1.5rem 6rem !default 6 | 7 | .footer 8 | background-color: $footer-background-color 9 | padding: $footer-padding 10 | @if $footer-color 11 | color: $footer-color 12 | -------------------------------------------------------------------------------- /rust/ray-tracing-one-weekend/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ray-tracing-one-weekend" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | dashmap = "6" 11 | num = "0.4" 12 | rand = "0.9" 13 | rand_xorshift = "0.4" 14 | rayon = "1" 15 | -------------------------------------------------------------------------------- /rust/aws-assume-role/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aws-assume-role" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | clap.workspace = true 11 | aws-config.workspace = true 12 | aws-sdk-sts.workspace = true 13 | tokio.workspace = true 14 | -------------------------------------------------------------------------------- /rust/rdig/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rdig" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | [dependencies] 8 | anstream.workspace = true 9 | anstyle.workspace = true 10 | hickory-resolver = { version = "0.25", default-features = false, features = ["tokio", "https-aws-lc-rs", "rustls-platform-verifier"] } 11 | tokio.workspace = true 12 | tracing-subscriber.workspace = true 13 | -------------------------------------------------------------------------------- /rust/s3-prefix-get/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "s3-prefix-get" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | aws-config.workspace = true 11 | aws-sdk-s3.workspace = true 12 | clap.workspace = true 13 | futures.workspace = true 14 | tokio.workspace = true 15 | -------------------------------------------------------------------------------- /rust/agent-proto/README.md: -------------------------------------------------------------------------------- 1 | # agent-proto 2 | Sample implementation of ssh-agent(1) style daemon/client with gRPC. 3 | 4 | ## Usage 5 | ``` 6 | % cargo build 7 | % eval $(target/debug/agent) 8 | % echo $AGENT_PROTO_SOCK 9 | /tmp/agent-proto-gngcgl/agent.22569.sock 10 | % echo $AGENT_PROTO_PID 11 | 22570 12 | % target/debug/client 13 | total = 1 14 | % target/debug/client 15 | total = 2 16 | % target/debug/client 17 | total = 3 18 | % kill $AGENT_PROTO_PID 19 | ``` 20 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sample-client" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | graphql_client.workspace = true 10 | reqwest.workspace = true 11 | serde.workspace = true 12 | wasm-bindgen = "0.2" 13 | wasm-bindgen-futures = "0.4" 14 | web-sys = "0.3" 15 | yew = { version = "0.21", features = ["csr"] } 16 | -------------------------------------------------------------------------------- /rust/miam2tf/src/mruby_c.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | #![allow(non_snake_case)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(dead_code)] 5 | #![allow(improper_ctypes)] 6 | #![allow(clippy::redundant_static_lifetimes)] 7 | #![allow(clippy::approx_constant)] 8 | #![allow(clippy::upper_case_acronyms)] 9 | #![allow(clippy::transmute_int_to_bool)] 10 | #![allow(clippy::useless_transmute)] 11 | #![allow(clippy::ptr_offset_with_cast)] 12 | 13 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 14 | -------------------------------------------------------------------------------- /rust/miam2tf/include/wrapper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | mrb_aspec wrapper_mrb_args_req(mrb_int n); 10 | mrb_int wrapper_rarray_len(mrb_value ary); 11 | mrb_int wrapper_mrb_nil_p(mrb_value o); 12 | struct RClass* wrapper_e_runtime_error(mrb_state *mrb); 13 | mrb_value wrapper_mrb_nil_value(void); 14 | mrb_int wrapper_mrb_integer(mrb_value n); 15 | -------------------------------------------------------------------------------- /cxx/fc-find/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(fc-find) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | include(FindPkgConfig) 5 | pkg_check_modules(FONTCONFIG REQUIRED fontconfig) 6 | include_directories(${FONTCONFIG_INCLUDE_DIRS}) 7 | link_directories(${FONTCONFIG_LIBRARY_DIRS}) 8 | link_libraries(${FONTCONFIG_LIBRARIES}) 9 | 10 | add_definitions(-std=c++11 -Wall -W) 11 | set(CMAKE_CXX_FLAGS_RELEASE "-O3") 12 | set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") 13 | 14 | add_executable(fc-find fc-find.cc) 15 | 16 | install(PROGRAMS fc-find DESTINATION bin) 17 | -------------------------------------------------------------------------------- /learn/http2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "http2" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2021" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | bytes = "1" 11 | hpack_codec = "0.1" 12 | tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "io-util", "io-std"] } 13 | tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "tls12", "ring"] } 14 | webpki-roots = "0.26" 15 | -------------------------------------------------------------------------------- /cxx/libssh-exec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(libssh-exec) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | include(FindPkgConfig) 5 | pkg_check_modules(LIBSSH_EXEC REQUIRED libssh) 6 | include_directories(${LIBSSH_EXEC_INCLUDE_DIRS}) 7 | link_directories(${LIBSSH_EXEC_LIBRARY_DIRS}) 8 | link_libraries(${LIBSSH_EXEC_LIBRARIES}) 9 | 10 | add_definitions(-std=c++11 -Wall -W) 11 | set(CMAKE_CXX_FLAGS_RELEASE "-O3") 12 | set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") 13 | 14 | add_executable(libssh-exec libssh-exec.cc) 15 | 16 | install(PROGRAMS libssh-exec DESTINATION bin) 17 | -------------------------------------------------------------------------------- /rust/corretto-pkgbuild/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "corretto-pkgbuild" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | anyhow.workspace = true 10 | clap.workspace = true 11 | handlebars = "6" 12 | octocrab = "0.44" 13 | pulldown-cmark = { version = "0.13", default-features = false } 14 | serde.workspace = true 15 | tendril = "0.4" 16 | tokio.workspace = true 17 | tracing.workspace = true 18 | tracing-subscriber.workspace = true 19 | -------------------------------------------------------------------------------- /rust/miam2tf/build_config.rb.lock: -------------------------------------------------------------------------------- 1 | --- 2 | mruby: 3 | version: 3.1.0 4 | release_no: 30100 5 | builds: 6 | host: 7 | https://github.com/iij/mruby-regexp-pcre.git: 8 | url: https://github.com/iij/mruby-regexp-pcre.git 9 | branch: HEAD 10 | commit: a961225c0953dd2bd987111f0836821573616de2 11 | version: 0.0.0 12 | https://github.com/k0kubun/mruby-hashie.git: 13 | url: https://github.com/k0kubun/mruby-hashie.git 14 | branch: HEAD 15 | commit: c69255a94debcd641f2087b569f5625509bde698 16 | version: 0.0.0 17 | -------------------------------------------------------------------------------- /rust/assert_trait/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "assert_trait" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | syn = "2" 14 | quote = "1" 15 | 16 | [dev-dependencies] 17 | futures = "0.3" 18 | tokio = { version = "1", features = ["macros", "rt-multi-thread", "time", "process"] } 19 | tokio-stream = { version = "0.1", features = ["time"] } 20 | -------------------------------------------------------------------------------- /rust/gh-contrib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gh-contrib" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | anstream.workspace = true 10 | anstyle.workspace = true 11 | anyhow.workspace = true 12 | chrono.workspace = true 13 | clap.workspace = true 14 | graphql_client.workspace = true 15 | reqwest.workspace = true 16 | serde.workspace = true 17 | tokio.workspace = true 18 | tracing.workspace = true 19 | tracing-subscriber.workspace = true 20 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/layout/section.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $section-padding: 3rem 1.5rem !default 4 | $section-padding-desktop: 3rem 3rem !default 5 | $section-padding-medium: 9rem 4.5rem !default 6 | $section-padding-large: 18rem 6rem !default 7 | 8 | .section 9 | padding: $section-padding 10 | // Responsiveness 11 | +desktop 12 | padding: $section-padding-desktop 13 | // Sizes 14 | &.is-medium 15 | padding: $section-padding-medium 16 | &.is-large 17 | padding: $section-padding-large 18 | -------------------------------------------------------------------------------- /cxx/pdf-unlock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(pdf-unlock) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | include(FindPkgConfig) 5 | pkg_check_modules(PDF_UNLOCK REQUIRED poppler poppler-glib cairo gio-2.0) 6 | include_directories(${PDF_UNLOCK_INCLUDE_DIRS}) 7 | link_directories(${PDF_UNLOCK_LIBRARY_DIRS}) 8 | link_libraries(${PDF_UNLOCK_LIBRARIES}) 9 | 10 | add_definitions(-std=c++11 -Wall -W) 11 | set(CMAKE_CXX_FLAGS_RELEASE "-O3") 12 | set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") 13 | 14 | add_executable(pdf-unlock pdf-unlock.cc) 15 | 16 | install(PROGRAMS pdf-unlock DESTINATION bin) 17 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/form/checkbox-radio.sass: -------------------------------------------------------------------------------- 1 | %checkbox-radio 2 | cursor: pointer 3 | display: inline-block 4 | line-height: 1.25 5 | position: relative 6 | input 7 | cursor: pointer 8 | &:hover 9 | color: $input-hover-color 10 | &[disabled], 11 | fieldset[disabled] &, 12 | input[disabled] 13 | color: $input-disabled-color 14 | cursor: not-allowed 15 | 16 | .checkbox 17 | @extend %checkbox-radio 18 | 19 | .radio 20 | @extend %checkbox-radio 21 | & + .radio 22 | +ltr-property("margin", 0.5em, false) 23 | -------------------------------------------------------------------------------- /rust/dockerhub-login/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dockerhub-login" 3 | version = "0.1.0" 4 | edition = "2024" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | anyhow.workspace = true 10 | clap.workspace = true 11 | futures-util = "0.3" 12 | http = "1" 13 | reqwest.workspace = true 14 | serde.workspace = true 15 | serde_json.workspace = true 16 | tempfile.workspace = true 17 | tokio.workspace = true 18 | tokio-tungstenite = "0.26" 19 | tracing.workspace = true 20 | tracing-subscriber.workspace = true 21 | -------------------------------------------------------------------------------- /rust/jrsonnet-lint/README.md: -------------------------------------------------------------------------------- 1 | # jrsonnet-lint 2 | Linter for Jsonnet files. 3 | 4 | ## Features 5 | ### Detect unused variables 6 | 7 | ``` 8 | % cat a.jsonnet 9 | local x = error 'error'; 10 | 11 | { 12 | x: x, 13 | local x = 1, 14 | } 15 | % cat b.jsonnet 16 | local x = error 'error'; 17 | 18 | { 19 | x: x, 20 | local y = 1, 21 | } 22 | % target/debug/jrsonnet-lint a.jsonnet b.jsonnet 23 | a.jsonnet:1:x is defined but unused 24 | b.jsonnet:3:y is defined but unused 25 | ``` 26 | 27 | FIXME: Line number of unused variable location is inaccurate except for top-level `local` expression. 28 | -------------------------------------------------------------------------------- /rust/github-api-v4-sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "github-api-v4-sample" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | anyhow.workspace = true 11 | clap.workspace = true 12 | graphql_client.workspace = true 13 | jsonwebtoken = "9" 14 | reqwest.workspace = true 15 | serde.workspace = true 16 | serde_json.workspace = true 17 | tokio.workspace = true 18 | tracing.workspace = true 19 | tracing-subscriber.workspace = true 20 | -------------------------------------------------------------------------------- /rust/dockerhub-login/src/input.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, serde::Serialize)] 2 | #[serde(rename_all = "camelCase")] 3 | pub struct DispatchMouseEventParams { 4 | #[serde(rename = "type")] 5 | pub type_: &'static str, 6 | pub x: f64, 7 | pub y: f64, 8 | pub button: &'static str, 9 | pub click_count: i64, 10 | } 11 | 12 | #[derive(Debug, serde::Serialize)] 13 | #[serde(rename_all = "camelCase")] 14 | pub struct DispatchKeyEventParams<'a> { 15 | #[serde(rename = "type")] 16 | pub type_: &'static str, 17 | #[serde(skip_serializing_if = "Option::is_none")] 18 | pub text: Option<&'a str>, 19 | } 20 | -------------------------------------------------------------------------------- /learn/grpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "grpc" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [build-dependencies] 10 | prost-build = "0.13" 11 | 12 | [dependencies] 13 | bytes = "1" 14 | hpack_codec = "0.1" 15 | prost = "0.13" 16 | tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "io-util", "io-std"] } 17 | tokio-rustls = { version = "0.26", default-features = false, features = ["logging", "tls12", "ring"] } 18 | webpki-roots = "0.26" 19 | -------------------------------------------------------------------------------- /cxx/gnome-keyring-unlock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(gnome-keyring-unlock) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | include(FindPkgConfig) 5 | pkg_check_modules(GNOME_KEYRING_UNLOCK REQUIRED gnome-keyring-1) 6 | include_directories(${GNOME_KEYRING_UNLOCK_INCLUDE_DIRS}) 7 | link_directories(${GNOME_KEYRING_UNLOCK_LIBRARY_DIRS}) 8 | link_libraries(${GNOME_KEYRING_UNLOCK_LIBRARIES}) 9 | 10 | add_definitions(-std=c99 -Wall -W) 11 | set(CMAKE_CXX_FLAGS_RELEASE "-O2") 12 | set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") 13 | 14 | add_executable(gnome-keyring-unlock gnome-keyring-unlock.c) 15 | 16 | install(PROGRAMS gnome-keyring-unlock DESTINATION bin) 17 | -------------------------------------------------------------------------------- /rust/errno/src/main.rs: -------------------------------------------------------------------------------- 1 | include!(concat!(env!("OUT_DIR"), "/errno.rs")); 2 | 3 | fn main() { 4 | for arg in std::env::args().skip(1) { 5 | if let Ok(n) = arg.parse::() { 6 | for (name, value, message) in ERROR_NUMBERS.iter().filter(|(_, value, _)| *value == n) { 7 | println!("{}={}: {}", name, value, message); 8 | } 9 | } 10 | 11 | for (name, value, message) in ERROR_NUMBERS 12 | .iter() 13 | .filter(|(name, _, message)| name.contains(&arg) || message.contains(&arg)) 14 | { 15 | println!("{}={}: {}", name, value, message); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-server/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sample-server" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | anyhow.workspace = true 10 | axum = "0.8" 11 | juniper = { version = "0.16", default-features = false } 12 | juniper_axum = "0.2" 13 | listenfd = "1" 14 | sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio-rustls", "macros", "postgres"] } 15 | tokio.workspace = true 16 | tower.workspace = true 17 | tower-http = { version = "0.6", features = ["trace"] } 18 | tracing-subscriber.workspace = true 19 | -------------------------------------------------------------------------------- /packer/ec2-arch64/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "aws_access_key": "", 4 | "aws_secret_key": "", 5 | "region": "ap-northeast-1" 6 | }, 7 | "builders": [ 8 | { 9 | "type": "amazon-ebs", 10 | "access_key": "{{user `aws_access_key`}}", 11 | "secret_key": "{{user `aws_secret_key`}}", 12 | "region": "{{user `region`}}", 13 | "source_ami": "ami-31d9a830", 14 | "instance_type": "t1.micro", 15 | "ssh_username": "root", 16 | "ami_name": "packer-ec2-arch64 {{timestamp}}" 17 | } 18 | ], 19 | "provisioners": [ 20 | { 21 | "type": "shell", 22 | "script": "provisioner.sh" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/bridge.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // typedef const char *const_string_t; 4 | import "C" 5 | 6 | import ( 7 | "cuelang.org/go/cue" 8 | ) 9 | 10 | //export cue_export 11 | func cue_export(filename C.const_string_t, code C.const_string_t, e *C.int) *C.char { 12 | f := C.GoString(filename) 13 | c := C.GoString(code) 14 | r := cue.Runtime{} 15 | instance, err := r.Compile(f, c) 16 | if err != nil { 17 | *e = 1 18 | return C.CString(err.Error()) 19 | } 20 | json, err := instance.Value().MarshalJSON() 21 | if err != nil { 22 | *e = 1 23 | return C.CString(err.Error()) 24 | } 25 | *e = 0 26 | return C.CString(string(json)) 27 | } 28 | 29 | func main() { 30 | } 31 | -------------------------------------------------------------------------------- /rust/miam2tf/src/wrapper.c: -------------------------------------------------------------------------------- 1 | #include "wrapper.h" 2 | 3 | void mrb_miam2tf_gem_init(mrb_state* _mrb) { 4 | } 5 | 6 | void mrb_miam2tf_gem_final(mrb_state* _mrb) { 7 | } 8 | 9 | mrb_aspec wrapper_mrb_args_req(mrb_int n) { 10 | return MRB_ARGS_REQ(n); 11 | } 12 | 13 | mrb_int wrapper_rarray_len(mrb_value ary) { 14 | return RARRAY_LEN(ary); 15 | } 16 | 17 | mrb_int wrapper_mrb_nil_p(mrb_value o) { 18 | return mrb_nil_p(o); 19 | } 20 | 21 | struct RClass* wrapper_e_runtime_error(mrb_state *mrb) { 22 | return E_RUNTIME_ERROR; 23 | } 24 | 25 | mrb_value wrapper_mrb_nil_value(void) { 26 | return mrb_nil_value(); 27 | } 28 | 29 | mrb_int wrapper_mrb_integer(mrb_value n) { return mrb_integer(n); } 30 | -------------------------------------------------------------------------------- /rust/envwarden/README.md: -------------------------------------------------------------------------------- 1 | # envwarden 2 | Set environment variables from Bitwarden Secure Notes. 3 | 4 | ## Prerequisites 5 | - Create a folder for envwarden in Bitwarden 6 | - Save values as custom fields of Secure Note in the folder 7 | - The field name is mapped to environment variable name 8 | - The field value is mapped to environment variable value 9 | - The field type must be "Text" or "Hidden" 10 | - Install Bitwarden CLI 11 | - https://github.com/bitwarden/cli 12 | 13 | ## Usage 14 | ``` 15 | % export BW_SESSION="$(bw unlock --raw)" 16 | % export ENVWARDEN_FOLDERID=$(bw get folder envwarden | jq -r .id) 17 | % envwarden aws printenv AWS_ACCESS_KEY_ID 18 | AKIA................ 19 | ``` 20 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/other.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | .block 4 | @extend %block 5 | 6 | .delete 7 | @extend %delete 8 | 9 | .heading 10 | display: block 11 | font-size: 11px 12 | letter-spacing: 1px 13 | margin-bottom: 5px 14 | text-transform: uppercase 15 | 16 | .loader 17 | @extend %loader 18 | 19 | .number 20 | align-items: center 21 | background-color: $background 22 | border-radius: $radius-rounded 23 | display: inline-flex 24 | font-size: $size-medium 25 | height: 2em 26 | justify-content: center 27 | margin-right: 1.5rem 28 | min-width: 2.5em 29 | padding: 0.25rem 0.5rem 30 | text-align: center 31 | vertical-align: top 32 | -------------------------------------------------------------------------------- /rust/grpc-sample/src/bin/greeter_client.rs: -------------------------------------------------------------------------------- 1 | #[tokio::main] 2 | async fn main() -> Result<(), Box> { 3 | let mut client = 4 | grpc_sample::hello::greeter_client::GreeterClient::connect("http://localhost:5000").await?; 5 | let request = tonic::Request::new(grpc_sample::hello::HelloRequest { 6 | name: "grpc-sample".to_owned(), 7 | }); 8 | let slow = match std::env::var("SLOW") { 9 | Ok(v) => v == "1", 10 | Err(_) => false, 11 | }; 12 | let response = if slow { 13 | client.say_hello_slow(request).await? 14 | } else { 15 | client.say_hello(request).await? 16 | }; 17 | println!("{:?}", response); 18 | 19 | Ok(()) 20 | } 21 | -------------------------------------------------------------------------------- /packer/ec2-arch64/template.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'json' 3 | 4 | template = { 5 | variables: { 6 | aws_access_key: '', 7 | aws_secret_key: '', 8 | region: 'ap-northeast-1', 9 | }, 10 | builders: [{ 11 | type: 'amazon-ebs', 12 | access_key: '{{user `aws_access_key`}}', 13 | secret_key: '{{user `aws_secret_key`}}', 14 | region: '{{user `region`}}', 15 | source_ami: 'ami-31d9a830', # https://www.uplinklabs.net/projects/arch-linux-on-ec2/ 16 | instance_type: 't1.micro', 17 | ssh_username: 'root', 18 | ami_name: 'packer-ec2-arch64 {{timestamp}}', 19 | }], 20 | provisioners: [{ 21 | type: 'shell', 22 | script: 'provisioner.sh', 23 | }], 24 | } 25 | 26 | puts JSON.pretty_generate(template) 27 | -------------------------------------------------------------------------------- /rust/agent-proto/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "agent-proto" 3 | version = "0.1.0" 4 | authors = ["Kohei Suzuki "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [build-dependencies] 10 | tonic-build.workspace = true 11 | 12 | [dependencies] 13 | anyhow.workspace = true 14 | hyper-util = "0.1" 15 | libc.workspace = true 16 | nix = { version = "0.30", features = ["fs", "process"] } 17 | prost.workspace = true 18 | tempfile.workspace = true 19 | tokio-stream = { version = "0.1", features = ["net"] } 20 | tokio.workspace = true 21 | tonic.workspace = true 22 | tower.workspace = true 23 | tracing-subscriber.workspace = true 24 | tracing.workspace = true 25 | -------------------------------------------------------------------------------- /packer/arch64/http/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | http_root="$1" 4 | shift 5 | 6 | sgdisk --new 1::+1m --typecode 1:ef02 --new 2::+100m --new 3 /dev/sda 7 | mkfs.ext4 /dev/sda2 8 | mkfs.ext4 /dev/sda3 9 | mount /dev/sda3 /mnt 10 | mkdir /mnt/boot 11 | mount /dev/sda2 /mnt/boot 12 | 13 | #cp /etc/pacman.d/mirrorlist /tmp/mirrorlist 14 | #rankmirrors -n 3 /tmp/mirrorlist > /etc/pacman.d/mirrorlist 15 | echo 'Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch' > /etc/pacman.d/mirrorlist 16 | pacstrap /mnt base grub sudo openssh 17 | genfstab -U -p /mnt >> /mnt/etc/fstab 18 | 19 | setup_chroot=/root/setup-chroot.sh 20 | curl -o /mnt/$setup_chroot "$http_root/setup-chroot.sh" 21 | chmod +x /mnt/$setup_chroot 22 | arch-chroot /mnt $setup_chroot 23 | 24 | rm /mnt/$setup_chroot 25 | reboot 26 | -------------------------------------------------------------------------------- /rust/gh-contrib/graphql/query_contrib.graphql: -------------------------------------------------------------------------------- 1 | query QueryContrib($login: String!, $from: DateTime, $to: DateTime) { 2 | user(login: $login) { 3 | contributionsCollection(from: $from, to: $to) { 4 | startedAt 5 | endedAt 6 | pullRequestContributions(first: 100) { 7 | edges { 8 | node { 9 | pullRequest { 10 | state 11 | url 12 | createdAt 13 | title 14 | } 15 | } 16 | } 17 | } 18 | issueContributions(first: 100) { 19 | edges { 20 | node { 21 | issue { 22 | state 23 | url 24 | createdAt 25 | title 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /rust/dockerhub-login/src/target.rs: -------------------------------------------------------------------------------- 1 | pub type TargetId = String; 2 | 3 | #[derive(Debug, serde::Deserialize)] 4 | #[serde(rename_all = "camelCase")] 5 | pub struct GetTargetsResult { 6 | pub target_infos: Vec, 7 | } 8 | 9 | #[derive(Debug, serde::Deserialize)] 10 | #[serde(rename_all = "camelCase")] 11 | pub struct TargetInfo { 12 | #[serde(rename = "type")] 13 | pub type_: String, 14 | pub target_id: TargetId, 15 | } 16 | 17 | #[derive(Debug, serde::Serialize)] 18 | #[serde(rename_all = "camelCase")] 19 | pub struct AttachToTargetParams<'a> { 20 | pub target_id: &'a TargetId, 21 | pub flatten: bool, 22 | } 23 | 24 | #[derive(Debug, serde::Deserialize)] 25 | #[serde(rename_all = "camelCase")] 26 | pub struct AttachToTargetResult { 27 | pub session_id: crate::cdp::SessionId, 28 | } 29 | -------------------------------------------------------------------------------- /rust/graphql-sample/README.md: -------------------------------------------------------------------------------- 1 | # graphql-sample 2 | Boilerplate code for building web app using GraphQL 3 | 4 | ## Libraries 5 | - Server side 6 | - Juniper 7 | - Axum 8 | - SQLx 9 | - Client side 10 | - graphql-client 11 | - Yew 12 | 13 | ## Prerequisites 14 | - Install graphql-client CLI 15 | - `cargo install graphql_client_cli` 16 | - Install [trunk](https://trunkrs.dev/) 17 | 18 | ## Development 19 | - Launch GraphQL server with `cd sample-server; systemfd --no-pid -s http::3000 -- cargo watch -x run` 20 | - Generate schema and client code with `graphql-client introspect-schema http://localhost:3000/graphql --output schema.json` 21 | - Launch trunk server with `cd sample-client; trunk serve` 22 | - Open http://localhost:8080 to see main page 23 | - Open http://localhost:3000/graphiql to use GraphiQL 24 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/box.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $box-color: $text !default 4 | $box-background-color: $scheme-main !default 5 | $box-radius: $radius-large !default 6 | $box-shadow: $shadow !default 7 | $box-padding: 1.25rem !default 8 | 9 | $box-link-hover-shadow: 0 0.5em 1em -0.125em rgba($scheme-invert, 0.1), 0 0 0 1px $link !default 10 | $box-link-active-shadow: inset 0 1px 2px rgba($scheme-invert, 0.2), 0 0 0 1px $link !default 11 | 12 | .box 13 | @extend %block 14 | background-color: $box-background-color 15 | border-radius: $box-radius 16 | box-shadow: $box-shadow 17 | color: $box-color 18 | display: block 19 | padding: $box-padding 20 | 21 | a.box 22 | &:hover, 23 | &:focus 24 | box-shadow: $box-link-hover-shadow 25 | &:active 26 | box-shadow: $box-link-active-shadow 27 | -------------------------------------------------------------------------------- /rust/miam2tf/README.md: -------------------------------------------------------------------------------- 1 | # miam2tf 2 | Convert [miam](https://github.com/codenize-tools/miam) to Terraform definition (WIP) 3 | 4 | ## Usage 5 | ``` 6 | % cargo build # Requires `rake` to build libmruby.a 7 | % cat IAMfile 8 | Dir.glob('users/*.iam').each do |file| 9 | require file 10 | end 11 | % target/debug/miam2tf | terraform fmt - 12 | resource "aws_iam_user" "s3viewer" { 13 | name = "s3viewer" 14 | path = "/" 15 | } 16 | resource "aws_iam_user_policy" "s3viewer-s3viewer" { 17 | name = "s3viewer" 18 | user = aws_iam_user.s3viewer.name 19 | policy = data.aws_iam_policy_document.s3viewer-s3viewer.json 20 | } 21 | data "aws_iam_policy_document" "s3viewer-s3viewer" { 22 | version = "2012-10-17" 23 | statement { 24 | effect = "Allow" 25 | actions = ["s3:Get*", "s3:List*"] 26 | resources = ["*"] 27 | } 28 | } 29 | (snip) 30 | ``` 31 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() -> Result<(), Box> { 2 | let path = "input.cue"; 3 | let code = std::fs::read_to_string(path)?; 4 | let exported = cue_export(path, &code)?; 5 | println!("{}", exported); 6 | Ok(()) 7 | } 8 | 9 | fn cue_export(filename: &str, code: &str) -> Result { 10 | let filename_cstr = std::ffi::CString::new(filename).unwrap(); 11 | let code_cstr = std::ffi::CString::new(code).unwrap(); 12 | let mut e = 0; 13 | let result = unsafe { 14 | let ptr = go_bridge_sample::cue_export(filename_cstr.as_ptr(), code_cstr.as_ptr(), &mut e); 15 | let r = std::ffi::CStr::from_ptr(ptr).to_string_lossy().into_owned(); 16 | libc::free(ptr as *mut libc::c_void); 17 | r 18 | }; 19 | if e == 0 { 20 | Ok(result) 21 | } else { 22 | Err(result) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /rust/dockerhub-login/src/fetch.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, serde::Serialize)] 2 | #[serde(rename_all = "camelCase")] 3 | pub struct EnableParams<'a> { 4 | pub patterns: Vec>, 5 | } 6 | 7 | #[derive(Debug, serde::Serialize)] 8 | #[serde(rename_all = "camelCase")] 9 | pub struct RequestPattern<'a> { 10 | pub url_pattern: &'a str, 11 | } 12 | 13 | #[derive(Debug, serde::Deserialize)] 14 | #[serde(rename_all = "camelCase")] 15 | pub struct RequestPaused { 16 | pub request_id: RequestId, 17 | pub request: NetworkRequest, 18 | } 19 | 20 | pub type RequestId = String; 21 | 22 | #[derive(Debug, serde::Deserialize)] 23 | #[serde(rename_all = "camelCase")] 24 | pub struct NetworkRequest { 25 | pub headers: std::collections::HashMap, 26 | } 27 | 28 | #[derive(Debug, serde::Serialize)] 29 | #[serde(rename_all = "camelCase")] 30 | pub struct ContinueRequestParams<'a> { 31 | pub request_id: &'a RequestId, 32 | } 33 | -------------------------------------------------------------------------------- /rust/jrsonnet-lint/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() -> Result<(), Box> { 2 | for arg in std::env::args().skip(1) { 3 | let code = std::fs::read_to_string(&arg)?; 4 | let expr = jrsonnet_parser::parse( 5 | &code, 6 | &jrsonnet_parser::ParserSettings { 7 | source: jrsonnet_parser::Source::new( 8 | jrsonnet_parser::SourcePath::new(jrsonnet_parser::SourceFile::new(arg.into())), 9 | "".into(), 10 | ), 11 | }, 12 | )?; 13 | let unused_variables = jrsonnet_lint::find_unused_variables(&expr); 14 | for variable in unused_variables { 15 | println!( 16 | "{}:{}:{} is defined but unused", 17 | variable.path.display(), 18 | variable.begin_offset_line()?, 19 | variable.name 20 | ); 21 | } 22 | } 23 | Ok(()) 24 | } 25 | -------------------------------------------------------------------------------- /rust/agent-proto/src/bin/client.rs: -------------------------------------------------------------------------------- 1 | #[tokio::main] 2 | async fn main() -> Result<(), anyhow::Error> { 3 | use std::convert::TryFrom as _; 4 | 5 | let socket_path = std::env::var("AGENT_PROTO_SOCK")?; 6 | let channel = tonic::transport::Endpoint::try_from("http://[::]:50051")? 7 | .connect_with_connector(tower::service_fn(move |_: tonic::transport::Uri| { 8 | let socket_path = socket_path.clone(); 9 | async { 10 | Ok::<_, std::io::Error>(hyper_util::rt::TokioIo::new( 11 | tokio::net::UnixStream::connect(socket_path).await?, 12 | )) 13 | } 14 | })) 15 | .await?; 16 | let mut client = agent_proto::agent_service_client::AgentServiceClient::new(channel); 17 | let resp = client 18 | .increment(tonic::Request::new(agent_proto::IncrementRequest { n: 1 })) 19 | .await?; 20 | println!("total = {}", resp.into_inner().total); 21 | Ok(()) 22 | } 23 | -------------------------------------------------------------------------------- /rust/xft-height/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let xlib = x11_dl::xlib::Xlib::open().expect("Unable to load xlib"); 3 | let xft = x11_dl::xft::Xft::open().expect("Unable to load xft"); 4 | 5 | let args: Vec = std::env::args().collect(); 6 | if args.len() > 1 { 7 | let desc_cstr = 8 | std::ffi::CString::new(args[1].clone()).expect("Unable to allocate CString"); 9 | 10 | let dpy = unsafe { (xlib.XOpenDisplay)(std::ptr::null()) }; 11 | let screen = unsafe { (xlib.XDefaultScreenOfDisplay)(dpy) }; 12 | let screen_number = unsafe { (xlib.XScreenNumberOfScreen)(screen) }; 13 | let font = unsafe { (xft.XftFontOpenName)(dpy, screen_number, desc_cstr.as_ptr()) }; 14 | let height = unsafe { *font }.height; 15 | println!("{}", height); 16 | unsafe { (xft.XftFontClose)(dpy, font) }; 17 | unsafe { (xlib.XCloseDisplay)(dpy) }; 18 | } else { 19 | eprintln!("Usage: {} PATTERN", args[0]); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packer/ec2-arch64/provisioner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | 4 | cat <<'EOS' >> /etc/pacman.conf 5 | [aur-eagletmt] 6 | SigLevel = Required 7 | Server = http://arch.wanko.cc/$repo/os/$arch 8 | EOS 9 | GPGKEY=C48DBD97 10 | pacman-key --recv-keys $GPGKEY 11 | pacman-key --lsign-key $GPGKEY 12 | 13 | pacman -Syu --noconfirm 14 | pacman -S --noconfirm tmux-cjkwidth htop-vi 15 | 16 | ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime 17 | 18 | echo ja_JP.UTF-8 UTF-8 >> /etc/locale.gen 19 | locale-gen 20 | 21 | systemctl disable syslog-ng.service 22 | systemctl disable sshd.service 23 | systemctl enable sshd.socket 24 | 25 | mkdir -m755 /home/eagletmt 26 | useradd -U eagletmt 27 | gpasswd -a eagletmt wheel 28 | gpasswd -a eagletmt systemd-journal 29 | echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/10_wheel 30 | mkdir -m700 ~eagletmt/.ssh 31 | curl https://github.com/eagletmt.keys > ~eagletmt/.ssh/authorized_keys 32 | chmod 600 ~eagletmt/.ssh/authorized_keys 33 | chown -R eagletmt:eagletmt ~eagletmt/.ssh 34 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/grid/tiles.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $tile-spacing: 0.75rem !default 4 | 5 | .tile 6 | align-items: stretch 7 | display: block 8 | flex-basis: 0 9 | flex-grow: 1 10 | flex-shrink: 1 11 | min-height: min-content 12 | // Modifiers 13 | &.is-ancestor 14 | margin-left: $tile-spacing * -1 15 | margin-right: $tile-spacing * -1 16 | margin-top: $tile-spacing * -1 17 | &:last-child 18 | margin-bottom: $tile-spacing * -1 19 | &:not(:last-child) 20 | margin-bottom: $tile-spacing 21 | &.is-child 22 | margin: 0 !important 23 | &.is-parent 24 | padding: $tile-spacing 25 | &.is-vertical 26 | flex-direction: column 27 | & > .tile.is-child:not(:last-child) 28 | margin-bottom: 1.5rem !important 29 | // Responsiveness 30 | +tablet 31 | &:not(.is-child) 32 | display: flex 33 | @for $i from 1 through 12 34 | &.is-#{$i} 35 | flex: none 36 | width: (divide($i, 12)) * 100% 37 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/container.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $container-offset: (2 * $gap) !default 4 | $container-max-width: $fullhd !default 5 | 6 | .container 7 | flex-grow: 1 8 | margin: 0 auto 9 | position: relative 10 | width: auto 11 | &.is-fluid 12 | max-width: none !important 13 | padding-left: $gap 14 | padding-right: $gap 15 | width: 100% 16 | +desktop 17 | max-width: $desktop - $container-offset 18 | +until-widescreen 19 | &.is-widescreen:not(.is-max-desktop) 20 | max-width: min($widescreen, $container-max-width) - $container-offset 21 | +until-fullhd 22 | &.is-fullhd:not(.is-max-desktop):not(.is-max-widescreen) 23 | max-width: min($fullhd, $container-max-width) - $container-offset 24 | +widescreen 25 | &:not(.is-max-desktop) 26 | max-width: min($widescreen, $container-max-width) - $container-offset 27 | +fullhd 28 | &:not(.is-max-desktop):not(.is-max-widescreen) 29 | max-width: min($fullhd, $container-max-width) - $container-offset 30 | -------------------------------------------------------------------------------- /rust/go-bridge-sample/build.rs: -------------------------------------------------------------------------------- 1 | fn main() -> Result<(), Box> { 2 | let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); 3 | 4 | println!("cargo:rerun-if-changed=bridge.go"); 5 | println!("cargo:rustc-link-lib=static=go-bridge-sample"); 6 | println!("cargo:rustc-link-search=native={}", out_dir.display()); 7 | let status = std::process::Command::new("go") 8 | .arg("build") 9 | .arg("-buildmode=c-archive") 10 | .arg(format!( 11 | "-o={}", 12 | out_dir.join("libgo-bridge-sample.a").display() 13 | )) 14 | .status()?; 15 | if !status.success() { 16 | panic!("Failed to build libgo-bridge-sample.a"); 17 | } 18 | 19 | let bindings = bindgen::Builder::default() 20 | .header(format!( 21 | "{}", 22 | out_dir.join("libgo-bridge-sample.h").display() 23 | )) 24 | .generate() 25 | .expect("Failed to generate bindings.rs from libgo-bridge-sample.h"); 26 | bindings.write_to_file(out_dir.join("bindings.rs"))?; 27 | Ok(()) 28 | } 29 | -------------------------------------------------------------------------------- /cxx/gnome-keyring-unlock/gnome-keyring-unlock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static void read_password(char *buf, size_t n) 8 | { 9 | struct termios save, t; 10 | 11 | fputs("Password: ", stdout); 12 | fflush(stdout); 13 | 14 | tcgetattr(STDIN_FILENO, &save); 15 | t = save; 16 | t.c_lflag &= ~ECHO; 17 | tcsetattr(STDIN_FILENO, TCSANOW, &t); 18 | fgets(buf, n, stdin); 19 | tcsetattr(STDIN_FILENO, TCSANOW, &save); 20 | 21 | putchar('\n'); 22 | fflush(stdout); 23 | 24 | const size_t len = strlen(buf); 25 | if (buf[len-1] == '\n') { 26 | buf[len-1] = '\0'; 27 | } 28 | } 29 | 30 | int main(void) { 31 | char password[1024]; 32 | read_password(password, sizeof(password)); 33 | GnomeKeyringResult result = gnome_keyring_unlock_sync(NULL, password); 34 | switch (result) { 35 | case GNOME_KEYRING_RESULT_OK: 36 | return 0; 37 | default: 38 | fprintf(stderr, "Unable to unlock: %s (result=%d)\n", gnome_keyring_result_to_message(result), result); 39 | return 1; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/base/minireset.sass: -------------------------------------------------------------------------------- 1 | /*! minireset.css v0.0.6 | MIT License | github.com/jgthms/minireset.css */ 2 | // Blocks 3 | html, 4 | body, 5 | p, 6 | ol, 7 | ul, 8 | li, 9 | dl, 10 | dt, 11 | dd, 12 | blockquote, 13 | figure, 14 | fieldset, 15 | legend, 16 | textarea, 17 | pre, 18 | iframe, 19 | hr, 20 | h1, 21 | h2, 22 | h3, 23 | h4, 24 | h5, 25 | h6 26 | margin: 0 27 | padding: 0 28 | 29 | // Headings 30 | h1, 31 | h2, 32 | h3, 33 | h4, 34 | h5, 35 | h6 36 | font-size: 100% 37 | font-weight: normal 38 | 39 | // List 40 | ul 41 | list-style: none 42 | 43 | // Form 44 | button, 45 | input, 46 | select, 47 | textarea 48 | margin: 0 49 | 50 | // Box sizing 51 | html 52 | box-sizing: border-box 53 | 54 | * 55 | &, 56 | &::before, 57 | &::after 58 | box-sizing: inherit 59 | 60 | // Media 61 | img, 62 | video 63 | height: auto 64 | max-width: 100% 65 | 66 | // Iframe 67 | iframe 68 | border: 0 69 | 70 | // Table 71 | table 72 | border-collapse: collapse 73 | border-spacing: 0 74 | 75 | td, 76 | th 77 | padding: 0 78 | &:not([align]) 79 | text-align: inherit 80 | -------------------------------------------------------------------------------- /packer/arch64/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "type": "virtualbox-iso", 5 | "guest_os_type": "ArchLinux_64", 6 | "iso_url": "http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/iso/2014.03.01/archlinux-2014.03.01-dual.iso", 7 | "iso_checksum": "bc24540b60a5128d51b6abda462807ce51c77704", 8 | "iso_checksum_type": "sha1", 9 | "guest_additions_mode": "disable", 10 | "disk_size": 8000, 11 | "ssh_username": "vagrant", 12 | "ssh_password": "vagrant", 13 | "http_directory": "http", 14 | "boot_command": [ 15 | "", 16 | "curl -O http://{{ .HTTPIP }}:{{ .HTTPPort }}/setup.sh", 17 | "sh setup.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}" 18 | ], 19 | "vboxmanage": [ 20 | ["modifyvm", "{{.Name}}", "--memory", "512"], 21 | ["modifyvm", "{{.Name}}", "--cpus", "1"] 22 | ], 23 | "shutdown_command": "sudo shutdown -h now" 24 | } 25 | ], 26 | "provisioners": [ 27 | { 28 | "type": "shell", 29 | "scripts": ["scripts/vagrant.sh"] 30 | } 31 | ], 32 | "post-processors": ["vagrant"] 33 | } 34 | -------------------------------------------------------------------------------- /rust/dockerhub-login/src/dom.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, serde::Deserialize)] 2 | #[serde(rename_all = "camelCase")] 3 | pub struct GetDocumentResult { 4 | pub root: Node, 5 | } 6 | #[derive(Debug, serde::Deserialize)] 7 | #[serde(rename_all = "camelCase")] 8 | pub struct Node { 9 | pub node_id: NodeId, 10 | } 11 | 12 | #[derive(Debug, serde::Serialize)] 13 | #[serde(rename_all = "camelCase")] 14 | pub struct QuerySelectorParams<'a> { 15 | pub node_id: NodeId, 16 | pub selector: &'a str, 17 | } 18 | #[derive(Debug, serde::Deserialize)] 19 | #[serde(rename_all = "camelCase")] 20 | pub struct QuerySelectorResult { 21 | pub node_id: NodeId, 22 | } 23 | 24 | #[derive(Debug, serde::Serialize)] 25 | #[serde(rename_all = "camelCase")] 26 | pub struct GetBoxModelParams { 27 | pub node_id: NodeId, 28 | } 29 | #[derive(Debug, serde::Deserialize)] 30 | #[serde(rename_all = "camelCase")] 31 | pub struct GetBoxModelResult { 32 | pub model: BoxModel, 33 | } 34 | #[derive(Debug, serde::Deserialize)] 35 | #[serde(rename_all = "camelCase")] 36 | pub struct BoxModel { 37 | pub content: Quad, 38 | } 39 | 40 | pub type Quad = [f64; 8]; 41 | pub type NodeId = i64; 42 | -------------------------------------------------------------------------------- /packer/arch64/http/setup-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | 4 | echo arch64.local > /etc/hostname 5 | 6 | ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime 7 | sed -i.bak -e 's/#\(en_US.UTF-8.*\)/\1/' /etc/locale.gen 8 | rm /etc/locale.gen.bak 9 | locale-gen 10 | 11 | # For vagrant 12 | echo -e 'vagrant\nvagrant\n' | passwd 13 | useradd -m vagrant 14 | echo -e 'vagrant\nvagrant\n' | passwd vagrant 15 | echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant 16 | chmod 0440 /etc/sudoers.d/vagrant 17 | 18 | # Disable PredictableNetworkInterfaceNames. 19 | # See https://github.com/mitchellh/vagrant/blob/master/plugins/guests/arch/cap/configure_networks.rb 20 | # and http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/#idontlikethishowdoidisablethis 21 | ln -sf /dev/null /etc/udev/rules.d/80-net-name-slot.rules # v197 <= systemd <= v208 22 | ln -sf /dev/null /etc/udev/rules.d/80-net-setup-link.rules # v209 <= systemd 23 | 24 | # For ssh 25 | systemctl enable sshd.service 26 | systemctl enable dhcpcd@eth0.service 27 | 28 | mkinitcpio -p linux 29 | grub-install --target=i386-pc --recheck /dev/sda 30 | grub-mkconfig -o /boot/grub/grub.cfg 31 | -------------------------------------------------------------------------------- /rust/aws-assume-role/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, clap::Parser)] 2 | struct Args { 3 | #[clap(short, long)] 4 | role_arn: String, 5 | } 6 | 7 | #[tokio::main] 8 | async fn main() -> Result<(), Box> { 9 | use clap::Parser as _; 10 | let args = Args::parse(); 11 | 12 | let role_session_name = format!( 13 | "{}-{}", 14 | std::env::var("USER")?, 15 | std::time::SystemTime::now() 16 | .duration_since(std::time::SystemTime::UNIX_EPOCH)? 17 | .as_secs() 18 | ); 19 | 20 | let shared_config = aws_config::load_defaults(aws_config::BehaviorVersion::v2025_01_17()).await; 21 | let sts_client = aws_sdk_sts::Client::new(&shared_config); 22 | let resp = sts_client 23 | .assume_role() 24 | .role_arn(args.role_arn) 25 | .role_session_name(role_session_name) 26 | .send() 27 | .await?; 28 | let creds = resp.credentials.unwrap(); 29 | println!( 30 | "AWS_ACCESS_KEY_ID={}\nAWS_SECRET_ACCESS_KEY={}\nAWS_SESSION_TOKEN={}", 31 | creds.access_key_id, creds.secret_access_key, creds.session_token, 32 | ); 33 | 34 | Ok(()) 35 | } 36 | -------------------------------------------------------------------------------- /rust/curl2ffmpeg/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, clap::Parser)] 2 | struct Args { 3 | // curl-compat options 4 | #[clap(short = 'H')] 5 | headers: Vec, 6 | 7 | #[clap(long, default_value_t = false)] 8 | print: bool, 9 | #[clap(short, long)] 10 | output: String, 11 | 12 | url: String, 13 | } 14 | 15 | fn main() { 16 | use clap::Parser as _; 17 | let args = Args::parse(); 18 | 19 | let mut cmd = vec![ 20 | "ffmpeg".to_owned(), 21 | "-i".to_owned(), 22 | format!("'{}'", args.url), 23 | "-c:a".to_owned(), 24 | "copy".to_owned(), 25 | "-c:v".to_owned(), 26 | "copy".to_owned(), 27 | format!("'{}'", args.output), 28 | ]; 29 | for header in args.headers { 30 | cmd.push("-headers".to_owned()); 31 | cmd.push(format!("'{header}'")); 32 | } 33 | 34 | if args.print { 35 | println!("{}", cmd.join(" ")); 36 | } else { 37 | use std::os::unix::process::CommandExt as _; 38 | let mut it = cmd.into_iter(); 39 | let p = it.next().unwrap(); 40 | let err = std::process::Command::new(p).args(it).exec(); 41 | panic!("Failed to exec ffmpeg: {err}"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /rust/s3-du/src/main.rs: -------------------------------------------------------------------------------- 1 | use clap::Parser as _; 2 | 3 | #[derive(Debug, clap::Parser)] 4 | struct Opt { 5 | #[clap(short, long)] 6 | bucket: String, 7 | #[clap(short, long)] 8 | prefix: String, 9 | } 10 | 11 | #[tokio::main] 12 | async fn main() -> Result<(), Box> { 13 | let opt = Opt::parse(); 14 | 15 | let shared_config = aws_config::load_defaults(aws_config::BehaviorVersion::v2025_01_17()).await; 16 | let s3_client = aws_sdk_s3::Client::new(&shared_config); 17 | 18 | let mut continuation_token = None; 19 | let mut size = 0; 20 | loop { 21 | let resp = s3_client 22 | .list_objects_v2() 23 | .bucket(&opt.bucket) 24 | .prefix(&opt.prefix) 25 | .set_continuation_token(continuation_token) 26 | .send() 27 | .await?; 28 | continuation_token = resp.next_continuation_token; 29 | 30 | if let Some(contents) = resp.contents { 31 | for content in contents { 32 | size += content.size.expect("content size is none"); 33 | } 34 | } 35 | 36 | if continuation_token.is_none() { 37 | break; 38 | } 39 | } 40 | println!("{}", size); 41 | 42 | Ok(()) 43 | } 44 | -------------------------------------------------------------------------------- /rust/miam2tf/build.rs: -------------------------------------------------------------------------------- 1 | fn main() -> Result<(), Box> { 2 | if !std::process::Command::new("rake") 3 | .env("MRUBY_CONFIG", "build_config.rb") 4 | .status()? 5 | .success() 6 | { 7 | panic!("failed to build mruby"); 8 | } 9 | println!("cargo:rustc-link-search=native=miam2tf/vendor/mruby/build/host/lib"); 10 | println!("cargo:rustc-link-lib=static=mruby"); 11 | 12 | println!("cargo:rerun-if-changed=include/wrapper.h"); 13 | println!("cargo:rerun-if-changed=src/wrapper.c"); 14 | println!("cargo:rerun-if-changed=build_config.rb"); 15 | println!("cargo:rerun-if-changed=mrblib/miam.rb"); 16 | 17 | let bindings = bindgen::Builder::default() 18 | .clang_arg("-Ivendor/mruby/include") 19 | .header("include/wrapper.h") 20 | .blocklist_item("FP_NAN") 21 | .blocklist_item("FP_INFINITE") 22 | .blocklist_item("FP_ZERO") 23 | .blocklist_item("FP_SUBNORMAL") 24 | .blocklist_item("FP_NORMAL") 25 | .generate_comments(false) 26 | .generate() 27 | .expect("unable to generate bindings"); 28 | let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR")?); 29 | bindings.write_to_file(out_path.join("bindings.rs"))?; 30 | Ok(()) 31 | } 32 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/icon.sass: -------------------------------------------------------------------------------- 1 | $icon-dimensions: 1.5rem !default 2 | $icon-dimensions-small: 1rem !default 3 | $icon-dimensions-medium: 2rem !default 4 | $icon-dimensions-large: 3rem !default 5 | $icon-text-spacing: 0.25em !default 6 | 7 | .icon 8 | align-items: center 9 | display: inline-flex 10 | justify-content: center 11 | height: $icon-dimensions 12 | width: $icon-dimensions 13 | // Sizes 14 | &.is-small 15 | height: $icon-dimensions-small 16 | width: $icon-dimensions-small 17 | &.is-medium 18 | height: $icon-dimensions-medium 19 | width: $icon-dimensions-medium 20 | &.is-large 21 | height: $icon-dimensions-large 22 | width: $icon-dimensions-large 23 | 24 | .icon-text 25 | align-items: flex-start 26 | color: inherit 27 | display: inline-flex 28 | flex-wrap: wrap 29 | line-height: $icon-dimensions 30 | vertical-align: top 31 | .icon 32 | flex-grow: 0 33 | flex-shrink: 0 34 | &:not(:last-child) 35 | +ltr 36 | margin-right: $icon-text-spacing 37 | +rtl 38 | margin-left: $icon-text-spacing 39 | &:not(:first-child) 40 | +ltr 41 | margin-left: $icon-text-spacing 42 | +rtl 43 | margin-right: $icon-text-spacing 44 | 45 | div.icon-text 46 | display: flex 47 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/color.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/derived-variables" 2 | 3 | @each $name, $pair in $colors 4 | $color: nth($pair, 1) 5 | .has-text-#{$name} 6 | color: $color !important 7 | a.has-text-#{$name} 8 | &:hover, 9 | &:focus 10 | color: bulmaDarken($color, 10%) !important 11 | .has-background-#{$name} 12 | background-color: $color !important 13 | @if length($pair) >= 4 14 | $color-light: nth($pair, 3) 15 | $color-dark: nth($pair, 4) 16 | // Light 17 | .has-text-#{$name}-light 18 | color: $color-light !important 19 | a.has-text-#{$name}-light 20 | &:hover, 21 | &:focus 22 | color: bulmaDarken($color-light, 10%) !important 23 | .has-background-#{$name}-light 24 | background-color: $color-light !important 25 | // Dark 26 | .has-text-#{$name}-dark 27 | color: $color-dark !important 28 | a.has-text-#{$name}-dark 29 | &:hover, 30 | &:focus 31 | color: bulmaLighten($color-dark, 10%) !important 32 | .has-background-#{$name}-dark 33 | background-color: $color-dark !important 34 | 35 | @each $name, $shade in $shades 36 | .has-text-#{$name} 37 | color: $shade !important 38 | .has-background-#{$name} 39 | background-color: $shade !important 40 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/spacing.sass: -------------------------------------------------------------------------------- 1 | .is-marginless 2 | margin: 0 !important 3 | 4 | .is-paddingless 5 | padding: 0 !important 6 | 7 | $spacing-shortcuts: ("margin": "m", "padding": "p") !default 8 | $spacing-directions: ("top": "t", "right": "r", "bottom": "b", "left": "l") !default 9 | $spacing-horizontal: "x" !default 10 | $spacing-vertical: "y" !default 11 | $spacing-values: ("0": 0, "1": 0.25rem, "2": 0.5rem, "3": 0.75rem, "4": 1rem, "5": 1.5rem, "6": 3rem, "auto": auto) !default 12 | 13 | @each $property, $shortcut in $spacing-shortcuts 14 | @each $name, $value in $spacing-values 15 | // All directions 16 | .#{$shortcut}-#{$name} 17 | #{$property}: $value !important 18 | // Cardinal directions 19 | @each $direction, $suffix in $spacing-directions 20 | .#{$shortcut}#{$suffix}-#{$name} 21 | #{$property}-#{$direction}: $value !important 22 | // Horizontal axis 23 | @if $spacing-horizontal != null 24 | .#{$shortcut}#{$spacing-horizontal}-#{$name} 25 | #{$property}-left: $value !important 26 | #{$property}-right: $value !important 27 | // Vertical axis 28 | @if $spacing-vertical != null 29 | .#{$shortcut}#{$spacing-vertical}-#{$name} 30 | #{$property}-top: $value !important 31 | #{$property}-bottom: $value !important 32 | -------------------------------------------------------------------------------- /rust/dockerhub-login/src/cdp.rs: -------------------------------------------------------------------------------- 1 | pub type SessionId = String; 2 | 3 | #[derive(Debug, serde::Serialize)] 4 | #[serde(rename_all = "camelCase")] 5 | pub struct Request<'a, T> { 6 | pub id: u64, 7 | #[serde(skip_serializing_if = "Option::is_none")] 8 | pub session_id: Option<&'a SessionId>, 9 | pub method: &'static str, 10 | pub params: T, 11 | } 12 | 13 | #[derive(Debug, serde::Deserialize)] 14 | #[serde(rename_all = "camelCase")] 15 | pub struct Response { 16 | pub id: u64, 17 | pub session_id: Option, 18 | pub result: T, 19 | } 20 | 21 | #[derive(Debug, serde::Deserialize)] 22 | #[serde(rename_all = "camelCase")] 23 | pub struct ErrorResponse { 24 | pub id: u64, 25 | pub session_id: Option, 26 | pub error: CdpError, 27 | } 28 | 29 | #[derive(Debug, serde::Deserialize)] 30 | #[serde(rename_all = "camelCase")] 31 | pub struct CdpError { 32 | pub code: i64, 33 | pub message: String, 34 | } 35 | impl std::fmt::Display for CdpError { 36 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 37 | write!(f, "CdpError: code={} message={}", self.code, self.message) 38 | } 39 | } 40 | impl std::error::Error for CdpError {} 41 | 42 | #[derive(Debug, serde::Deserialize)] 43 | #[serde(rename_all = "camelCase")] 44 | pub struct Event { 45 | pub session_id: String, 46 | pub method: String, 47 | pub params: T, 48 | } 49 | -------------------------------------------------------------------------------- /rust/git-pkgbuild-commit/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() -> anyhow::Result<()> { 2 | let repo = gix::discover(".")?; 3 | let index = repo.index()?; 4 | let Some(entry) = index.entry_by_path(".SRCINFO".into()) else { 5 | anyhow::bail!(".SRCINFO does not exist"); 6 | }; 7 | let object = repo.find_object(entry.id)?; 8 | 9 | if !is_staged(&repo, &object)? { 10 | println!(".SRCINFO is not staged"); 11 | return Ok(()); 12 | } 13 | 14 | let blob = object.into_blob(); 15 | let srcinfo = String::from_utf8_lossy(&blob.data); 16 | let Some(pkgver) = srcinfo.lines().find_map(|line| { 17 | let line = line.trim_start(); 18 | const PKGVER_PREFIX: &str = "pkgver = "; 19 | line.starts_with(PKGVER_PREFIX) 20 | .then(|| &line[PKGVER_PREFIX.len()..]) 21 | }) else { 22 | anyhow::bail!("Cannot find pkgver from .SRCINFO"); 23 | }; 24 | 25 | let status = std::process::Command::new("git") 26 | .args(["commit", "-m"]) 27 | .arg(format!("Update to v{}", pkgver)) 28 | .status()?; 29 | anyhow::ensure!(status.success(), "git-commit failed"); 30 | 31 | Ok(()) 32 | } 33 | 34 | fn is_staged(repo: &gix::Repository, object: &gix::Object) -> anyhow::Result { 35 | let tree = repo.head_commit()?.tree()?; 36 | if let Some(entry) = tree.find_entry(".SRCINFO") { 37 | Ok(object.id != entry.oid()) 38 | } else { 39 | // .SRCINFO is new blob 40 | Ok(true) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/flexbox.sass: -------------------------------------------------------------------------------- 1 | $flex-direction-values: row, row-reverse, column, column-reverse 2 | @each $value in $flex-direction-values 3 | .is-flex-direction-#{$value} 4 | flex-direction: $value !important 5 | 6 | $flex-wrap-values: nowrap, wrap, wrap-reverse 7 | @each $value in $flex-wrap-values 8 | .is-flex-wrap-#{$value} 9 | flex-wrap: $value !important 10 | 11 | $justify-content-values: flex-start, flex-end, center, space-between, space-around, space-evenly, start, end, left, right 12 | @each $value in $justify-content-values 13 | .is-justify-content-#{$value} 14 | justify-content: $value !important 15 | 16 | $align-content-values: flex-start, flex-end, center, space-between, space-around, space-evenly, stretch, start, end, baseline 17 | @each $value in $align-content-values 18 | .is-align-content-#{$value} 19 | align-content: $value !important 20 | 21 | $align-items-values: stretch, flex-start, flex-end, center, baseline, start, end, self-start, self-end 22 | @each $value in $align-items-values 23 | .is-align-items-#{$value} 24 | align-items: $value !important 25 | 26 | $align-self-values: auto, flex-start, flex-end, center, baseline, stretch 27 | @each $value in $align-self-values 28 | .is-align-self-#{$value} 29 | align-self: $value !important 30 | 31 | $flex-operators: grow, shrink 32 | @each $operator in $flex-operators 33 | @for $i from 0 through 5 34 | .is-flex-#{$operator}-#{$i} 35 | flex-#{$operator}: $i !important 36 | -------------------------------------------------------------------------------- /rust/assert_trait/examples/assert.rs: -------------------------------------------------------------------------------- 1 | use futures::StreamExt as _; 2 | 3 | #[tokio::main] 4 | async fn main() -> Result<(), Box> { 5 | for c in assert_trait::assert_trait!(Iterator, "assert".chars()) { 6 | println!("{}", c); 7 | } 8 | for line in assert_trait::assert_trait!(<'a>, Iterator, "a\nb\nc".lines()) { 9 | println!("{}", line); 10 | } 11 | 12 | let interval = assert_trait::assert_trait!( 13 | futures::Stream + Unpin, 14 | tokio_stream::wrappers::IntervalStream::new(tokio::time::interval( 15 | tokio::time::Duration::from_secs(2) 16 | )) 17 | .map(|i| futures::future::Either::Left(i)) 18 | .take(4) 19 | ); 20 | let status = futures::stream::once(tokio::process::Command::new("sleep").arg("6").status()) 21 | .map(|s| futures::future::Either::Right(s)); 22 | // OK 23 | let status = assert_trait::assert_trait!(futures::Stream, status); 24 | // NG 25 | // let status = assert_trait::assert_trait!(Unpin, status); 26 | tokio::pin!(status); 27 | // OK 28 | let status = assert_trait::assert_trait!(Unpin, status); 29 | let mut stream = assert_trait::assert_trait!( 30 | futures::Stream>> + Unpin, 31 | futures::stream::select(interval, status) 32 | ); 33 | while let Some(item) = stream.next().await { 34 | println!("{:?}", item); 35 | } 36 | 37 | Ok(()) 38 | } 39 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/utilities/controls.sass: -------------------------------------------------------------------------------- 1 | @import "derived-variables" 2 | 3 | $control-radius: $radius !default 4 | $control-radius-small: $radius-small !default 5 | 6 | $control-border-width: 1px !default 7 | 8 | $control-height: 2.5em !default 9 | $control-line-height: 1.5 !default 10 | 11 | $control-padding-vertical: calc(0.5em - #{$control-border-width}) !default 12 | $control-padding-horizontal: calc(0.75em - #{$control-border-width}) !default 13 | 14 | =control 15 | -moz-appearance: none 16 | -webkit-appearance: none 17 | align-items: center 18 | border: $control-border-width solid transparent 19 | border-radius: $control-radius 20 | box-shadow: none 21 | display: inline-flex 22 | font-size: $size-normal 23 | height: $control-height 24 | justify-content: flex-start 25 | line-height: $control-line-height 26 | padding-bottom: $control-padding-vertical 27 | padding-left: $control-padding-horizontal 28 | padding-right: $control-padding-horizontal 29 | padding-top: $control-padding-vertical 30 | position: relative 31 | vertical-align: top 32 | // States 33 | &:focus, 34 | &.is-focused, 35 | &:active, 36 | &.is-active 37 | outline: none 38 | &[disabled], 39 | fieldset[disabled] & 40 | cursor: not-allowed 41 | 42 | // The controls sizes use mixins so they can be used at different breakpoints 43 | =control-small 44 | border-radius: $control-radius-small 45 | font-size: $size-small 46 | =control-medium 47 | font-size: $size-medium 48 | =control-large 49 | font-size: $size-large 50 | -------------------------------------------------------------------------------- /gce/archlinux/create-image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | id="${RANDOM}" 5 | disk_name="archlinux-builder-data-${id}" 6 | instance_name="archlinux-builder-${id}" 7 | zone='asia-northeast1-a' 8 | machine_type='n1-standard-1' 9 | image_name="archlinux-$(date +%Y-%m-%d)-${id}" 10 | 11 | # user defined 12 | network='gcp' 13 | subnet='apne1' 14 | 15 | echo "Create disk $disk_name" 16 | gcloud compute disks create "$disk_name" \ 17 | --type pd-ssd \ 18 | --size 10GB \ 19 | --zone "$zone" 20 | 21 | echo "Create instance $instance_name" 22 | gcloud compute instances create "$instance_name" \ 23 | --image-project ubuntu-os-cloud \ 24 | --image-family ubuntu-1604-lts \ 25 | --machine-type "$machine_type" \ 26 | --zone "$zone" \ 27 | --network "$network" \ 28 | --subnet "$subnet" \ 29 | --metadata-from-file startup-script=startup-script.sh \ 30 | --scopes compute-rw \ 31 | --disk "name=$disk_name,mode=rw" 32 | 33 | cat < create-image-next-${id}.sh 34 | #!/bin/bash 35 | set -ex 36 | 37 | echo "Delete instance $instance_name" 38 | gcloud compute instances delete "$instance_name" \ 39 | --quiet \ 40 | --zone "$zone" 41 | 42 | echo "Create image $image_name from $disk_name" 43 | gcloud compute images create "$image_name" \ 44 | --family archlinux \ 45 | --source-disk "$disk_name" \ 46 | --source-disk-zone "$zone" 47 | 48 | echo "Delete disk $disk_name" 49 | gcloud compute disks delete "$disk_name" \ 50 | --quiet \ 51 | --zone "$zone" 52 | 53 | EOS 54 | chmod +x create-image-next-${id}.sh 55 | echo "Run create-image-next-${id}.sh after startup-script.sh finished" 56 | -------------------------------------------------------------------------------- /rust/corretto-pkgbuild/src/template/PKGBUILD: -------------------------------------------------------------------------------- 1 | {{ #if maintainer }}# Maintainer: {{ maintainer }}{{ /if }} 2 | pkgname=amazon-corretto-{{ jdk_version }} 3 | pkgver={{ pkgver }} 4 | pkgrel={{ pkgrel }} 5 | pkgdesc='No-cost, multiplatform, production-ready distribution of OpenJDK' 6 | arch=('x86_64' 'aarch64') 7 | url='https://aws.amazon.com/corretto/' 8 | license=('GPL2') 9 | depends=('java-runtime-common' 'java-environment-common') 10 | provides=('java-runtime-headless={{ jdk_version }}' 'java-runtime={{ jdk_version }}' 'java-environment={{ jdk_version }}') 11 | backup=() 12 | options=() 13 | # https://docs.aws.amazon.com/corretto/latest/corretto-{{ jdk_version }}-ug/downloads-list.html 14 | source_x86_64=("https://corretto.aws/downloads/resources/${pkgver}/amazon-corretto-${pkgver}-linux-x64.tar.gz"{,.sig}) 15 | source_aarch64=("https://corretto.aws/downloads/resources/${pkgver}/amazon-corretto-${pkgver}-linux-aarch64.tar.gz"{,.sig}) 16 | validpgpkeys=('6DC3636DAE534049C8B94623A122542AB04F24E3') # Amazon Services LLC (Amazon Corretto release) 17 | 18 | package() { 19 | mkdir -p "$pkgdir/usr/lib/jvm" 20 | case "$CARCH" in 21 | "x86_64") 22 | cp -a "amazon-corretto-$pkgver-linux-x64" "$pkgdir/usr/lib/jvm/java-{{ jdk_version }}-amazon-corretto" 23 | ;; 24 | "aarch64") 25 | cp -a "amazon-corretto-$pkgver-linux-aarch64" "$pkgdir/usr/lib/jvm/java-{{ jdk_version }}-amazon-corretto" 26 | ;; 27 | esac 28 | } 29 | 30 | sha256sums_x86_64=('{{ x86_64_checksum_sha256 }}' 31 | 'SKIP') 32 | sha256sums_aarch64=('{{ aarch64_checksum_sha256 }}' 33 | 'SKIP') 34 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/image.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $dimensions: 16 24 32 48 64 96 128 !default 4 | 5 | .image 6 | display: block 7 | position: relative 8 | img 9 | display: block 10 | height: auto 11 | width: 100% 12 | &.is-rounded 13 | border-radius: $radius-rounded 14 | &.is-fullwidth 15 | width: 100% 16 | // Ratio 17 | &.is-square, 18 | &.is-1by1, 19 | &.is-5by4, 20 | &.is-4by3, 21 | &.is-3by2, 22 | &.is-5by3, 23 | &.is-16by9, 24 | &.is-2by1, 25 | &.is-3by1, 26 | &.is-4by5, 27 | &.is-3by4, 28 | &.is-2by3, 29 | &.is-3by5, 30 | &.is-9by16, 31 | &.is-1by2, 32 | &.is-1by3 33 | img, 34 | .has-ratio 35 | @extend %overlay 36 | height: 100% 37 | width: 100% 38 | &.is-square, 39 | &.is-1by1 40 | padding-top: 100% 41 | &.is-5by4 42 | padding-top: 80% 43 | &.is-4by3 44 | padding-top: 75% 45 | &.is-3by2 46 | padding-top: 66.6666% 47 | &.is-5by3 48 | padding-top: 60% 49 | &.is-16by9 50 | padding-top: 56.25% 51 | &.is-2by1 52 | padding-top: 50% 53 | &.is-3by1 54 | padding-top: 33.3333% 55 | &.is-4by5 56 | padding-top: 125% 57 | &.is-3by4 58 | padding-top: 133.3333% 59 | &.is-2by3 60 | padding-top: 150% 61 | &.is-3by5 62 | padding-top: 166.6666% 63 | &.is-9by16 64 | padding-top: 177.7777% 65 | &.is-1by2 66 | padding-top: 200% 67 | &.is-1by3 68 | padding-top: 300% 69 | // Sizes 70 | @each $dimension in $dimensions 71 | &.is-#{$dimension}x#{$dimension} 72 | height: $dimension * 1px 73 | width: $dimension * 1px 74 | -------------------------------------------------------------------------------- /rust/corretto-pkgbuild/README.md: -------------------------------------------------------------------------------- 1 | # corretto-pkgbuild 2 | Generate PKGBUILD for Amazon Corretto from GitHub releases. 3 | 4 | ## Usage 5 | ``` 6 | % corretto-pkgbuild -j 8 7 | pkgname=amazon-corretto-8 8 | pkgver=8.342.07.4 9 | pkgrel=1 10 | pkgdesc='No-cost, multiplatform, production-ready distribution of OpenJDK' 11 | arch=('x86_64' 'aarch64') 12 | url='https://aws.amazon.com/corretto/' 13 | license=('GPL2') 14 | depends=('java-runtime-common' 'java-environment-common') 15 | provides=('java-runtime-headless=8' 'java-runtime=8' 'java-environment=8') 16 | backup=() 17 | options=() 18 | # https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/downloads-list.html 19 | source_x86_64=("https://corretto.aws/downloads/resources/${pkgver}/amazon-corretto-${pkgver}-linux-x64.tar.gz"{,.sig}) 20 | source_aarch64=("https://corretto.aws/downloads/resources/${pkgver}/amazon-corretto-${pkgver}-linux-aarch64.tar.gz"{,.sig}) 21 | validpgpkeys=('6DC3636DAE534049C8B94623A122542AB04F24E3') # Amazon Services LLC (Amazon Corretto release) 22 | 23 | package() { 24 | mkdir -p "$pkgdir/usr/lib/jvm" 25 | case "$CARCH" in 26 | "x86_64") 27 | cp -a "amazon-corretto-$pkgver-linux-x64" "$pkgdir/usr/lib/jvm/java-8-amazon-corretto" 28 | ;; 29 | "aarch64") 30 | cp -a "amazon-corretto-$pkgver-linux-aarch64" "$pkgdir/usr/lib/jvm/java-8-amazon-corretto" 31 | ;; 32 | esac 33 | } 34 | 35 | sha256sums_x86_64=('f10fc46f42df58cf26a4689a7016aa610b691ad4e8be7c349f8651dec79d4e41' 36 | 'SKIP') 37 | sha256sums_aarch64=('2d454c4804fc2ee5a2aef9f517ca6c2b85dee7728d74edf20f85a35681b2d143' 38 | 'SKIP') 39 | ``` 40 | -------------------------------------------------------------------------------- /rust/errno/build.rs: -------------------------------------------------------------------------------- 1 | #[allow(clippy::type_complexity)] 2 | static MACROS: once_cell::sync::OnceCell>>> = 3 | once_cell::sync::OnceCell::new(); 4 | 5 | #[derive(Debug, Default)] 6 | struct MacroCollector {} 7 | 8 | impl bindgen::callbacks::ParseCallbacks for MacroCollector { 9 | fn int_macro(&self, name: &str, value: i64) -> Option { 10 | if name.starts_with('E') { 11 | MACROS 12 | .get() 13 | .unwrap() 14 | .lock() 15 | .unwrap() 16 | .borrow_mut() 17 | .push((name.to_owned(), value as i32)); 18 | } 19 | None 20 | } 21 | } 22 | 23 | fn main() -> Result<(), Box> { 24 | use std::io::Write as _; 25 | MACROS.set(Default::default()).unwrap(); 26 | 27 | bindgen::builder() 28 | .header_contents("wrapper.h", "#include ") 29 | .parse_callbacks(Box::::default()) 30 | .generate() 31 | .expect("unable to collect macros"); 32 | 33 | let out_dir = std::env::var("OUT_DIR")?; 34 | let mut file = std::fs::File::create(std::path::Path::new(&out_dir).join("errno.rs"))?; 35 | writeln!(file, "pub const ERROR_NUMBERS: &[(&str, i32, &str)] = &[")?; 36 | for (name, value) in MACROS.get().unwrap().lock()?.borrow().iter() { 37 | let message = unsafe { std::ffi::CStr::from_ptr(libc::strerror(*value)).to_str()? }; 38 | writeln!(file, "(\"{}\", {}, \"{}\"),", name, value, message)?; 39 | } 40 | writeln!(file, "];")?; 41 | Ok(()) 42 | } 43 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/notification.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $notification-background-color: $background !default 4 | $notification-code-background-color: $scheme-main !default 5 | $notification-radius: $radius !default 6 | $notification-padding: 1.25rem 2.5rem 1.25rem 1.5rem !default 7 | $notification-padding-ltr: 1.25rem 2.5rem 1.25rem 1.5rem !default 8 | $notification-padding-rtl: 1.25rem 1.5rem 1.25rem 2.5rem !default 9 | 10 | $notification-colors: $colors !default 11 | 12 | .notification 13 | @extend %block 14 | background-color: $notification-background-color 15 | border-radius: $notification-radius 16 | position: relative 17 | +ltr 18 | padding: $notification-padding-ltr 19 | +rtl 20 | padding: $notification-padding-rtl 21 | a:not(.button):not(.dropdown-item) 22 | color: currentColor 23 | text-decoration: underline 24 | strong 25 | color: currentColor 26 | code, 27 | pre 28 | background: $notification-code-background-color 29 | pre code 30 | background: transparent 31 | & > .delete 32 | +ltr-position(0.5rem) 33 | position: absolute 34 | top: 0.5rem 35 | .title, 36 | .subtitle, 37 | .content 38 | color: currentColor 39 | // Colors 40 | @each $name, $pair in $notification-colors 41 | $color: nth($pair, 1) 42 | $color-invert: nth($pair, 2) 43 | &.is-#{$name} 44 | background-color: $color 45 | color: $color-invert 46 | // If light and dark colors are provided 47 | @if length($pair) >= 4 48 | $color-light: nth($pair, 3) 49 | $color-dark: nth($pair, 4) 50 | &.is-light 51 | background-color: $color-light 52 | color: $color-dark 53 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/media.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $media-border-color: bulmaRgba($border, 0.5) !default 4 | $media-border-size: 1px !default 5 | $media-spacing: 1rem !default 6 | $media-spacing-large: 1.5rem !default 7 | $media-content-spacing: 0.75rem !default 8 | $media-level-1-spacing: 0.75rem !default 9 | $media-level-1-content-spacing: 0.5rem !default 10 | $media-level-2-spacing: 0.5rem !default 11 | 12 | .media 13 | align-items: flex-start 14 | display: flex 15 | text-align: inherit 16 | .content:not(:last-child) 17 | margin-bottom: $media-content-spacing 18 | .media 19 | border-top: $media-border-size solid $media-border-color 20 | display: flex 21 | padding-top: $media-level-1-spacing 22 | .content:not(:last-child), 23 | .control:not(:last-child) 24 | margin-bottom: $media-level-1-content-spacing 25 | .media 26 | padding-top: $media-level-2-spacing 27 | & + .media 28 | margin-top: $media-level-2-spacing 29 | & + .media 30 | border-top: $media-border-size solid $media-border-color 31 | margin-top: $media-spacing 32 | padding-top: $media-spacing 33 | // Sizes 34 | &.is-large 35 | & + .media 36 | margin-top: $media-spacing-large 37 | padding-top: $media-spacing-large 38 | 39 | .media-left, 40 | .media-right 41 | flex-basis: auto 42 | flex-grow: 0 43 | flex-shrink: 0 44 | 45 | .media-left 46 | +ltr-property("margin", $media-spacing) 47 | 48 | .media-right 49 | +ltr-property("margin", $media-spacing, false) 50 | 51 | .media-content 52 | flex-basis: auto 53 | flex-grow: 1 54 | flex-shrink: 1 55 | text-align: inherit 56 | 57 | +mobile 58 | .media-content 59 | overflow-x: auto 60 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/form/input-textarea.sass: -------------------------------------------------------------------------------- 1 | $textarea-padding: $control-padding-horizontal !default 2 | $textarea-max-height: 40em !default 3 | $textarea-min-height: 8em !default 4 | 5 | $textarea-colors: $form-colors !default 6 | 7 | %input-textarea 8 | @extend %input 9 | box-shadow: $input-shadow 10 | max-width: 100% 11 | width: 100% 12 | &[readonly] 13 | box-shadow: none 14 | // Colors 15 | @each $name, $pair in $textarea-colors 16 | $color: nth($pair, 1) 17 | &.is-#{$name} 18 | border-color: $color 19 | &:focus, 20 | &.is-focused, 21 | &:active, 22 | &.is-active 23 | box-shadow: $input-focus-box-shadow-size bulmaRgba($color, 0.25) 24 | // Sizes 25 | &.is-small 26 | +control-small 27 | &.is-medium 28 | +control-medium 29 | &.is-large 30 | +control-large 31 | // Modifiers 32 | &.is-fullwidth 33 | display: block 34 | width: 100% 35 | &.is-inline 36 | display: inline 37 | width: auto 38 | 39 | .input 40 | @extend %input-textarea 41 | &.is-rounded 42 | border-radius: $radius-rounded 43 | padding-left: calc(#{$control-padding-horizontal} + 0.375em) 44 | padding-right: calc(#{$control-padding-horizontal} + 0.375em) 45 | &.is-static 46 | background-color: transparent 47 | border-color: transparent 48 | box-shadow: none 49 | padding-left: 0 50 | padding-right: 0 51 | 52 | .textarea 53 | @extend %input-textarea 54 | display: block 55 | max-width: 100% 56 | min-width: 100% 57 | padding: $textarea-padding 58 | resize: vertical 59 | &:not([rows]) 60 | max-height: $textarea-max-height 61 | min-height: $textarea-min-height 62 | &[rows] 63 | height: initial 64 | // Modifiers 65 | &.has-fixed-size 66 | resize: none 67 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/level.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $level-item-spacing: ($block-spacing * 0.5) !default 4 | 5 | .level 6 | @extend %block 7 | align-items: center 8 | justify-content: space-between 9 | code 10 | border-radius: $radius 11 | img 12 | display: inline-block 13 | vertical-align: top 14 | // Modifiers 15 | &.is-mobile 16 | display: flex 17 | .level-left, 18 | .level-right 19 | display: flex 20 | .level-left + .level-right 21 | margin-top: 0 22 | .level-item 23 | &:not(:last-child) 24 | margin-bottom: 0 25 | +ltr-property("margin", $level-item-spacing) 26 | &:not(.is-narrow) 27 | flex-grow: 1 28 | // Responsiveness 29 | +tablet 30 | display: flex 31 | & > .level-item 32 | &:not(.is-narrow) 33 | flex-grow: 1 34 | 35 | .level-item 36 | align-items: center 37 | display: flex 38 | flex-basis: auto 39 | flex-grow: 0 40 | flex-shrink: 0 41 | justify-content: center 42 | .title, 43 | .subtitle 44 | margin-bottom: 0 45 | // Responsiveness 46 | +mobile 47 | &:not(:last-child) 48 | margin-bottom: $level-item-spacing 49 | 50 | .level-left, 51 | .level-right 52 | flex-basis: auto 53 | flex-grow: 0 54 | flex-shrink: 0 55 | .level-item 56 | // Modifiers 57 | &.is-flexible 58 | flex-grow: 1 59 | // Responsiveness 60 | +tablet 61 | &:not(:last-child) 62 | +ltr-property("margin", $level-item-spacing) 63 | 64 | .level-left 65 | align-items: center 66 | justify-content: flex-start 67 | // Responsiveness 68 | +mobile 69 | & + .level-right 70 | margin-top: 1.5rem 71 | +tablet 72 | display: flex 73 | 74 | .level-right 75 | align-items: center 76 | justify-content: flex-end 77 | // Responsiveness 78 | +tablet 79 | display: flex 80 | -------------------------------------------------------------------------------- /rust/corretto-pkgbuild/test/corretto-11.0.16.8.3.md: -------------------------------------------------------------------------------- 1 | For release notes see : [CHANGELOG.md](https://github.com/corretto/corretto-11/blob/release-11.0.16.8.3/CHANGELOG.md) 2 | 3 | |Platform |Type |Download Link |Checksum (MD5) / Checksum (SHA256) |Sig File | 4 | |--- |--- |--- |--- |--- | 5 | |[macOS x64](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/macos-install.html) |JDK |[amazon-corretto-11.0.16.8.3-macosx-x64.pkg](https://corretto.aws/downloads/resources/11.0.16.8.3/amazon-corretto-11.0.16.8.3-macosx-x64.pkg) | `dd72fbbfa721e3cd422a2a5883c4755c` /
`6ea0caa2d5cedb859ddb470e54dac08377c216b5921c10dedfb1c2f2e0c58545` | | 6 | |[macOS x64](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/macos-install.html) |JDK |[amazon-corretto-11.0.16.8.3-macosx-x64.tar.gz](https://corretto.aws/downloads/resources/11.0.16.8.3/amazon-corretto-11.0.16.8.3-macosx-x64.tar.gz) | `f629535046b54667cc5ec6653935c269` /
`8d015d4bf405b5027bd88a806a025078a8daa82afbaab06b2ed64c9e638e1e01` | [Download](https://corretto.aws/downloads/resources/11.0.16.8.3/amazon-corretto-11.0.16.8.3-macosx-x64.tar.gz.sig) | 7 | |[macOS aarch64](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/macos-install.html) |JDK |[amazon-corretto-11.0.16.8.3-macosx-aarch64.pkg](https://corretto.aws/downloads/resources/11.0.16.8.3/amazon-corretto-11.0.16.8.3-macosx-aarch64.pkg) | `001995b4b62e5b44ac71b740403e54d4` /
`ba5fdc6ce029f8aa2e2789408266334c480616a058f49b3c8696a591fbc997a3` | | 8 | |[macOS aarch64](https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/macos-install.html) |JDK |[amazon-corretto-11.0.16.8.3-macosx-aarch64.tar.gz](https://corretto.aws/downloads/resources/11.0.16.8.3/amazon-corretto-11.0.16.8.3-macosx-aarch64.tar.gz) | `97ef4f95aaa583a85f2654238d8bf675` /
`b3a85aa264b2c4fc49f70001ccff40b30b9d5e719c57b4ff3d24631d3e6ed4d0` | [Download](https://corretto.aws/downloads/resources/11.0.16.8.3/amazon-corretto-11.0.16.8.3-macosx-aarch64.tar.gz.sig) | 9 | -------------------------------------------------------------------------------- /rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | 4 | members = [ 5 | "./agent-proto", 6 | "./ambiwidth", 7 | "./assert_trait", 8 | "./aws-assume-role", 9 | "./corretto-pkgbuild", 10 | "./dockerhub-login", 11 | "./envwarden", 12 | "./errno", 13 | "./gh-contrib", 14 | "./git-pkgbuild-commit", 15 | "./github-api-v4-sample", 16 | "./go-bridge-sample", 17 | "./graphql-sample/sample-client", 18 | "./graphql-sample/sample-server", 19 | "./grpc-sample", 20 | "./gyazo", 21 | "./jrsonnet-lint", 22 | "./miam2tf", 23 | "./pfs-unpack", 24 | "./ray-tracing-one-weekend", 25 | "./rdig", 26 | "./s3-du", 27 | "./s3-prefix-get", 28 | "./tls-cert-expiration", 29 | "./xft-height", 30 | "./unused-libsonnet", 31 | ] 32 | 33 | [workspace.dependencies] 34 | anstream = "0.6" 35 | anstyle = "1" 36 | anyhow = { version = "1", features = ["backtrace"] } 37 | aws-config = "1" 38 | aws-sdk-s3 = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] } 39 | aws-sdk-sts = { version = "1", default-features = false, features = ["default-https-client"] } 40 | bindgen = "0.71" 41 | chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] } 42 | clap = { version = "4", features = ["derive", "env"] } 43 | futures = "0.3" 44 | graphql_client = "0.14" 45 | jrsonnet-evaluator = "0.5.0-pre95" 46 | jrsonnet-gcmodule = "0.3" 47 | jrsonnet-parser = "0.5.0-pre95" 48 | jrsonnet-stdlib = "0.5.0-pre95" 49 | libc = "0.2" 50 | prost = "0.13" 51 | reqwest = { version = "0.12", default-features = false, features = ["gzip", "rustls-tls", "stream", "trust-dns", "json"] } 52 | serde = { version = "1", features = ["derive"] } 53 | serde_json = "1" 54 | tempfile = "3" 55 | tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "signal", "time", "process", "tracing"] } 56 | tonic = "0.13" 57 | tonic-build = "0.13" 58 | tower = "0.5" 59 | tracing = "0.1" 60 | tracing-subscriber = { version = "0.3", features = ["env-filter"] } 61 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/menu.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $menu-item-color: $text !default 4 | $menu-item-radius: $radius-small !default 5 | $menu-item-hover-color: $text-strong !default 6 | $menu-item-hover-background-color: $background !default 7 | $menu-item-active-color: $link-invert !default 8 | $menu-item-active-background-color: $link !default 9 | 10 | $menu-list-border-left: 1px solid $border !default 11 | $menu-list-line-height: 1.25 !default 12 | $menu-list-link-padding: 0.5em 0.75em !default 13 | $menu-nested-list-margin: 0.75em !default 14 | $menu-nested-list-padding-left: 0.75em !default 15 | 16 | $menu-label-color: $text-light !default 17 | $menu-label-font-size: 0.75em !default 18 | $menu-label-letter-spacing: 0.1em !default 19 | $menu-label-spacing: 1em !default 20 | 21 | .menu 22 | font-size: $size-normal 23 | // Sizes 24 | &.is-small 25 | font-size: $size-small 26 | &.is-medium 27 | font-size: $size-medium 28 | &.is-large 29 | font-size: $size-large 30 | 31 | .menu-list 32 | line-height: $menu-list-line-height 33 | a 34 | border-radius: $menu-item-radius 35 | color: $menu-item-color 36 | display: block 37 | padding: $menu-list-link-padding 38 | &:hover 39 | background-color: $menu-item-hover-background-color 40 | color: $menu-item-hover-color 41 | // Modifiers 42 | &.is-active 43 | background-color: $menu-item-active-background-color 44 | color: $menu-item-active-color 45 | li 46 | ul 47 | +ltr-property("border", $menu-list-border-left, false) 48 | margin: $menu-nested-list-margin 49 | +ltr-property("padding", $menu-nested-list-padding-left, false) 50 | 51 | .menu-label 52 | color: $menu-label-color 53 | font-size: $menu-label-font-size 54 | letter-spacing: $menu-label-letter-spacing 55 | text-transform: uppercase 56 | &:not(:first-child) 57 | margin-top: $menu-label-spacing 58 | &:not(:last-child) 59 | margin-bottom: $menu-label-spacing 60 | -------------------------------------------------------------------------------- /rust/grpc-sample/src/bin/greeter_server.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | struct MyGreeter {} 3 | 4 | #[tonic::async_trait] 5 | impl grpc_sample::hello::greeter_server::Greeter for MyGreeter { 6 | async fn say_hello( 7 | &self, 8 | request: tonic::Request, 9 | ) -> Result, tonic::Status> { 10 | let reply = grpc_sample::hello::HelloReply { 11 | message: format!("Hello {}!", request.into_inner().name), 12 | }; 13 | Ok(tonic::Response::new(reply)) 14 | } 15 | 16 | async fn say_hello_slow( 17 | &self, 18 | request: tonic::Request, 19 | ) -> Result, tonic::Status> { 20 | std::thread::sleep(std::time::Duration::from_secs(10)); 21 | self.say_hello(request).await 22 | } 23 | } 24 | 25 | async fn shutdown_signal() { 26 | let mut int_stream = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::interrupt()) 27 | .expect("Failed to install SIGINT handler"); 28 | let mut term_stream = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()) 29 | .expect("Failed to install SIGTERM handler"); 30 | tokio::select! { 31 | _ = int_stream.recv() => { 32 | println!("Received SIGINT"); 33 | } 34 | _ = term_stream.recv() => { 35 | println!("Received SIGTERM"); 36 | } 37 | }; 38 | } 39 | 40 | #[tokio::main] 41 | async fn main() -> Result<(), Box> { 42 | let addr = "0.0.0.0:5000".parse().unwrap(); 43 | let greeter = MyGreeter::default(); 44 | println!("Listening on {} ...", addr); 45 | tonic::transport::Server::builder() 46 | .add_service(grpc_sample::hello::greeter_server::GreeterServer::new( 47 | greeter, 48 | )) 49 | .serve_with_shutdown(addr, shutdown_signal()) 50 | .await?; 51 | Ok(()) 52 | } 53 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/form/shared.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/controls" 2 | @import "../utilities/mixins" 3 | 4 | $form-colors: $colors !default 5 | 6 | $input-color: $text-strong !default 7 | $input-background-color: $scheme-main !default 8 | $input-border-color: $border !default 9 | $input-height: $control-height !default 10 | $input-shadow: inset 0 0.0625em 0.125em rgba($scheme-invert, 0.05) !default 11 | $input-placeholder-color: bulmaRgba($input-color, 0.3) !default 12 | 13 | $input-hover-color: $text-strong !default 14 | $input-hover-border-color: $border-hover !default 15 | 16 | $input-focus-color: $text-strong !default 17 | $input-focus-border-color: $link !default 18 | $input-focus-box-shadow-size: 0 0 0 0.125em !default 19 | $input-focus-box-shadow-color: bulmaRgba($link, 0.25) !default 20 | 21 | $input-disabled-color: $text-light !default 22 | $input-disabled-background-color: $background !default 23 | $input-disabled-border-color: $background !default 24 | $input-disabled-placeholder-color: bulmaRgba($input-disabled-color, 0.3) !default 25 | 26 | $input-arrow: $link !default 27 | 28 | $input-icon-color: $border !default 29 | $input-icon-active-color: $text !default 30 | 31 | $input-radius: $radius !default 32 | 33 | =input 34 | @extend %control 35 | background-color: $input-background-color 36 | border-color: $input-border-color 37 | border-radius: $input-radius 38 | color: $input-color 39 | +placeholder 40 | color: $input-placeholder-color 41 | &:hover, 42 | &.is-hovered 43 | border-color: $input-hover-border-color 44 | &:focus, 45 | &.is-focused, 46 | &:active, 47 | &.is-active 48 | border-color: $input-focus-border-color 49 | box-shadow: $input-focus-box-shadow-size $input-focus-box-shadow-color 50 | &[disabled], 51 | fieldset[disabled] & 52 | background-color: $input-disabled-background-color 53 | border-color: $input-disabled-border-color 54 | box-shadow: none 55 | color: $input-disabled-color 56 | +placeholder 57 | color: $input-disabled-placeholder-color 58 | 59 | %input 60 | +input 61 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/title.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $title-color: $text-strong !default 4 | $title-family: false !default 5 | $title-size: $size-3 !default 6 | $title-weight: $weight-semibold !default 7 | $title-line-height: 1.125 !default 8 | $title-strong-color: inherit !default 9 | $title-strong-weight: inherit !default 10 | $title-sub-size: 0.75em !default 11 | $title-sup-size: 0.75em !default 12 | 13 | $subtitle-color: $text !default 14 | $subtitle-family: false !default 15 | $subtitle-size: $size-5 !default 16 | $subtitle-weight: $weight-normal !default 17 | $subtitle-line-height: 1.25 !default 18 | $subtitle-strong-color: $text-strong !default 19 | $subtitle-strong-weight: $weight-semibold !default 20 | $subtitle-negative-margin: -1.25rem !default 21 | 22 | .title, 23 | .subtitle 24 | @extend %block 25 | word-break: break-word 26 | em, 27 | span 28 | font-weight: inherit 29 | sub 30 | font-size: $title-sub-size 31 | sup 32 | font-size: $title-sup-size 33 | .tag 34 | vertical-align: middle 35 | 36 | .title 37 | color: $title-color 38 | @if $title-family 39 | font-family: $title-family 40 | font-size: $title-size 41 | font-weight: $title-weight 42 | line-height: $title-line-height 43 | strong 44 | color: $title-strong-color 45 | font-weight: $title-strong-weight 46 | &:not(.is-spaced) + .subtitle 47 | margin-top: $subtitle-negative-margin 48 | // Sizes 49 | @each $size in $sizes 50 | $i: index($sizes, $size) 51 | &.is-#{$i} 52 | font-size: $size 53 | 54 | .subtitle 55 | color: $subtitle-color 56 | @if $subtitle-family 57 | font-family: $subtitle-family 58 | font-size: $subtitle-size 59 | font-weight: $subtitle-weight 60 | line-height: $subtitle-line-height 61 | strong 62 | color: $subtitle-strong-color 63 | font-weight: $subtitle-strong-weight 64 | &:not(.is-spaced) + .title 65 | margin-top: $subtitle-negative-margin 66 | // Sizes 67 | @each $size in $sizes 68 | $i: index($sizes, $size) 69 | &.is-#{$i} 70 | font-size: $size 71 | -------------------------------------------------------------------------------- /cxx/fc-find/fc-find.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) { 9 | if (argc < 2) { 10 | std::cerr << "Usage: " << argv[0] << " STRING" << std::endl; 11 | return 1; 12 | } 13 | 14 | FcInit(); 15 | 16 | std::vector targets; 17 | std::regex re("^U\\+([0-9a-fA-F]+)$", std::regex::extended); 18 | for (int i = 1; i < argc; ++i) { 19 | int len = std::strlen(argv[i]); 20 | std::cmatch m; 21 | if (std::regex_match(argv[i], m, re)) { 22 | targets.push_back(std::stoi(m[1], 0, 16)); 23 | } else { 24 | const FcChar8 *str = reinterpret_cast(argv[i]); 25 | FcChar32 c = 0; 26 | int n; 27 | while ((n = FcUtf8ToUcs4(str, &c, len)) != 0) { 28 | targets.push_back(c); 29 | str += n; 30 | len -= n; 31 | } 32 | } 33 | } 34 | 35 | static const FcChar8 name[] = { 0 }; 36 | std::unique_ptr p(FcNameParse(name), FcPatternDestroy); 37 | FcResult result; 38 | FcConfigSubstitute(NULL, p.get(), FcMatchPattern); 39 | FcDefaultSubstitute(p.get()); 40 | std::unique_ptr set( 41 | FcFontSort(NULL, p.get(), FcFalse, NULL, &result), FcFontSetDestroy); 42 | if (result != FcResultMatch) { 43 | std::cerr << "FcFontSort failed: result=" << result << std::endl; 44 | return 1; 45 | } 46 | 47 | for (int i = 0; i < set->nfont; ++i) { 48 | const FcPattern *font = set->fonts[i]; 49 | FcChar8 *fullname = nullptr; 50 | FcCharSet *charset = nullptr; 51 | 52 | if (FcPatternGetString(font, FC_FULLNAME, 0, &fullname) != FcResultMatch) { 53 | continue; 54 | } 55 | if (FcPatternGetCharSet(font, FC_CHARSET, 0, &charset) != FcResultMatch) { 56 | continue; 57 | } 58 | if (std::all_of(targets.begin(), targets.end(), [charset](FcChar32 c) { return FcCharSetHasChar(charset, c) == FcTrue; })) { 59 | std::cout << fullname << std::endl; 60 | } 61 | } 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/breadcrumb.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $breadcrumb-item-color: $link !default 4 | $breadcrumb-item-hover-color: $link-hover !default 5 | $breadcrumb-item-active-color: $text-strong !default 6 | 7 | $breadcrumb-item-padding-vertical: 0 !default 8 | $breadcrumb-item-padding-horizontal: 0.75em !default 9 | 10 | $breadcrumb-item-separator-color: $border-hover !default 11 | 12 | .breadcrumb 13 | @extend %block 14 | @extend %unselectable 15 | font-size: $size-normal 16 | white-space: nowrap 17 | a 18 | align-items: center 19 | color: $breadcrumb-item-color 20 | display: flex 21 | justify-content: center 22 | padding: $breadcrumb-item-padding-vertical $breadcrumb-item-padding-horizontal 23 | &:hover 24 | color: $breadcrumb-item-hover-color 25 | li 26 | align-items: center 27 | display: flex 28 | &:first-child a 29 | +ltr-property("padding", 0, false) 30 | &.is-active 31 | a 32 | color: $breadcrumb-item-active-color 33 | cursor: default 34 | pointer-events: none 35 | & + li::before 36 | color: $breadcrumb-item-separator-color 37 | content: "\0002f" 38 | ul, 39 | ol 40 | align-items: flex-start 41 | display: flex 42 | flex-wrap: wrap 43 | justify-content: flex-start 44 | .icon 45 | &:first-child 46 | +ltr-property("margin", 0.5em) 47 | &:last-child 48 | +ltr-property("margin", 0.5em, false) 49 | // Alignment 50 | &.is-centered 51 | ol, 52 | ul 53 | justify-content: center 54 | &.is-right 55 | ol, 56 | ul 57 | justify-content: flex-end 58 | // Sizes 59 | &.is-small 60 | font-size: $size-small 61 | &.is-medium 62 | font-size: $size-medium 63 | &.is-large 64 | font-size: $size-large 65 | // Styles 66 | &.has-arrow-separator 67 | li + li::before 68 | content: "\02192" 69 | &.has-bullet-separator 70 | li + li::before 71 | content: "\02022" 72 | &.has-dot-separator 73 | li + li::before 74 | content: "\000b7" 75 | &.has-succeeds-separator 76 | li + li::before 77 | content: "\0227B" 78 | -------------------------------------------------------------------------------- /gce/archlinux/startup-script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | # Prepare root volume 5 | sgdisk --new 1::+1m --typecode 1:ef02 --new 2 /dev/sdb 6 | mkfs.btrfs /dev/sdb2 7 | 8 | # Unarchive bootstrap tree 9 | curl -vL -o archlinux-bootstrap.tar.gz https://mirrors.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2017.05.01-x86_64.tar.gz 10 | tar xf archlinux-bootstrap.tar.gz 11 | 12 | # pacman-key requires haveged 13 | apt install -y haveged 14 | 15 | cat <<'EOS' > root.x86_64/build.sh 16 | #!/bin/bash 17 | set -ex 18 | 19 | mount /dev/sdb2 /mnt 20 | trap 'umount /mnt' EXIT 21 | 22 | pacman-key --init 23 | pacman-key --populate archlinux 24 | 25 | echo 'Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch' >> /etc/pacman.d/mirrorlist 26 | echo 'Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch' >> /etc/pacman.d/mirrorlist 27 | 28 | pacstrap /mnt base grub openssh sudo 29 | 30 | curl -vL -o /mnt/gce.pkg.tar.xz http://arch.wanko.cc/aur-eagletmt/os/x86_64/gce-compute-image-packages-20170523-2-any.pkg.tar.xz 31 | arch-chroot /mnt pacman --noconfirm -U /gce.pkg.tar.xz 32 | rm /mnt/gce.pkg.tar.xz 33 | 34 | echo -e '[Match]\nName=ens4\n\n[Network]\nDHCP=ipv4' > /mnt/etc/systemd/network/ens4.network 35 | ln -sfn /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf 36 | 37 | arch-chroot /mnt systemctl enable \ 38 | sshd.socket \ 39 | systemd-networkd.service \ 40 | systemd-resolved.service \ 41 | google-accounts-daemon.service \ 42 | google-clock-skew-daemon.service \ 43 | google-instance-setup.service \ 44 | google-ip-forwarding-daemon.service \ 45 | google-network-setup.service \ 46 | google-shutdown-scripts.service \ 47 | google-startup-scripts.service 48 | 49 | arch-chroot /mnt grub-install --target=i386-pc /dev/sdb 50 | # mkinitcpio returns non-zero code for btrfs, but it's OK. 51 | arch-chroot /mnt mkinitcpio -p linux || true 52 | # https://cloud.google.com/compute/docs/images/import-existing-image#configure_bootloader 53 | echo 'GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0,38400n8d"' >> /mnt/etc/default/grub 54 | arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg 55 | EOS 56 | chmod +x root.x86_64/build.sh 57 | 58 | root.x86_64/usr/bin/arch-chroot root.x86_64 /build.sh 59 | -------------------------------------------------------------------------------- /rust/tls-cert-expiration/src/main.rs: -------------------------------------------------------------------------------- 1 | use chrono::TimeZone as _; 2 | use clap::Parser as _; 3 | use std::convert::TryFrom as _; 4 | use std::io::Write as _; 5 | use x509_parser::prelude::FromDer as _; 6 | 7 | #[derive(Debug, clap::Parser)] 8 | struct Opt { 9 | #[clap(short, long, default_value = "443")] 10 | port: u16, 11 | host: String, 12 | } 13 | 14 | fn main() -> Result<(), Box> { 15 | let opt = Opt::parse(); 16 | 17 | let mut tcp_stream = std::net::TcpStream::connect((opt.host.as_str(), opt.port))?; 18 | let dns_name = rustls::pki_types::ServerName::try_from(opt.host.as_str())?.to_owned(); 19 | let mut root_certs = rustls::RootCertStore::empty(); 20 | for cert in rustls_native_certs::load_native_certs().expect("failed to load native certs") { 21 | root_certs.add(cert)?; 22 | } 23 | let config = rustls::ClientConfig::builder() 24 | .with_root_certificates(root_certs) 25 | .with_no_client_auth(); 26 | let mut client = rustls::ClientConnection::new(std::sync::Arc::new(config), dns_name)?; 27 | while client.wants_write() { 28 | client.write_tls(&mut tcp_stream)?; 29 | } 30 | tcp_stream.flush()?; 31 | while client.is_handshaking() && client.peer_certificates().is_none() { 32 | client.read_tls(&mut tcp_stream)?; 33 | client.process_new_packets()?; 34 | } 35 | let certs = client.peer_certificates().unwrap(); 36 | let (_, cert) = x509_parser::certificate::X509Certificate::from_der(certs[0].as_ref())?; 37 | println!("{}", opt.host); 38 | println!( 39 | " {}", 40 | chrono::Local 41 | .timestamp_opt(cert.validity().not_before.timestamp(), 0) 42 | .unwrap() 43 | .to_rfc3339() 44 | ); 45 | println!( 46 | " {}", 47 | chrono::Local 48 | .timestamp_opt(cert.validity().not_after.timestamp(), 0) 49 | .unwrap() 50 | .to_rfc3339() 51 | ); 52 | let duration = cert 53 | .validity() 54 | .time_to_expiration() 55 | .expect("time_to_expiration failed"); 56 | let rc = if duration <= std::time::Duration::from_secs(30 * 24 * 60 * 60) { 57 | 1 58 | } else { 59 | 0 60 | }; 61 | 62 | std::process::exit(rc); 63 | } 64 | -------------------------------------------------------------------------------- /cxx/libssh-exec/libssh-exec.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) { 5 | std::string host, cmd; 6 | if (argc >= 3) { 7 | host = argv[1]; 8 | cmd = argv[2]; 9 | } else { 10 | std::cerr << "Usage: " << argv[0] << " host cmd" << std::endl; 11 | return 1; 12 | } 13 | 14 | ssh::Session session; 15 | session.setOption(SSH_OPTIONS_LOG_VERBOSITY, SSH_LOG_INFO); 16 | session.setOption(SSH_OPTIONS_HOST, "barkhorn"); 17 | session.optionsParseConfig(NULL); 18 | // https://red.libssh.org/issues/220 19 | session.setOption(SSH_OPTIONS_ADD_IDENTITY, "%d/id_ed25519"); 20 | session.connect(); 21 | 22 | switch (session.isServerKnown()) { 23 | case SSH_SERVER_KNOWN_OK: 24 | break; 25 | case SSH_SERVER_KNOWN_CHANGED: 26 | std::cerr << "server_known: KNOWN_CHANGED!" << std::endl; 27 | return 1; 28 | case SSH_SERVER_FOUND_OTHER: 29 | std::cerr << "server_known: FOUND_OTHER!" << std::endl; 30 | return 1; 31 | case SSH_SERVER_NOT_KNOWN: 32 | std::cerr << "server_known: NOT_KNOWN" << std::endl; 33 | break; 34 | case SSH_SERVER_FILE_NOT_FOUND: 35 | std::cerr << "server_known: FILE_NOT_FOUND" << std::endl; 36 | break; 37 | default: 38 | std::cerr << "server_known: ERROR" << std::endl; 39 | return 1; 40 | } 41 | 42 | session.userauthNone(); 43 | const int available_auth = session.getAuthList(); 44 | if (available_auth & SSH_AUTH_METHOD_PUBLICKEY) { 45 | const int auth_rc = session.userauthPublickeyAuto(); 46 | if (auth_rc == SSH_AUTH_ERROR) { 47 | std::cerr << "publickey auth error" << std::endl; 48 | return 1; 49 | } else if (auth_rc == SSH_AUTH_SUCCESS) { 50 | std::cerr << "successfully authenticated" << std::endl; 51 | } else { 52 | std::cerr << "publickey auth failed: " << auth_rc << std::endl; 53 | return 1; 54 | } 55 | } 56 | 57 | ssh::Channel channel(session); 58 | channel.openSession(); 59 | channel.requestExec(cmd.c_str()); 60 | 61 | int nbytes; 62 | char buf[1024]; 63 | const int timeout_msec = 10 * 1000; 64 | while ((nbytes = channel.read(buf, sizeof(buf), timeout_msec)) > 0) { 65 | std::cout.write(buf, nbytes); 66 | } 67 | 68 | channel.sendEof(); 69 | channel.close(); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /rust/miam2tf/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod loader; 2 | pub mod mruby; 3 | mod mruby_c; 4 | pub mod printer; 5 | 6 | #[derive(Debug)] 7 | pub struct Miam { 8 | pub users: Vec, 9 | pub groups: Vec, 10 | pub roles: Vec, 11 | pub managed_policies: Vec, 12 | pub instance_profiles: Vec, 13 | } 14 | 15 | #[derive(Debug)] 16 | pub struct User { 17 | pub user_name: String, 18 | pub path: Option, 19 | pub policies: Vec, 20 | pub groups: Vec, 21 | pub attached_managed_policies: Vec, 22 | } 23 | 24 | #[derive(Debug)] 25 | pub struct PolicyDocument { 26 | pub name: String, 27 | pub version: Option, 28 | pub statements: Vec, 29 | } 30 | 31 | #[derive(Debug)] 32 | pub struct PolicyStatement { 33 | pub sid: Option, 34 | pub effect: String, 35 | pub actions: Vec, 36 | pub resources: Vec, 37 | pub conditions: Vec, 38 | 39 | pub principals: Vec, 40 | 41 | pub not_actions: Vec, 42 | pub not_resources: Vec, 43 | pub not_principals: Vec, 44 | } 45 | 46 | #[derive(Debug)] 47 | pub struct PolicyCondition { 48 | pub test: String, 49 | pub variable: String, 50 | pub values: Vec, 51 | } 52 | 53 | #[derive(Debug)] 54 | pub struct PolicyPrincipal { 55 | pub typ: String, 56 | pub identifiers: Vec, 57 | } 58 | 59 | #[derive(Debug)] 60 | pub struct Group { 61 | pub name: String, 62 | pub path: Option, 63 | pub policies: Vec, 64 | pub attached_managed_policies: Vec, 65 | } 66 | 67 | #[derive(Debug)] 68 | pub struct Role { 69 | pub name: String, 70 | pub path: Option, 71 | pub assume_role_policy_document: Option, 72 | pub policies: Vec, 73 | pub attached_managed_policies: Vec, 74 | pub instance_profiles: Vec, 75 | pub max_session_duration: Option, 76 | } 77 | 78 | #[derive(Debug)] 79 | pub struct ManagedPolicy { 80 | pub name: String, 81 | pub path: Option, 82 | pub policy_document: PolicyDocument, 83 | } 84 | 85 | #[derive(Debug)] 86 | pub struct InstanceProfile { 87 | pub name: String, 88 | pub path: Option, 89 | } 90 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/form/select.sass: -------------------------------------------------------------------------------- 1 | $select-colors: $form-colors !default 2 | 3 | .select 4 | display: inline-block 5 | max-width: 100% 6 | position: relative 7 | vertical-align: top 8 | &:not(.is-multiple) 9 | height: $input-height 10 | &:not(.is-multiple):not(.is-loading) 11 | &::after 12 | @extend %arrow 13 | border-color: $input-arrow 14 | +ltr-position(1.125em) 15 | z-index: 4 16 | &.is-rounded 17 | select 18 | border-radius: $radius-rounded 19 | +ltr-property("padding", 1em, false) 20 | select 21 | @extend %input 22 | cursor: pointer 23 | display: block 24 | font-size: 1em 25 | max-width: 100% 26 | outline: none 27 | &::-ms-expand 28 | display: none 29 | &[disabled]:hover, 30 | fieldset[disabled] &:hover 31 | border-color: $input-disabled-border-color 32 | &:not([multiple]) 33 | +ltr-property("padding", 2.5em) 34 | &[multiple] 35 | height: auto 36 | padding: 0 37 | option 38 | padding: 0.5em 1em 39 | // States 40 | &:not(.is-multiple):not(.is-loading):hover 41 | &::after 42 | border-color: $input-hover-color 43 | // Colors 44 | @each $name, $pair in $select-colors 45 | $color: nth($pair, 1) 46 | &.is-#{$name} 47 | &:not(:hover)::after 48 | border-color: $color 49 | select 50 | border-color: $color 51 | &:hover, 52 | &.is-hovered 53 | border-color: bulmaDarken($color, 5%) 54 | &:focus, 55 | &.is-focused, 56 | &:active, 57 | &.is-active 58 | box-shadow: $input-focus-box-shadow-size bulmaRgba($color, 0.25) 59 | // Sizes 60 | &.is-small 61 | +control-small 62 | &.is-medium 63 | +control-medium 64 | &.is-large 65 | +control-large 66 | // Modifiers 67 | &.is-disabled 68 | &::after 69 | border-color: $input-disabled-color 70 | &.is-fullwidth 71 | width: 100% 72 | select 73 | width: 100% 74 | &.is-loading 75 | &::after 76 | @extend %loader 77 | margin-top: 0 78 | position: absolute 79 | +ltr-position(0.625em) 80 | top: 0.625em 81 | transform: none 82 | &.is-small:after 83 | font-size: $size-small 84 | &.is-medium:after 85 | font-size: $size-medium 86 | &.is-large:after 87 | font-size: $size-large 88 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/elements/progress.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $progress-bar-background-color: $border-light !default 4 | $progress-value-background-color: $text !default 5 | $progress-border-radius: $radius-rounded !default 6 | 7 | $progress-indeterminate-duration: 1.5s !default 8 | 9 | $progress-colors: $colors !default 10 | 11 | .progress 12 | @extend %block 13 | -moz-appearance: none 14 | -webkit-appearance: none 15 | border: none 16 | border-radius: $progress-border-radius 17 | display: block 18 | height: $size-normal 19 | overflow: hidden 20 | padding: 0 21 | width: 100% 22 | &::-webkit-progress-bar 23 | background-color: $progress-bar-background-color 24 | &::-webkit-progress-value 25 | background-color: $progress-value-background-color 26 | &::-moz-progress-bar 27 | background-color: $progress-value-background-color 28 | &::-ms-fill 29 | background-color: $progress-value-background-color 30 | border: none 31 | // Colors 32 | @each $name, $pair in $progress-colors 33 | $color: nth($pair, 1) 34 | &.is-#{$name} 35 | &::-webkit-progress-value 36 | background-color: $color 37 | &::-moz-progress-bar 38 | background-color: $color 39 | &::-ms-fill 40 | background-color: $color 41 | &:indeterminate 42 | background-image: linear-gradient(to right, $color 30%, $progress-bar-background-color 30%) 43 | 44 | &:indeterminate 45 | animation-duration: $progress-indeterminate-duration 46 | animation-iteration-count: infinite 47 | animation-name: moveIndeterminate 48 | animation-timing-function: linear 49 | background-color: $progress-bar-background-color 50 | background-image: linear-gradient(to right, $text 30%, $progress-bar-background-color 30%) 51 | background-position: top left 52 | background-repeat: no-repeat 53 | background-size: 150% 150% 54 | &::-webkit-progress-bar 55 | background-color: transparent 56 | &::-moz-progress-bar 57 | background-color: transparent 58 | &::-ms-fill 59 | animation-name: none 60 | 61 | // Sizes 62 | &.is-small 63 | height: $size-small 64 | &.is-medium 65 | height: $size-medium 66 | &.is-large 67 | height: $size-large 68 | 69 | @keyframes moveIndeterminate 70 | from 71 | background-position: 200% 0 72 | to 73 | background-position: -200% 0 74 | -------------------------------------------------------------------------------- /rust/s3-prefix-get/src/main.rs: -------------------------------------------------------------------------------- 1 | use clap::Parser as _; 2 | use futures::StreamExt as _; 3 | use tokio::io::AsyncWriteExt as _; 4 | 5 | #[derive(clap::Parser)] 6 | struct Opt { 7 | #[clap(short, long)] 8 | bucket: String, 9 | #[clap(short, long)] 10 | prefix: String, 11 | #[clap(short, long)] 12 | output_dir: std::path::PathBuf, 13 | } 14 | 15 | #[tokio::main] 16 | async fn main() -> Result<(), Box> { 17 | let opt = Opt::parse(); 18 | 19 | let shared_config = aws_config::load_defaults(aws_config::BehaviorVersion::v2025_01_17()).await; 20 | let s3_client = aws_sdk_s3::Client::new(&shared_config); 21 | 22 | let mut continuation_token = None; 23 | loop { 24 | let resp = s3_client 25 | .list_objects_v2() 26 | .bucket(&opt.bucket) 27 | .prefix(&opt.prefix) 28 | .set_continuation_token(continuation_token) 29 | .send() 30 | .await?; 31 | continuation_token = resp.next_continuation_token; 32 | 33 | if let Some(contents) = resp.contents { 34 | let mut futures = Vec::new(); 35 | for content in contents { 36 | if let Some(key) = content.key { 37 | let path = opt.output_dir.join(&key); 38 | futures.push(download(&s3_client, &opt.bucket, key, path)); 39 | } 40 | } 41 | let mut futures_unordered = futures::stream::iter(futures).buffer_unordered(16); 42 | while futures_unordered.next().await.transpose()?.is_some() {} 43 | } 44 | 45 | if continuation_token.is_none() { 46 | break; 47 | } 48 | } 49 | 50 | Ok(()) 51 | } 52 | 53 | async fn download( 54 | s3_client: &aws_sdk_s3::Client, 55 | bucket: &str, 56 | key: String, 57 | path: std::path::PathBuf, 58 | ) -> Result<(), Box> { 59 | let resp = s3_client 60 | .get_object() 61 | .bucket(bucket) 62 | .key(&key) 63 | .send() 64 | .await?; 65 | if let Some(parent) = path.parent() { 66 | tokio::fs::create_dir_all(parent).await?; 67 | } 68 | let file = tokio::fs::File::create(&path).await?; 69 | let mut writer = tokio::io::BufWriter::new(file); 70 | let mut reader = resp.body.into_async_read(); 71 | tokio::io::copy(&mut reader, &mut writer).await?; 72 | writer.shutdown().await?; 73 | println!("s3://{}/{} -> {}", bucket, key, path.display()); 74 | Ok(()) 75 | } 76 | -------------------------------------------------------------------------------- /rust/dockerhub-login/src/browser.rs: -------------------------------------------------------------------------------- 1 | use tokio::io::AsyncBufReadExt as _; 2 | 3 | pub async fn launch() -> anyhow::Result<( 4 | tokio::process::Child, 5 | tokio_tungstenite::WebSocketStream>, 6 | )> { 7 | let user_data_dir = tempfile::TempDir::new()?; 8 | const DEFAULT_ARGS: &[&str] = &[ 9 | "--allow-pre-commit-input", 10 | "--disable-background-networking", 11 | "--enable-features=NetworkServiceInProcess2", 12 | "--disable-background-timer-throttling", 13 | "--disable-backgrounding-occluded-windows", 14 | "--disable-breakpad", 15 | "--disable-client-side-phishing-detection", 16 | "--disable-component-extensions-with-background-pages", 17 | "--disable-default-apps", 18 | "--disable-dev-shm-usage", 19 | "--disable-extensions", 20 | "--disable-features=Translate,BackForwardCache,AcceptCHFrame,AvoidUnnecessaryBeforeUnloadCheckSync", 21 | "--disable-hang-monitor", 22 | "--disable-ipc-flooding-protection", 23 | "--disable-popup-blocking", 24 | "--disable-prompt-on-repost", 25 | "--disable-renderer-backgrounding", 26 | "--disable-sync", 27 | "--force-color-profile=srgb", 28 | "--metrics-recording-only", 29 | "--no-first-run", 30 | "--enable-automation", 31 | "--password-store=basic", 32 | "--use-mock-keychain", 33 | "--enable-blink-features=IdleDetection", 34 | "--export-tagged-pdf", 35 | ]; 36 | const HEADLESS_ARGS: &[&str] = &["--headless", "--hide-scrollbars", "--mute-audio"]; 37 | let mut child = tokio::process::Command::new("chromium") 38 | .stderr(std::process::Stdio::piped()) 39 | .args(DEFAULT_ARGS) 40 | .args(HEADLESS_ARGS) 41 | .arg("--remote-debugging-port=0") 42 | .arg(format!( 43 | "--user-data-dir={}", 44 | user_data_dir.path().display() 45 | )) 46 | .spawn()?; 47 | let stderr = child 48 | .stderr 49 | .take() 50 | .expect("child process doesn't have stderr"); 51 | let mut reader = tokio::io::BufReader::new(stderr).lines(); 52 | while let Some(line) = reader.next_line().await? { 53 | const DEVTOOLS_PREFIX: &str = "DevTools listening on "; 54 | if let Some(endpoint) = line.strip_prefix(DEVTOOLS_PREFIX) { 55 | let (ws, _) = tokio_tungstenite::connect_async(endpoint).await?; 56 | return Ok((child, ws)); 57 | } 58 | } 59 | anyhow::bail!("failed to find DevTools endpoint"); 60 | } 61 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/dropdown.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $dropdown-menu-min-width: 12rem !default 4 | 5 | $dropdown-content-background-color: $scheme-main !default 6 | $dropdown-content-arrow: $link !default 7 | $dropdown-content-offset: 4px !default 8 | $dropdown-content-padding-bottom: 0.5rem !default 9 | $dropdown-content-padding-top: 0.5rem !default 10 | $dropdown-content-radius: $radius !default 11 | $dropdown-content-shadow: $shadow !default 12 | $dropdown-content-z: 20 !default 13 | 14 | $dropdown-item-color: $text !default 15 | $dropdown-item-hover-color: $scheme-invert !default 16 | $dropdown-item-hover-background-color: $background !default 17 | $dropdown-item-active-color: $link-invert !default 18 | $dropdown-item-active-background-color: $link !default 19 | 20 | $dropdown-divider-background-color: $border-light !default 21 | 22 | .dropdown 23 | display: inline-flex 24 | position: relative 25 | vertical-align: top 26 | &.is-active, 27 | &.is-hoverable:hover 28 | .dropdown-menu 29 | display: block 30 | &.is-right 31 | .dropdown-menu 32 | left: auto 33 | right: 0 34 | &.is-up 35 | .dropdown-menu 36 | bottom: 100% 37 | padding-bottom: $dropdown-content-offset 38 | padding-top: initial 39 | top: auto 40 | 41 | .dropdown-menu 42 | display: none 43 | +ltr-position(0, false) 44 | min-width: $dropdown-menu-min-width 45 | padding-top: $dropdown-content-offset 46 | position: absolute 47 | top: 100% 48 | z-index: $dropdown-content-z 49 | 50 | .dropdown-content 51 | background-color: $dropdown-content-background-color 52 | border-radius: $dropdown-content-radius 53 | box-shadow: $dropdown-content-shadow 54 | padding-bottom: $dropdown-content-padding-bottom 55 | padding-top: $dropdown-content-padding-top 56 | 57 | .dropdown-item 58 | color: $dropdown-item-color 59 | display: block 60 | font-size: 0.875rem 61 | line-height: 1.5 62 | padding: 0.375rem 1rem 63 | position: relative 64 | 65 | a.dropdown-item, 66 | button.dropdown-item 67 | +ltr-property("padding", 3rem) 68 | text-align: inherit 69 | white-space: nowrap 70 | width: 100% 71 | &:hover 72 | background-color: $dropdown-item-hover-background-color 73 | color: $dropdown-item-hover-color 74 | &.is-active 75 | background-color: $dropdown-item-active-background-color 76 | color: $dropdown-item-active-color 77 | 78 | .dropdown-divider 79 | background-color: $dropdown-divider-background-color 80 | border: none 81 | display: block 82 | height: 1px 83 | margin: 0.5rem 0 84 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/utilities/initial-variables.sass: -------------------------------------------------------------------------------- 1 | // Colors 2 | 3 | $black: hsl(0, 0%, 4%) !default 4 | $black-bis: hsl(0, 0%, 7%) !default 5 | $black-ter: hsl(0, 0%, 14%) !default 6 | 7 | $grey-darker: hsl(0, 0%, 21%) !default 8 | $grey-dark: hsl(0, 0%, 29%) !default 9 | $grey: hsl(0, 0%, 48%) !default 10 | $grey-light: hsl(0, 0%, 71%) !default 11 | $grey-lighter: hsl(0, 0%, 86%) !default 12 | $grey-lightest: hsl(0, 0%, 93%) !default 13 | 14 | $white-ter: hsl(0, 0%, 96%) !default 15 | $white-bis: hsl(0, 0%, 98%) !default 16 | $white: hsl(0, 0%, 100%) !default 17 | 18 | $orange: hsl(14, 100%, 53%) !default 19 | $yellow: hsl(44, 100%, 77%) !default 20 | $green: hsl(153, 53%, 53%) !default 21 | $turquoise: hsl(171, 100%, 41%) !default 22 | $cyan: hsl(207, 61%, 53%) !default 23 | $blue: hsl(229, 53%, 53%) !default 24 | $purple: hsl(271, 100%, 71%) !default 25 | $red: hsl(348, 86%, 61%) !default 26 | 27 | // Typography 28 | 29 | $family-sans-serif: BlinkMacSystemFont, -apple-system, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif !default 30 | $family-monospace: monospace !default 31 | $render-mode: optimizeLegibility !default 32 | 33 | $size-1: 3rem !default 34 | $size-2: 2.5rem !default 35 | $size-3: 2rem !default 36 | $size-4: 1.5rem !default 37 | $size-5: 1.25rem !default 38 | $size-6: 1rem !default 39 | $size-7: 0.75rem !default 40 | 41 | $weight-light: 300 !default 42 | $weight-normal: 400 !default 43 | $weight-medium: 500 !default 44 | $weight-semibold: 600 !default 45 | $weight-bold: 700 !default 46 | 47 | // Spacing 48 | 49 | $block-spacing: 1.5rem !default 50 | 51 | // Responsiveness 52 | 53 | // The container horizontal gap, which acts as the offset for breakpoints 54 | $gap: 32px !default 55 | // 960, 1152, and 1344 have been chosen because they are divisible by both 12 and 16 56 | $tablet: 769px !default 57 | // 960px container + 4rem 58 | $desktop: 960px + (2 * $gap) !default 59 | // 1152px container + 4rem 60 | $widescreen: 1152px + (2 * $gap) !default 61 | $widescreen-enabled: true !default 62 | // 1344px container + 4rem 63 | $fullhd: 1344px + (2 * $gap) !default 64 | $fullhd-enabled: true !default 65 | 66 | // Miscellaneous 67 | 68 | $easing: ease-out !default 69 | $radius-small: 2px !default 70 | $radius: 4px !default 71 | $radius-large: 6px !default 72 | $radius-rounded: 9999px !default 73 | $speed: 86ms !default 74 | 75 | // Flags 76 | 77 | $variable-columns: true !default 78 | $rtl: false !default 79 | -------------------------------------------------------------------------------- /ruby/mickey24_bot.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # coding: utf-8 3 | 4 | class Brainfuck 5 | attr_accessor :mem, :ptr, :code, :inits, :output 6 | 7 | def initialize 8 | @inits = [] 9 | @mem = [] 10 | @ptr = 0 11 | @code = '' 12 | @output = [] 13 | end 14 | 15 | def add_tail(c) 16 | r = Marshal.load(Marshal.dump(self)) 17 | r.ptr = @mem.each_with_index.min_by do |m, i| 18 | [(m-c+256) % 256, (c-m+256) % 256].min + (i-@ptr).abs 19 | end[1] 20 | 21 | if r.ptr < @ptr 22 | r.code += '<' * (@ptr-r.ptr) 23 | elsif r.ptr > @ptr 24 | r.code += '>' * (r.ptr-@ptr) 25 | end 26 | 27 | if (r.mem[r.ptr]-c+256)%256 < (c-r.mem[r.ptr]+256)%256 28 | r.code += '-' * ((r.mem[r.ptr]-c+256)%256) 29 | elsif (r.mem[r.ptr]-c+256)%256 > (c-r.mem[r.ptr]+256)%256 30 | r.code += '+' * (c - r.mem[r.ptr]) 31 | end 32 | r.code += '.' 33 | r.mem[r.ptr] = c 34 | r.output += [c] 35 | r 36 | end 37 | 38 | def add_head(c) 39 | r = Brainfuck.new 40 | n = 256.step(0, -6).min_by do |i| 41 | j = (256-i) / 6 42 | v = j/4 43 | if j%4 != 0 44 | if j%4 == 3 45 | v += 2 + 1 + 1 46 | else 47 | v += 2 + j%4 48 | end 49 | end 50 | (i-c).abs + v 51 | end 52 | r.inits = @inits + [n] 53 | r.rebuild_prelude 54 | @output.each do |d| 55 | r = r.add_tail(d) 56 | end 57 | r.add_tail(c) 58 | end 59 | 60 | def rebuild_prelude 61 | @mem = Marshal.load(Marshal.dump(@inits)) 62 | @code = '++++++[>++++[' 63 | six = [] 64 | @inits.each do |m| 65 | t = 256-m 66 | @code += '>' + '-' * (t/24) 67 | six += [(t % 24)/6] 68 | end 69 | while six.last == 0 70 | six.pop 71 | end 72 | @code += '<' * @inits.size 73 | @code += '-]' 74 | six.each do |i| 75 | @code += '>' + '-'*i 76 | end 77 | @code += '<' * six.size 78 | @code += '<-]>>' 79 | self 80 | end 81 | end 82 | 83 | def mickey24_bot(s, limit = 140) 84 | target = s.unpack('C*') 85 | pq = [Brainfuck.new.add_head(target.shift)] 86 | target.each do |c| 87 | pq = pq.map do |bf| 88 | [bf.add_head(c), bf.add_tail(c)].select do |b| 89 | b.code.size + '@mickey24_bot '.size <= limit 90 | end 91 | end.flatten.sort_by do |b| 92 | b.code.size 93 | end 94 | end 95 | pq[0] 96 | end 97 | 98 | r = mickey24_bot(ARGF.read.chomp) 99 | if r 100 | s = "@mickey24_bot #{r.code}" 101 | puts s.size 102 | puts s 103 | else 104 | puts 'fail!' 105 | end 106 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-server/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, juniper::GraphQLObject, sqlx::FromRow)] 2 | #[graphql()] 3 | struct User { 4 | id: i32, 5 | name: String, 6 | } 7 | 8 | #[derive(Clone)] 9 | struct Context { 10 | pool: sqlx::PgPool, 11 | } 12 | impl juniper::Context for Context {} 13 | 14 | struct Query; 15 | #[juniper::graphql_object(context = Context)] 16 | impl Query { 17 | async fn user(context: &Context, id: i32) -> juniper::FieldResult> { 18 | let user: Option = sqlx::query_as("select id, name from users where id = $1") 19 | .bind(id) 20 | .fetch_optional(&context.pool) 21 | .await?; 22 | Ok(user) 23 | } 24 | } 25 | 26 | type ScalarValue = juniper::DefaultScalarValue; 27 | type Schema = juniper::RootNode< 28 | 'static, 29 | Query, 30 | juniper::EmptyMutation, 31 | juniper::EmptySubscription, 32 | ScalarValue, 33 | >; 34 | 35 | #[tokio::main] 36 | async fn main() -> Result<(), anyhow::Error> { 37 | if std::env::var("RUST_LOG").is_err() { 38 | std::env::set_var("RUST_LOG", "info,tower_http::trace=debug"); 39 | } 40 | tracing_subscriber::fmt::init(); 41 | 42 | let pool = sqlx::PgPool::connect_with( 43 | sqlx::postgres::PgConnectOptions::new() 44 | .host("localhost") 45 | .port(5432) 46 | .database("graphql_sample") 47 | .username("graphql_sample") 48 | .password("himitsu"), 49 | ) 50 | .await?; 51 | let schema = std::sync::Arc::new(Schema::new( 52 | Query, 53 | juniper::EmptyMutation::new(), 54 | juniper::EmptySubscription::new(), 55 | )); 56 | let context = std::sync::Arc::new(Context { pool }); 57 | 58 | let app = axum::Router::new() 59 | .route( 60 | "/graphiql", 61 | axum::routing::get(juniper_axum::graphiql("/graphql", None)), 62 | ) 63 | .route("/graphql", axum::routing::post(graphql_handler)) 64 | .layer(tower::ServiceBuilder::new().layer(tower_http::trace::TraceLayer::new_for_http())) 65 | .layer(axum::Extension(context)) 66 | .layer(axum::Extension(schema)); 67 | 68 | let listener = if let Some(l) = listenfd::ListenFd::from_env().take_tcp_listener(0)? { 69 | tokio::net::TcpListener::from_std(l)? 70 | } else { 71 | tokio::net::TcpListener::bind("127.0.0.1:3000").await? 72 | }; 73 | axum::serve(listener, app).await?; 74 | Ok(()) 75 | } 76 | 77 | async fn graphql_handler( 78 | schema: axum::Extension>, 79 | context: axum::Extension>, 80 | req: juniper_axum::extract::JuniperRequest, 81 | ) -> juniper_axum::response::JuniperResponse { 82 | juniper_axum::response::JuniperResponse(req.0.execute(&schema, &context).await) 83 | } 84 | -------------------------------------------------------------------------------- /rust/gyazo/infra/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "gyazo" { 2 | bucket = "gyazo.wanko.cc" 3 | website { 4 | index_document = "index.html" 5 | } 6 | cors_rule { 7 | allowed_headers = ["*"] 8 | allowed_methods = ["GET"] 9 | allowed_origins = ["*"] 10 | max_age_seconds = 3000 11 | } 12 | } 13 | 14 | resource "aws_acm_certificate" "gyazo" { 15 | provider = aws.use1 16 | domain_name = "gyazo.wanko.cc" 17 | validation_method = "DNS" 18 | } 19 | 20 | data "aws_route53_zone" "wanko-cc" { 21 | name = "wanko.cc." 22 | private_zone = false 23 | } 24 | 25 | resource "aws_route53_record" "gyazo-validation" { 26 | zone_id = data.aws_route53_zone.wanko-cc.id 27 | name = aws_acm_certificate.gyazo.domain_validation_options[0].resource_record_name 28 | type = aws_acm_certificate.gyazo.domain_validation_options[0].resource_record_type 29 | records = [aws_acm_certificate.gyazo.domain_validation_options[0].resource_record_value] 30 | ttl = 60 31 | } 32 | 33 | resource "aws_acm_certificate_validation" "gyazo" { 34 | provider = aws.use1 35 | certificate_arn = aws_acm_certificate.gyazo.arn 36 | validation_record_fqdns = [aws_route53_record.gyazo-validation.fqdn] 37 | } 38 | 39 | locals { 40 | s3_origin_id = "s3-gyazo.wanko.cc" 41 | } 42 | 43 | resource "aws_cloudfront_distribution" "gyazo" { 44 | origin { 45 | domain_name = aws_s3_bucket.gyazo.bucket_domain_name 46 | origin_id = local.s3_origin_id 47 | } 48 | 49 | enabled = true 50 | is_ipv6_enabled = true 51 | aliases = [aws_acm_certificate.gyazo.domain_name] 52 | default_cache_behavior { 53 | allowed_methods = ["GET", "HEAD"] 54 | cached_methods = ["GET", "HEAD"] 55 | target_origin_id = local.s3_origin_id 56 | forwarded_values { 57 | query_string = false 58 | cookies { 59 | forward = "none" 60 | } 61 | } 62 | viewer_protocol_policy = "redirect-to-https" 63 | min_ttl = 0 64 | default_ttl = 24 * 60 * 60 65 | max_ttl = 365 * 24 * 60 * 60 66 | } 67 | 68 | price_class = "PriceClass_All" 69 | restrictions { 70 | geo_restriction { 71 | restriction_type = "none" 72 | } 73 | } 74 | viewer_certificate { 75 | acm_certificate_arn = aws_acm_certificate.gyazo.arn 76 | ssl_support_method = "sni-only" 77 | minimum_protocol_version = "TLSv1.1_2016" 78 | } 79 | } 80 | 81 | resource "aws_route53_record" "gyazo" { 82 | for_each = toset(["A", "AAAA"]) 83 | 84 | zone_id = data.aws_route53_zone.wanko-cc.id 85 | name = "gyazo.wanko.cc" 86 | type = each.value 87 | alias { 88 | name = aws_cloudfront_distribution.gyazo.domain_name 89 | zone_id = aws_cloudfront_distribution.gyazo.hosted_zone_id 90 | evaluate_target_health = false 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /cxx/pdf-unlock/pdf-unlock.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static void read_password(char *buf, size_t n) 10 | { 11 | struct termios save, t; 12 | 13 | fputs("Password: ", stdout); 14 | fflush(stdout); 15 | 16 | tcgetattr(STDIN_FILENO, &save); 17 | t = save; 18 | t.c_lflag &= ~ECHO; 19 | tcsetattr(STDIN_FILENO, TCSANOW, &t); 20 | fgets(buf, n, stdin); 21 | tcsetattr(STDIN_FILENO, TCSANOW, &save); 22 | 23 | putchar('\n'); 24 | fflush(stdout); 25 | 26 | const size_t len = strlen(buf); 27 | if (buf[len-1] == '\n') { 28 | buf[len-1] = '\0'; 29 | } 30 | } 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | if (argc != 3) { 35 | g_print("Usage: %s in-locked.pdf out-unlocked.pdf\n", argv[0]); 36 | return 1; 37 | } 38 | 39 | const char *inpath = argv[1]; 40 | const char *outpath = argv[2]; 41 | 42 | const std::unique_ptr infile( 43 | g_file_new_for_path(inpath), g_object_unref); 44 | GError *err = NULL; 45 | std::unique_ptr doc(poppler_document_new_from_gfile(infile.get(), argc == 3 ? NULL : argv[3], NULL, &err), g_object_unref); 46 | if (!doc && err->code == POPPLER_ERROR_ENCRYPTED) { 47 | g_clear_error(&err); 48 | 49 | char password[1024]; 50 | const gchar *env_password = g_getenv("PDF_UNLOCK_PASSWORD"); 51 | if (env_password != NULL) { 52 | strncpy(password, env_password, sizeof(password)-1); 53 | } else { 54 | read_password(password, sizeof(password)); 55 | } 56 | doc.reset( 57 | poppler_document_new_from_gfile(infile.get(), password, NULL, &err)); 58 | } 59 | if (!doc) { 60 | g_print("%s(%d): %s\n", g_quark_to_string(err->domain), err->code, err->message); 61 | g_clear_error(&err); 62 | return 2; 63 | } 64 | 65 | std::unique_ptr surface(cairo_pdf_surface_create(outpath, 0, 0), cairo_surface_destroy); 66 | if (cairo_surface_status(surface.get()) != CAIRO_STATUS_SUCCESS) { 67 | g_print("Cannot create PDF surface: %s\n", outpath); 68 | return 3; 69 | } 70 | std::unique_ptr cairo(cairo_create(surface.get()), cairo_destroy); 71 | if (cairo_status(cairo.get()) != CAIRO_STATUS_SUCCESS) { 72 | g_print("Cannot create cairo context\n"); 73 | return 3; 74 | } 75 | 76 | const int npages = poppler_document_get_n_pages(doc.get()); 77 | for (int i = 0; i < npages; i++) { 78 | PopplerPage *page = poppler_document_get_page(doc.get(), i); 79 | double width, height; 80 | poppler_page_get_size(page, &width, &height); 81 | cairo_pdf_surface_set_size(surface.get(), width, height); 82 | poppler_page_render_for_printing(page, cairo.get()); 83 | cairo_show_page(cairo.get()); 84 | g_object_unref(page); 85 | } 86 | cairo_save(cairo.get()); 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/typography.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | =typography-size($target:'') 4 | @each $size in $sizes 5 | $i: index($sizes, $size) 6 | .is-size-#{$i}#{if($target == '', '', '-' + $target)} 7 | font-size: $size !important 8 | 9 | +typography-size() 10 | 11 | +mobile 12 | +typography-size('mobile') 13 | 14 | +tablet 15 | +typography-size('tablet') 16 | 17 | +touch 18 | +typography-size('touch') 19 | 20 | +desktop 21 | +typography-size('desktop') 22 | 23 | +widescreen 24 | +typography-size('widescreen') 25 | 26 | +fullhd 27 | +typography-size('fullhd') 28 | 29 | $alignments: ('centered': 'center', 'justified': 'justify', 'left': 'left', 'right': 'right') 30 | 31 | @each $alignment, $text-align in $alignments 32 | .has-text-#{$alignment} 33 | text-align: #{$text-align} !important 34 | 35 | @each $alignment, $text-align in $alignments 36 | +mobile 37 | .has-text-#{$alignment}-mobile 38 | text-align: #{$text-align} !important 39 | +tablet 40 | .has-text-#{$alignment}-tablet 41 | text-align: #{$text-align} !important 42 | +tablet-only 43 | .has-text-#{$alignment}-tablet-only 44 | text-align: #{$text-align} !important 45 | +touch 46 | .has-text-#{$alignment}-touch 47 | text-align: #{$text-align} !important 48 | +desktop 49 | .has-text-#{$alignment}-desktop 50 | text-align: #{$text-align} !important 51 | +desktop-only 52 | .has-text-#{$alignment}-desktop-only 53 | text-align: #{$text-align} !important 54 | +widescreen 55 | .has-text-#{$alignment}-widescreen 56 | text-align: #{$text-align} !important 57 | +widescreen-only 58 | .has-text-#{$alignment}-widescreen-only 59 | text-align: #{$text-align} !important 60 | +fullhd 61 | .has-text-#{$alignment}-fullhd 62 | text-align: #{$text-align} !important 63 | 64 | .is-capitalized 65 | text-transform: capitalize !important 66 | 67 | .is-lowercase 68 | text-transform: lowercase !important 69 | 70 | .is-uppercase 71 | text-transform: uppercase !important 72 | 73 | .is-italic 74 | font-style: italic !important 75 | 76 | .is-underlined 77 | text-decoration: underline !important 78 | 79 | .has-text-weight-light 80 | font-weight: $weight-light !important 81 | .has-text-weight-normal 82 | font-weight: $weight-normal !important 83 | .has-text-weight-medium 84 | font-weight: $weight-medium !important 85 | .has-text-weight-semibold 86 | font-weight: $weight-semibold !important 87 | .has-text-weight-bold 88 | font-weight: $weight-bold !important 89 | 90 | .is-family-primary 91 | font-family: $family-primary !important 92 | 93 | .is-family-secondary 94 | font-family: $family-secondary !important 95 | 96 | .is-family-sans-serif 97 | font-family: $family-sans-serif !important 98 | 99 | .is-family-monospace 100 | font-family: $family-monospace !important 101 | 102 | .is-family-code 103 | font-family: $family-code !important 104 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/card.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $card-color: $text !default 4 | $card-background-color: $scheme-main !default 5 | $card-shadow: $shadow !default 6 | $card-radius: 0.25rem !default 7 | 8 | $card-header-background-color: transparent !default 9 | $card-header-color: $text-strong !default 10 | $card-header-padding: 0.75rem 1rem !default 11 | $card-header-shadow: 0 0.125em 0.25em rgba($scheme-invert, 0.1) !default 12 | $card-header-weight: $weight-bold !default 13 | 14 | $card-content-background-color: transparent !default 15 | $card-content-padding: 1.5rem !default 16 | 17 | $card-footer-background-color: transparent !default 18 | $card-footer-border-top: 1px solid $border-light !default 19 | $card-footer-padding: 0.75rem !default 20 | 21 | $card-media-margin: $block-spacing !default 22 | 23 | .card 24 | background-color: $card-background-color 25 | border-radius: $card-radius 26 | box-shadow: $card-shadow 27 | color: $card-color 28 | max-width: 100% 29 | position: relative 30 | 31 | %card-item 32 | &:first-child 33 | border-top-left-radius: $card-radius 34 | border-top-right-radius: $card-radius 35 | &:last-child 36 | border-bottom-left-radius: $card-radius 37 | border-bottom-right-radius: $card-radius 38 | 39 | .card-header 40 | @extend %card-item 41 | background-color: $card-header-background-color 42 | align-items: stretch 43 | box-shadow: $card-header-shadow 44 | display: flex 45 | 46 | .card-header-title 47 | align-items: center 48 | color: $card-header-color 49 | display: flex 50 | flex-grow: 1 51 | font-weight: $card-header-weight 52 | padding: $card-header-padding 53 | &.is-centered 54 | justify-content: center 55 | 56 | .card-header-icon 57 | +reset 58 | align-items: center 59 | cursor: pointer 60 | display: flex 61 | justify-content: center 62 | padding: $card-header-padding 63 | 64 | .card-image 65 | display: block 66 | position: relative 67 | &:first-child 68 | img 69 | border-top-left-radius: $card-radius 70 | border-top-right-radius: $card-radius 71 | &:last-child 72 | img 73 | border-bottom-left-radius: $card-radius 74 | border-bottom-right-radius: $card-radius 75 | 76 | .card-content 77 | @extend %card-item 78 | background-color: $card-content-background-color 79 | padding: $card-content-padding 80 | 81 | .card-footer 82 | @extend %card-item 83 | background-color: $card-footer-background-color 84 | border-top: $card-footer-border-top 85 | align-items: stretch 86 | display: flex 87 | 88 | .card-footer-item 89 | align-items: center 90 | display: flex 91 | flex-basis: 0 92 | flex-grow: 1 93 | flex-shrink: 0 94 | justify-content: center 95 | padding: $card-footer-padding 96 | &:not(:last-child) 97 | +ltr-property("border", $card-footer-border-top) 98 | 99 | // Combinations 100 | 101 | .card 102 | .media:not(:last-child) 103 | margin-bottom: $card-media-margin 104 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/helpers/visibility.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $displays: 'block' 'flex' 'inline' 'inline-block' 'inline-flex' 4 | 5 | @each $display in $displays 6 | .is-#{$display} 7 | display: #{$display} !important 8 | +mobile 9 | .is-#{$display}-mobile 10 | display: #{$display} !important 11 | +tablet 12 | .is-#{$display}-tablet 13 | display: #{$display} !important 14 | +tablet-only 15 | .is-#{$display}-tablet-only 16 | display: #{$display} !important 17 | +touch 18 | .is-#{$display}-touch 19 | display: #{$display} !important 20 | +desktop 21 | .is-#{$display}-desktop 22 | display: #{$display} !important 23 | +desktop-only 24 | .is-#{$display}-desktop-only 25 | display: #{$display} !important 26 | +widescreen 27 | .is-#{$display}-widescreen 28 | display: #{$display} !important 29 | +widescreen-only 30 | .is-#{$display}-widescreen-only 31 | display: #{$display} !important 32 | +fullhd 33 | .is-#{$display}-fullhd 34 | display: #{$display} !important 35 | 36 | .is-hidden 37 | display: none !important 38 | 39 | .is-sr-only 40 | border: none !important 41 | clip: rect(0, 0, 0, 0) !important 42 | height: 0.01em !important 43 | overflow: hidden !important 44 | padding: 0 !important 45 | position: absolute !important 46 | white-space: nowrap !important 47 | width: 0.01em !important 48 | 49 | +mobile 50 | .is-hidden-mobile 51 | display: none !important 52 | 53 | +tablet 54 | .is-hidden-tablet 55 | display: none !important 56 | 57 | +tablet-only 58 | .is-hidden-tablet-only 59 | display: none !important 60 | 61 | +touch 62 | .is-hidden-touch 63 | display: none !important 64 | 65 | +desktop 66 | .is-hidden-desktop 67 | display: none !important 68 | 69 | +desktop-only 70 | .is-hidden-desktop-only 71 | display: none !important 72 | 73 | +widescreen 74 | .is-hidden-widescreen 75 | display: none !important 76 | 77 | +widescreen-only 78 | .is-hidden-widescreen-only 79 | display: none !important 80 | 81 | +fullhd 82 | .is-hidden-fullhd 83 | display: none !important 84 | 85 | .is-invisible 86 | visibility: hidden !important 87 | 88 | +mobile 89 | .is-invisible-mobile 90 | visibility: hidden !important 91 | 92 | +tablet 93 | .is-invisible-tablet 94 | visibility: hidden !important 95 | 96 | +tablet-only 97 | .is-invisible-tablet-only 98 | visibility: hidden !important 99 | 100 | +touch 101 | .is-invisible-touch 102 | visibility: hidden !important 103 | 104 | +desktop 105 | .is-invisible-desktop 106 | visibility: hidden !important 107 | 108 | +desktop-only 109 | .is-invisible-desktop-only 110 | visibility: hidden !important 111 | 112 | +widescreen 113 | .is-invisible-widescreen 114 | visibility: hidden !important 115 | 116 | +widescreen-only 117 | .is-invisible-widescreen-only 118 | visibility: hidden !important 119 | 120 | +fullhd 121 | .is-invisible-fullhd 122 | visibility: hidden !important 123 | -------------------------------------------------------------------------------- /rust/assert_trait/src/lib.rs: -------------------------------------------------------------------------------- 1 | use syn::spanned::Spanned as _; 2 | struct AssertExpr { 3 | generics: Option, 4 | type_trait_object: syn::TypeTraitObject, 5 | expr: syn::Expr, 6 | } 7 | impl syn::parse::Parse for AssertExpr { 8 | fn parse(input: syn::parse::ParseStream) -> syn::Result { 9 | let generics = if input.peek(syn::Token![<]) { 10 | let g = Some(input.parse()?); 11 | input.parse::()?; 12 | g 13 | } else { 14 | None 15 | }; 16 | let type_trait_object = input.parse()?; 17 | input.parse::()?; 18 | let expr = input.parse()?; 19 | input.parse::>()?; 20 | Ok(AssertExpr { 21 | generics, 22 | type_trait_object, 23 | expr, 24 | }) 25 | } 26 | } 27 | 28 | fn build_assert_expr(assert_expr: AssertExpr) -> proc_macro::TokenStream { 29 | let type_trait_object = assert_expr.type_trait_object; 30 | let expr = assert_expr.expr; 31 | if let Some(mut generics) = assert_expr.generics { 32 | generics 33 | .params 34 | .push(syn::GenericParam::Type(syn::TypeParam { 35 | attrs: Vec::new(), 36 | ident: syn::Ident::new("T", type_trait_object.span()), 37 | colon_token: None, 38 | bounds: syn::punctuated::Punctuated::new(), 39 | eq_token: None, 40 | default: None, 41 | })); 42 | quote::quote! { 43 | ({ 44 | fn assert #generics(x: T) -> T where T: #type_trait_object { x } 45 | assert 46 | })(#expr) 47 | } 48 | .into() 49 | } else { 50 | quote::quote! { 51 | ({ 52 | fn assert(x: T) -> T where T: #type_trait_object { x } 53 | assert 54 | })(#expr) 55 | } 56 | .into() 57 | } 58 | } 59 | 60 | #[proc_macro] 61 | pub fn assert_trait(tokens: proc_macro::TokenStream) -> proc_macro::TokenStream { 62 | let input = syn::parse_macro_input!(tokens as AssertExpr); 63 | build_assert_expr(input) 64 | } 65 | 66 | #[cfg(test)] 67 | mod tests { 68 | #[test] 69 | fn assert_trait() { 70 | let tokens = quote::quote!(Iterator, "abc".chars()); 71 | let input = syn::parse2(tokens).unwrap(); 72 | let actual = super::build_assert_expr(input); 73 | let expected = quote::quote! { 74 | ({ 75 | fn assert(x: T) -> T where T: Iterator { x } 76 | assert 77 | })("abc".chars()) 78 | }; 79 | assert_eq!(format!("{}", expected), format!("{}", actual)); 80 | } 81 | 82 | #[test] 83 | fn assert_trait_with_lifetime() { 84 | let tokens = quote::quote!(<'a>, Iterator, "a\nb\nc".lines()); 85 | let input = syn::parse2(tokens).unwrap(); 86 | let actual = super::build_assert_expr(input); 87 | let expected = quote::quote! { 88 | ({ 89 | fn assert<'a, T>(x: T) -> T where T: Iterator { x } 90 | assert 91 | })("a\nb\nc".lines()) 92 | }; 93 | assert_eq!(format!("{}", expected), format!("{}", actual)); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/base/generic.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $body-background-color: $scheme-main !default 4 | $body-size: 16px !default 5 | $body-min-width: 300px !default 6 | $body-rendering: optimizeLegibility !default 7 | $body-family: $family-primary !default 8 | $body-overflow-x: hidden !default 9 | $body-overflow-y: scroll !default 10 | 11 | $body-color: $text !default 12 | $body-font-size: 1em !default 13 | $body-weight: $weight-normal !default 14 | $body-line-height: 1.5 !default 15 | 16 | $code-family: $family-code !default 17 | $code-padding: 0.25em 0.5em 0.25em !default 18 | $code-weight: normal !default 19 | $code-size: 0.875em !default 20 | 21 | $small-font-size: 0.875em !default 22 | 23 | $hr-background-color: $background !default 24 | $hr-height: 2px !default 25 | $hr-margin: 1.5rem 0 !default 26 | 27 | $strong-color: $text-strong !default 28 | $strong-weight: $weight-bold !default 29 | 30 | $pre-font-size: 0.875em !default 31 | $pre-padding: 1.25rem 1.5rem !default 32 | $pre-code-font-size: 1em !default 33 | 34 | html 35 | background-color: $body-background-color 36 | font-size: $body-size 37 | -moz-osx-font-smoothing: grayscale 38 | -webkit-font-smoothing: antialiased 39 | min-width: $body-min-width 40 | overflow-x: $body-overflow-x 41 | overflow-y: $body-overflow-y 42 | text-rendering: $body-rendering 43 | text-size-adjust: 100% 44 | 45 | article, 46 | aside, 47 | figure, 48 | footer, 49 | header, 50 | hgroup, 51 | section 52 | display: block 53 | 54 | body, 55 | button, 56 | input, 57 | optgroup, 58 | select, 59 | textarea 60 | font-family: $body-family 61 | 62 | code, 63 | pre 64 | -moz-osx-font-smoothing: auto 65 | -webkit-font-smoothing: auto 66 | font-family: $code-family 67 | 68 | body 69 | color: $body-color 70 | font-size: $body-font-size 71 | font-weight: $body-weight 72 | line-height: $body-line-height 73 | 74 | // Inline 75 | 76 | a 77 | color: $link 78 | cursor: pointer 79 | text-decoration: none 80 | strong 81 | color: currentColor 82 | &:hover 83 | color: $link-hover 84 | 85 | code 86 | background-color: $code-background 87 | color: $code 88 | font-size: $code-size 89 | font-weight: $code-weight 90 | padding: $code-padding 91 | 92 | hr 93 | background-color: $hr-background-color 94 | border: none 95 | display: block 96 | height: $hr-height 97 | margin: $hr-margin 98 | 99 | img 100 | height: auto 101 | max-width: 100% 102 | 103 | input[type="checkbox"], 104 | input[type="radio"] 105 | vertical-align: baseline 106 | 107 | small 108 | font-size: $small-font-size 109 | 110 | span 111 | font-style: inherit 112 | font-weight: inherit 113 | 114 | strong 115 | color: $strong-color 116 | font-weight: $strong-weight 117 | 118 | // Block 119 | 120 | fieldset 121 | border: none 122 | 123 | pre 124 | +overflow-touch 125 | background-color: $pre-background 126 | color: $pre 127 | font-size: $pre-font-size 128 | overflow-x: auto 129 | padding: $pre-padding 130 | white-space: pre 131 | word-wrap: normal 132 | code 133 | background-color: transparent 134 | color: currentColor 135 | font-size: $pre-code-font-size 136 | padding: 0 137 | 138 | table 139 | td, 140 | th 141 | vertical-align: top 142 | &:not([align]) 143 | text-align: inherit 144 | th 145 | color: $text-strong 146 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/message.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $message-background-color: $background !default 4 | $message-radius: $radius !default 5 | 6 | $message-header-background-color: $text !default 7 | $message-header-color: $text-invert !default 8 | $message-header-weight: $weight-bold !default 9 | $message-header-padding: 0.75em 1em !default 10 | $message-header-radius: $radius !default 11 | 12 | $message-body-border-color: $border !default 13 | $message-body-border-width: 0 0 0 4px !default 14 | $message-body-color: $text !default 15 | $message-body-padding: 1.25em 1.5em !default 16 | $message-body-radius: $radius !default 17 | 18 | $message-body-pre-background-color: $scheme-main !default 19 | $message-body-pre-code-background-color: transparent !default 20 | 21 | $message-header-body-border-width: 0 !default 22 | $message-colors: $colors !default 23 | 24 | .message 25 | @extend %block 26 | background-color: $message-background-color 27 | border-radius: $message-radius 28 | font-size: $size-normal 29 | strong 30 | color: currentColor 31 | a:not(.button):not(.tag):not(.dropdown-item) 32 | color: currentColor 33 | text-decoration: underline 34 | // Sizes 35 | &.is-small 36 | font-size: $size-small 37 | &.is-medium 38 | font-size: $size-medium 39 | &.is-large 40 | font-size: $size-large 41 | // Colors 42 | @each $name, $components in $message-colors 43 | $color: nth($components, 1) 44 | $color-invert: nth($components, 2) 45 | $color-light: null 46 | $color-dark: null 47 | 48 | @if length($components) >= 3 49 | $color-light: nth($components, 3) 50 | @if length($components) >= 4 51 | $color-dark: nth($components, 4) 52 | @else 53 | $color-luminance: colorLuminance($color) 54 | $darken-percentage: $color-luminance * 70% 55 | $desaturate-percentage: $color-luminance * 30% 56 | $color-dark: desaturate(darken($color, $darken-percentage), $desaturate-percentage) 57 | @else 58 | $color-lightning: max((100% - lightness($color)) - 2%, 0%) 59 | $color-light: lighten($color, $color-lightning) 60 | 61 | &.is-#{$name} 62 | background-color: $color-light 63 | .message-header 64 | background-color: $color 65 | color: $color-invert 66 | .message-body 67 | border-color: $color 68 | color: $color-dark 69 | 70 | .message-header 71 | align-items: center 72 | background-color: $message-header-background-color 73 | border-radius: $message-header-radius $message-header-radius 0 0 74 | color: $message-header-color 75 | display: flex 76 | font-weight: $message-header-weight 77 | justify-content: space-between 78 | line-height: 1.25 79 | padding: $message-header-padding 80 | position: relative 81 | .delete 82 | flex-grow: 0 83 | flex-shrink: 0 84 | +ltr-property("margin", 0.75em, false) 85 | & + .message-body 86 | border-width: $message-header-body-border-width 87 | border-top-left-radius: 0 88 | border-top-right-radius: 0 89 | 90 | .message-body 91 | border-color: $message-body-border-color 92 | border-radius: $message-body-radius 93 | border-style: solid 94 | border-width: $message-body-border-width 95 | color: $message-body-color 96 | padding: $message-body-padding 97 | code, 98 | pre 99 | background-color: $message-body-pre-background-color 100 | pre code 101 | background-color: $message-body-pre-code-background-color 102 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/modal.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $modal-z: 40 !default 4 | 5 | $modal-background-background-color: bulmaRgba($scheme-invert, 0.86) !default 6 | 7 | $modal-content-width: 640px !default 8 | $modal-content-margin-mobile: 20px !default 9 | $modal-content-spacing-mobile: 160px !default 10 | $modal-content-spacing-tablet: 40px !default 11 | 12 | $modal-close-dimensions: 40px !default 13 | $modal-close-right: 20px !default 14 | $modal-close-top: 20px !default 15 | 16 | $modal-card-spacing: 40px !default 17 | 18 | $modal-card-head-background-color: $background !default 19 | $modal-card-head-border-bottom: 1px solid $border !default 20 | $modal-card-head-padding: 20px !default 21 | $modal-card-head-radius: $radius-large !default 22 | 23 | $modal-card-title-color: $text-strong !default 24 | $modal-card-title-line-height: 1 !default 25 | $modal-card-title-size: $size-4 !default 26 | 27 | $modal-card-foot-radius: $radius-large !default 28 | $modal-card-foot-border-top: 1px solid $border !default 29 | 30 | $modal-card-body-background-color: $scheme-main !default 31 | $modal-card-body-padding: 20px !default 32 | 33 | $modal-breakpoint: $tablet !default 34 | 35 | .modal 36 | @extend %overlay 37 | align-items: center 38 | display: none 39 | flex-direction: column 40 | justify-content: center 41 | overflow: hidden 42 | position: fixed 43 | z-index: $modal-z 44 | // Modifiers 45 | &.is-active 46 | display: flex 47 | 48 | .modal-background 49 | @extend %overlay 50 | background-color: $modal-background-background-color 51 | 52 | .modal-content, 53 | .modal-card 54 | margin: 0 $modal-content-margin-mobile 55 | max-height: calc(100vh - #{$modal-content-spacing-mobile}) 56 | overflow: auto 57 | position: relative 58 | width: 100% 59 | // Responsiveness 60 | +from($modal-breakpoint) 61 | margin: 0 auto 62 | max-height: calc(100vh - #{$modal-content-spacing-tablet}) 63 | width: $modal-content-width 64 | 65 | .modal-close 66 | @extend %delete 67 | background: none 68 | height: $modal-close-dimensions 69 | position: fixed 70 | +ltr-position($modal-close-right) 71 | top: $modal-close-top 72 | width: $modal-close-dimensions 73 | 74 | .modal-card 75 | display: flex 76 | flex-direction: column 77 | max-height: calc(100vh - #{$modal-card-spacing}) 78 | overflow: hidden 79 | -ms-overflow-y: visible 80 | 81 | .modal-card-head, 82 | .modal-card-foot 83 | align-items: center 84 | background-color: $modal-card-head-background-color 85 | display: flex 86 | flex-shrink: 0 87 | justify-content: flex-start 88 | padding: $modal-card-head-padding 89 | position: relative 90 | 91 | .modal-card-head 92 | border-bottom: $modal-card-head-border-bottom 93 | border-top-left-radius: $modal-card-head-radius 94 | border-top-right-radius: $modal-card-head-radius 95 | 96 | .modal-card-title 97 | color: $modal-card-title-color 98 | flex-grow: 1 99 | flex-shrink: 0 100 | font-size: $modal-card-title-size 101 | line-height: $modal-card-title-line-height 102 | 103 | .modal-card-foot 104 | border-bottom-left-radius: $modal-card-foot-radius 105 | border-bottom-right-radius: $modal-card-foot-radius 106 | border-top: $modal-card-foot-border-top 107 | .button 108 | &:not(:last-child) 109 | +ltr-property("margin", 0.5em) 110 | 111 | .modal-card-body 112 | +overflow-touch 113 | background-color: $modal-card-body-background-color 114 | flex-grow: 1 115 | flex-shrink: 1 116 | overflow: auto 117 | padding: $modal-card-body-padding 118 | -------------------------------------------------------------------------------- /cxx/delay-signal/delay-signal.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | static void die(const char *msg) { 12 | perror(msg); 13 | exit(EXIT_FAILURE); 14 | } 15 | 16 | static int setup_signalfd(int epoll_fd, sigset_t *mask) { 17 | int fd = signalfd(-1, mask, SFD_CLOEXEC); 18 | if (fd == -1) { 19 | perror("signalfd"); 20 | } 21 | epoll_event event = { 22 | .events = EPOLLIN, .data = {.fd = fd}, 23 | }; 24 | if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &event) == -1) { 25 | perror("epoll_ctl(ADD, signalfd)"); 26 | } 27 | return fd; 28 | } 29 | 30 | int main(int argc, char *argv[]) { 31 | if (argc < 2) { 32 | fprintf(stderr, "Usage: %s COMMAND ARG ...\n", argv[0]); 33 | return 1; 34 | } 35 | long delay_sec = 5; 36 | 37 | sigset_t mask, target_mask; 38 | sigfillset(&mask); 39 | sigemptyset(&target_mask); 40 | sigaddset(&target_mask, SIGINT); 41 | sigaddset(&target_mask, SIGTERM); 42 | 43 | if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) { 44 | die("sigprocmask"); 45 | } 46 | 47 | const int epoll_fd = epoll_create1(EPOLL_CLOEXEC); 48 | if (epoll_fd == -1) { 49 | die("epoll_create1"); 50 | } 51 | const int sig_fd = setup_signalfd(epoll_fd, &mask); 52 | 53 | pid_t pid = fork(); 54 | if (pid == -1) { 55 | die("fork"); 56 | } else if (pid == 0) { 57 | sigprocmask(SIG_UNBLOCK, &mask, NULL); 58 | setsid(); 59 | execvp(argv[1], argv + 1); 60 | die("execvp"); 61 | } 62 | 63 | std::map delayed_signo; 64 | int child_status; 65 | 66 | for (;;) { 67 | epoll_event event; 68 | if (epoll_wait(epoll_fd, &event, 1, -1) == -1) { 69 | die("epoll_wait"); 70 | } 71 | 72 | if (event.data.fd == sig_fd) { 73 | signalfd_siginfo info; 74 | ssize_t n = read(event.data.fd, &info, sizeof(info)); 75 | if (n != sizeof(info)) { 76 | die("read"); 77 | } 78 | 79 | if (info.ssi_signo == SIGCHLD) { 80 | pid_t p = waitpid(pid, &child_status, WNOHANG); 81 | if (p == -1) { 82 | die("waitpid"); 83 | } else if (p == pid) { 84 | break; 85 | } 86 | } else { 87 | if (sigismember(&target_mask, info.ssi_signo)) { 88 | int timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); 89 | itimerspec it = { 90 | .it_interval = 91 | { 92 | .tv_sec = 0, .tv_nsec = 0, 93 | }, 94 | .it_value = 95 | { 96 | .tv_sec = delay_sec, .tv_nsec = 0, 97 | }, 98 | }; 99 | timerfd_settime(timer_fd, 0, &it, NULL); 100 | epoll_event ev = { 101 | .events = EPOLLIN, .data = {.fd = timer_fd}, 102 | }; 103 | epoll_ctl(epoll_fd, EPOLL_CTL_ADD, timer_fd, &ev); 104 | delayed_signo.insert(std::make_pair(timer_fd, info.ssi_signo)); 105 | } else { 106 | kill(pid, info.ssi_signo); 107 | } 108 | } 109 | } else { 110 | auto it = delayed_signo.find(event.data.fd); 111 | kill(pid, it->second); 112 | epoll_ctl(epoll_fd, EPOLL_CTL_DEL, it->first, NULL); 113 | close(it->first); 114 | delayed_signo.erase(it); 115 | } 116 | } 117 | 118 | close(epoll_fd); 119 | for (const auto &p : delayed_signo) { 120 | close(p.first); 121 | } 122 | close(sig_fd); 123 | 124 | return WEXITSTATUS(child_status); 125 | } 126 | -------------------------------------------------------------------------------- /rust/corretto-pkgbuild/test/corretto-8.342.07.4.md: -------------------------------------------------------------------------------- 1 | For release notes see : [CHANGELOG.md](https://github.com/corretto/corretto-8/blob/release-8.342.07.4/CHANGELOG.md) 2 | 3 | Note about OpenJDK [8u345](https://mail.openjdk.org/pipermail/jdk8u-dev/2022-August/015329.html): it contains only one fix for the next issue: 4 | * [JDK-8290832](https://bugs.openjdk.org/browse/JDK-8290832) It is no longer possible to change "user.dir" in the JDK8 5 | 6 | The Corretto 8.342.07.4 is up to date and has this fix already, so we do not need to release a new version. 7 | 8 | ### Download Links 9 | |Platform |Type |Download Link |Checksum (MD5) / Checksum (SHA256) |Sig File | 10 | |--- |--- |--- |--- |--- | 11 | |[Linux x64](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/generic-linux-install.html) |JDK | [java-1.8.0-amazon-corretto-jdk_8.342.07-4_amd64.deb](https://corretto.aws/downloads/resources/8.342.07.4/java-1.8.0-amazon-corretto-jdk_8.342.07-4_amd64.deb) | `cc8d7cd9d117899d99560dba3a4a204d` /
`0bd6f95b51cc729a6ce4bb6792e877e9e43c8ae5fa7835bc43bb80e7d87bcf7f` | | 12 | |[Linux x64](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/generic-linux-install.html) |JDK | [java-1.8.0-amazon-corretto-devel-1.8.0_342.b07-4.x86_64.rpm](https://corretto.aws/downloads/resources/8.342.07.4/java-1.8.0-amazon-corretto-devel-1.8.0_342.b07-4.x86_64.rpm) | `16ff8e9bedf5e8286a7506b768a4a0a2` /
`1886ee654af4ea78e9cc048a119511d807858798a96e85301cda1754ee79556d` | | 13 | |[Linux x64](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/generic-linux-install.html) |JDK | [amazon-corretto-8.342.07.4-linux-x64.tar.gz](https://corretto.aws/downloads/resources/8.342.07.4/amazon-corretto-8.342.07.4-linux-x64.tar.gz) | `b330794990c0c0df2338b9749ede7cae` /
`f10fc46f42df58cf26a4689a7016aa610b691ad4e8be7c349f8651dec79d4e41` | [Download](https://corretto.aws/downloads/resources/8.342.07.4/amazon-corretto-8.342.07.4-linux-x64.tar.gz.sig) | 14 | |[Linux aarch64](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/generic-linux-install.html) |JDK |[java-1.8.0-amazon-corretto-jdk_8.342.07-4_arm64.deb](https://corretto.aws/downloads/resources/8.342.07.4/java-1.8.0-amazon-corretto-jdk_8.342.07-4_arm64.deb) | `05be218afed8de2d619b46c1b6a9e379` /
`d6c1f9f3f697ed0aefdb329aec084dab8efe8154990d39c620fdfbd649476cd0` | | 15 | |[Linux aarch64](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/generic-linux-install.html) |JDK |[java-1.8.0-amazon-corretto-devel-1.8.0_342.b07-4.aarch64.rpm](https://corretto.aws/downloads/resources/8.342.07.4/java-1.8.0-amazon-corretto-devel-1.8.0_342.b07-4.aarch64.rpm) | `4162f4476e170b2285a6e11b8745f807` /
`2d8da94d304689b9e1127bd4f2cbda0045b8f3bece8bbf83439cebfb9f875bd8` | | 16 | |[Linux aarch64](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/generic-linux-install.html) |JDK |[amazon-corretto-8.342.07.4-linux-aarch64.tar.gz](https://corretto.aws/downloads/resources/8.342.07.4/amazon-corretto-8.342.07.4-linux-aarch64.tar.gz) | `9828bce5fdb42daf009234fa22ed51f6` /
`2d454c4804fc2ee5a2aef9f517ca6c2b85dee7728d74edf20f85a35681b2d143` | [Download](https://corretto.aws/downloads/resources/8.342.07.4/amazon-corretto-8.342.07.4-linux-aarch64.tar.gz.sig) | 17 | |[Alpine Linux x64](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/generic-linux-install.html)|JDK | [amazon-corretto-8.342.07.4-alpine-linux-x64.tar.gz](https://corretto.aws/downloads/resources/8.342.07.4/amazon-corretto-8.342.07.4-alpine-linux-x64.tar.gz) | `53baa75ff89d6270b21a5583fb1ddc0a` /
`f327ac3fa64a6dcf8c86a8f141f730fe9386f5192be6f42d5b9ee47f9c8b8c35` | [Download](https://corretto.aws/downloads/resources/8.342.07.4/amazon-corretto-8.342.07.4-alpine-linux-x64.tar.gz.sig) | 18 | -------------------------------------------------------------------------------- /rust/ambiwidth/src/main.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Usage: cargo run 3 | * sudo cp UTF-8-CJK.gz /usr/share/i18n/charmaps/ 4 | * sudo vim /etc/locale.gen # Add "ja_JP.UTF-8 UTF-8-CJK" 5 | * sudo locale-gen 6 | */ 7 | 8 | const UTF8_CHARMAP: &str = "/usr/share/i18n/charmaps/UTF-8.gz"; 9 | const EAST_ASIAN_WIDTH_URL: &str = "https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt"; 10 | 11 | use std::io::{BufRead, Write}; 12 | 13 | #[derive(Debug)] 14 | struct CharRange { 15 | start: u32, 16 | end: u32, 17 | } 18 | impl std::fmt::Display for CharRange { 19 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 20 | if self.start == self.end { 21 | Ok(()) 22 | } else if self.start + 1 == self.end { 23 | format_codepoint(f, self.start)?; 24 | write!(f, "\t\t\t2") 25 | } else { 26 | format_codepoint(f, self.start)?; 27 | write!(f, "...")?; 28 | format_codepoint(f, self.end - 1)?; 29 | write!(f, "\t2") 30 | } 31 | } 32 | } 33 | 34 | fn format_codepoint(f: &mut std::fmt::Formatter, c: u32) -> std::fmt::Result { 35 | if c < 0x10000 { 36 | write!(f, "", c) 37 | } else { 38 | write!(f, "", c) 39 | } 40 | } 41 | 42 | #[tokio::main] 43 | async fn main() -> Result<(), Box> { 44 | let client = reqwest::Client::new(); 45 | let resp = client 46 | .get(EAST_ASIAN_WIDTH_URL) 47 | .header( 48 | reqwest::header::ACCEPT_ENCODING, 49 | reqwest::header::HeaderValue::from_static("gzip"), 50 | ) 51 | .send() 52 | .await? 53 | .error_for_status()?; 54 | let body = resp.text().await?; 55 | 56 | let single_re = regex_lite::Regex::new(r"\A([0-9A-F]+);A")?; 57 | let multi_re = regex_lite::Regex::new(r"\A([0-9A-F]+)\.\.([0-9A-F]+);A")?; 58 | 59 | let mut ranges = Vec::new(); 60 | let mut cr = CharRange { start: 0, end: 0 }; 61 | for line in body.lines() { 62 | if let Some(caps) = single_re.captures(line) { 63 | let c = u32::from_str_radix(caps.get(1).unwrap().as_str(), 16)?; 64 | if cr.end == c { 65 | cr.end += 1; 66 | } else { 67 | ranges.push(cr); 68 | cr = CharRange { 69 | start: c, 70 | end: c + 1, 71 | }; 72 | } 73 | } else if let Some(caps) = multi_re.captures(line) { 74 | let c1 = u32::from_str_radix(caps.get(1).unwrap().as_str(), 16)?; 75 | let c2 = u32::from_str_radix(caps.get(2).unwrap().as_str(), 16)?; 76 | if cr.end == c1 { 77 | cr.end += c2 - c1 + 1; 78 | } else { 79 | ranges.push(cr); 80 | cr = CharRange { 81 | start: c1, 82 | end: c2 + 1, 83 | }; 84 | } 85 | } 86 | } 87 | ranges.push(cr); 88 | 89 | let mut writer = std::io::BufWriter::new(flate2::write::GzEncoder::new( 90 | std::fs::File::create("UTF-8-CJK.gz")?, 91 | flate2::Compression::default(), 92 | )); 93 | let reader = std::io::BufReader::new(flate2::bufread::GzDecoder::new(std::io::BufReader::new( 94 | std::fs::File::open(UTF8_CHARMAP)?, 95 | ))); 96 | for line in reader.lines() { 97 | let line = line?; 98 | if line == "END WIDTH" { 99 | for cr in ranges.drain(..) { 100 | writeln!(writer, "{}", cr)?; 101 | } 102 | } 103 | writeln!(writer, "{}", line)?; 104 | } 105 | 106 | Ok(()) 107 | } 108 | -------------------------------------------------------------------------------- /rust/gyazo/src/main.rs: -------------------------------------------------------------------------------- 1 | const BUCKET_NAME: &str = "gyazo.wanko.cc"; 2 | const URL_PREFIX: &str = "https://gyazo.wanko.cc"; 3 | const REGION: &str = "ap-northeast-1"; 4 | 5 | #[tokio::main] 6 | async fn main() -> Result<(), Box> { 7 | let shared_config = aws_config::defaults(aws_config::BehaviorVersion::v2025_01_17()) 8 | .region(REGION) 9 | .load() 10 | .await; 11 | let s3 = aws_sdk_s3::Client::new(&shared_config); 12 | 13 | for arg in std::env::args().skip(1) { 14 | upload(&s3, std::path::Path::new(&arg)).await?; 15 | } 16 | Ok(()) 17 | } 18 | 19 | async fn upload( 20 | s3_client: &aws_sdk_s3::Client, 21 | path: &std::path::Path, 22 | ) -> Result<(), Box> { 23 | use sha2::Digest as _; 24 | let image = tokio::fs::read(path).await?; 25 | let mut hasher = sha2::Sha256::new(); 26 | hasher.update(&image); 27 | let digest = format!("{:x}", hasher.finalize()); 28 | 29 | let image_key = format!( 30 | "{}.{}", 31 | digest, 32 | path.extension() 33 | .map(|ext| ext.to_str().unwrap()) 34 | .unwrap_or("") 35 | ); 36 | let content_type = path.extension().and_then(guess_content_type); 37 | let html = render_html(&digest, &image_key).into_bytes(); 38 | println!( 39 | "{} -> {}/{} (https://s3-{}.amazonaws.com/{}/{})", 40 | path.display(), 41 | URL_PREFIX, 42 | digest, 43 | REGION, 44 | BUCKET_NAME, 45 | digest 46 | ); 47 | let put_image_future = s3_client 48 | .put_object() 49 | .bucket(BUCKET_NAME) 50 | .storage_class(aws_sdk_s3::types::StorageClass::ReducedRedundancy) 51 | .key(image_key) 52 | .content_length(image.len() as i64) 53 | .body(image.into()) 54 | .set_content_type(content_type) 55 | .send(); 56 | let put_html_future = s3_client 57 | .put_object() 58 | .bucket(BUCKET_NAME) 59 | .storage_class(aws_sdk_s3::types::StorageClass::ReducedRedundancy) 60 | .key(digest) 61 | .content_length(html.len() as i64) 62 | .body(html.into()) 63 | .content_type("text/html") 64 | .send(); 65 | let (put_image_result, put_html_result) = futures::join!(put_image_future, put_html_future); 66 | put_image_result?; 67 | put_html_result?; 68 | Ok(()) 69 | } 70 | 71 | fn render_html(digest: &str, key: &str) -> String { 72 | let link = format!("{}/{}", URL_PREFIX, key); 73 | 74 | let mut buf = String::new(); 75 | buf.push_str(""); 76 | buf.push_str(digest); 77 | buf.push_str( 78 | "");
 91 |     buf.push_str(key);
 92 |     buf.push_str(""); 95 | buf 96 | } 97 | 98 | fn guess_content_type(ext: &std::ffi::OsStr) -> Option { 99 | if ext == "png" { 100 | Some("image/png".to_owned()) 101 | } else if ext == "jpg" { 102 | Some("image/jpeg".to_owned()) 103 | } else { 104 | None 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /rust/agent-proto/src/bin/agent.rs: -------------------------------------------------------------------------------- 1 | struct Agent { 2 | total: std::sync::Arc>, 3 | } 4 | 5 | #[tonic::async_trait] 6 | impl agent_proto::agent_service_server::AgentService for Agent { 7 | async fn increment( 8 | &self, 9 | request: tonic::Request, 10 | ) -> Result, tonic::Status> { 11 | let mut n = self 12 | .total 13 | .lock() 14 | .map_err(|e| tonic::Status::internal(e.to_string()))?; 15 | *n += request.into_inner().n; 16 | Ok(tonic::Response::new(agent_proto::IncrementResponse { 17 | total: *n, 18 | })) 19 | } 20 | } 21 | 22 | // Do not use tokio::main because fork(2) inside Tokio runtime behaves badly 23 | fn main() -> Result<(), anyhow::Error> { 24 | tracing_subscriber::fmt::init(); 25 | nix::sys::stat::umask(nix::sys::stat::Mode::from_bits(0o077).unwrap()); 26 | 27 | let socket_dir = tempfile::Builder::new().prefix("agent-proto-").tempdir()?; 28 | let parent_pid = std::process::id(); 29 | let socket_path = socket_dir.path().join(format!("agent.{}.sock", parent_pid)); 30 | 31 | if let nix::unistd::ForkResult::Parent { child } = unsafe { nix::unistd::fork() }? { 32 | println!( 33 | "AGENT_PROTO_SOCK={}; export AGENT_PROTO_SOCK;", 34 | socket_path.display() 35 | ); 36 | println!("AGENT_PROTO_PID={}; export AGENT_PROTO_PID;", child); 37 | std::process::exit(0); 38 | } 39 | 40 | unsafe { 41 | libc::prctl(libc::PR_SET_DUMPABLE, 0); 42 | libc::setrlimit( 43 | libc::RLIMIT_CORE, 44 | &libc::rlimit { 45 | rlim_cur: 0, 46 | rlim_max: 0, 47 | }, 48 | ); 49 | } 50 | nix::unistd::setsid()?; 51 | std::env::set_current_dir("/")?; 52 | let child_pid = std::process::id(); 53 | { 54 | let stdin = std::fs::File::open("/dev/null")?; 55 | nix::unistd::dup2_stdin(stdin)?; 56 | let stdout = 57 | std::fs::File::create(socket_dir.path().join(format!("stdout.{}.log", child_pid)))?; 58 | let stderr = 59 | std::fs::File::create(socket_dir.path().join(format!("stderr.{}.log", child_pid)))?; 60 | nix::unistd::dup2_stdout(stdout)?; 61 | nix::unistd::dup2_stderr(stderr)?; 62 | } 63 | 64 | let rt = tokio::runtime::Runtime::new()?; 65 | rt.block_on(async { 66 | let uds = tokio::net::UnixListener::bind(&socket_path)?; 67 | let uds_stream = tokio_stream::wrappers::UnixListenerStream::new(uds); 68 | 69 | let agent = Agent { 70 | total: std::sync::Arc::new(std::sync::Mutex::new(0)), 71 | }; 72 | tracing::info!( 73 | "Starting server {} (pid: {})", 74 | socket_path.display(), 75 | child_pid, 76 | ); 77 | tonic::transport::Server::builder() 78 | .add_service(agent_proto::agent_service_server::AgentServiceServer::new( 79 | agent, 80 | )) 81 | .serve_with_incoming_shutdown(uds_stream, shutdown()) 82 | .await?; 83 | tracing::info!("Exiting"); 84 | Ok(()) 85 | }) 86 | } 87 | 88 | async fn shutdown() { 89 | let mut sigint = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::interrupt()) 90 | .expect("Failed to set signal handler for SIGINT"); 91 | let mut sigterm = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()) 92 | .expect("Failed to set signal handler for SIGTERM"); 93 | let sig = tokio::select! { 94 | _ = sigint.recv() => "SIGINT", 95 | _ = sigterm.recv() => "SIGTERM", 96 | }; 97 | tracing::info!("Got {}", sig); 98 | } 99 | -------------------------------------------------------------------------------- /rust/github-api-v4-sample/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, serde::Serialize)] 2 | struct Claims { 3 | iat: u64, 4 | exp: u64, 5 | iss: u64, 6 | } 7 | 8 | #[derive(Debug, serde::Deserialize)] 9 | struct AppInstallation { 10 | id: u64, 11 | } 12 | 13 | #[derive(Debug, serde::Deserialize)] 14 | struct AppInstallationAccessToken { 15 | token: String, 16 | } 17 | 18 | #[derive(Debug, clap::Parser)] 19 | struct Opt { 20 | #[clap(short, long)] 21 | private_key: String, 22 | #[clap(short, long)] 23 | app_id: u64, 24 | #[clap(short, long)] 25 | owner: String, 26 | #[clap(short, long)] 27 | name: String, 28 | } 29 | 30 | #[allow(clippy::upper_case_acronyms)] 31 | type URI = String; 32 | #[derive(graphql_client::GraphQLQuery)] 33 | #[graphql( 34 | query_path = "latest_tarball_query.graphql", 35 | schema_path = "../schema.docs.graphql", 36 | response_derives = "Debug" 37 | )] 38 | struct LatestTarballQuery; 39 | 40 | #[tokio::main] 41 | async fn main() -> Result<(), anyhow::Error> { 42 | tracing_subscriber::fmt::init(); 43 | use clap::Parser as _; 44 | let opt = Opt::parse(); 45 | 46 | let client = reqwest::Client::builder() 47 | .user_agent("github-api-v4-sample") 48 | .build()?; 49 | let pem = std::fs::read(&opt.private_key)?; 50 | let encoding_key = jsonwebtoken::EncodingKey::from_rsa_pem(&pem)?; 51 | let now = std::time::SystemTime::now() 52 | .duration_since(std::time::UNIX_EPOCH)? 53 | .as_secs(); 54 | let claims = Claims { 55 | iat: now, 56 | exp: now + 9 * 60, 57 | iss: opt.app_id, 58 | }; 59 | let jwt = jsonwebtoken::encode( 60 | &jsonwebtoken::Header::new(jsonwebtoken::Algorithm::RS256), 61 | &claims, 62 | &encoding_key, 63 | )?; 64 | 65 | let installations: Vec = client 66 | .get("https://api.github.com/app/installations") 67 | .bearer_auth(&jwt) 68 | .header(reqwest::header::ACCEPT, "application/vnd.github.v3+json") 69 | .send() 70 | .await? 71 | .error_for_status()? 72 | .json() 73 | .await?; 74 | let installation_id = installations[0].id; 75 | 76 | let AppInstallationAccessToken { token } = client 77 | .post(format!( 78 | "https://api.github.com/app/installations/{}/access_tokens", 79 | installation_id 80 | )) 81 | .bearer_auth(&jwt) 82 | .header(reqwest::header::ACCEPT, "application/vnd.github.v3+json") 83 | .send() 84 | .await? 85 | .error_for_status()? 86 | .json() 87 | .await?; 88 | 89 | use graphql_client::GraphQLQuery as _; 90 | let query = LatestTarballQuery::build_query(latest_tarball_query::Variables { 91 | owner: opt.owner, 92 | name: opt.name, 93 | }); 94 | let resp: graphql_client::Response = client 95 | .post("https://api.github.com/graphql") 96 | .bearer_auth(&token) 97 | .json(&query) 98 | .send() 99 | .await? 100 | .error_for_status()? 101 | .json() 102 | .await?; 103 | 104 | if let Some(errors) = resp.errors { 105 | return Err(anyhow::anyhow!("GraphQL error: {:?}", errors)); 106 | } 107 | if let Some(latest_tarball_query::LatestTarballQueryRepositoryDefaultBranchRefTarget::Commit( 108 | commit, 109 | )) = resp 110 | .data 111 | .as_ref() 112 | .and_then(|data| data.repository.as_ref()) 113 | .and_then(|repo| repo.default_branch_ref.as_ref()) 114 | .and_then(|r| r.target.as_ref()) 115 | { 116 | println!("{}", commit.tarball_url); 117 | } else { 118 | return Err(anyhow::anyhow!("Unexpected query response: {:?}", resp)); 119 | } 120 | Ok(()) 121 | } 122 | -------------------------------------------------------------------------------- /rust/graphql-sample/sample-client/vendor/bulma/sass/components/panel.sass: -------------------------------------------------------------------------------- 1 | @import "../utilities/mixins" 2 | 3 | $panel-margin: $block-spacing !default 4 | $panel-item-border: 1px solid $border-light !default 5 | $panel-radius: $radius-large !default 6 | $panel-shadow: $shadow !default 7 | 8 | $panel-heading-background-color: $border-light !default 9 | $panel-heading-color: $text-strong !default 10 | $panel-heading-line-height: 1.25 !default 11 | $panel-heading-padding: 0.75em 1em !default 12 | $panel-heading-radius: $radius !default 13 | $panel-heading-size: 1.25em !default 14 | $panel-heading-weight: $weight-bold !default 15 | 16 | $panel-tabs-font-size: 0.875em !default 17 | $panel-tab-border-bottom: 1px solid $border !default 18 | $panel-tab-active-border-bottom-color: $link-active-border !default 19 | $panel-tab-active-color: $link-active !default 20 | 21 | $panel-list-item-color: $text !default 22 | $panel-list-item-hover-color: $link !default 23 | 24 | $panel-block-color: $text-strong !default 25 | $panel-block-hover-background-color: $background !default 26 | $panel-block-active-border-left-color: $link !default 27 | $panel-block-active-color: $link-active !default 28 | $panel-block-active-icon-color: $link !default 29 | 30 | $panel-icon-color: $text-light !default 31 | $panel-colors: $colors !default 32 | 33 | .panel 34 | border-radius: $panel-radius 35 | box-shadow: $panel-shadow 36 | font-size: $size-normal 37 | &:not(:last-child) 38 | margin-bottom: $panel-margin 39 | // Colors 40 | @each $name, $components in $panel-colors 41 | $color: nth($components, 1) 42 | $color-invert: nth($components, 2) 43 | &.is-#{$name} 44 | .panel-heading 45 | background-color: $color 46 | color: $color-invert 47 | .panel-tabs a.is-active 48 | border-bottom-color: $color 49 | .panel-block.is-active .panel-icon 50 | color: $color 51 | 52 | .panel-tabs, 53 | .panel-block 54 | &:not(:last-child) 55 | border-bottom: $panel-item-border 56 | 57 | .panel-heading 58 | background-color: $panel-heading-background-color 59 | border-radius: $panel-radius $panel-radius 0 0 60 | color: $panel-heading-color 61 | font-size: $panel-heading-size 62 | font-weight: $panel-heading-weight 63 | line-height: $panel-heading-line-height 64 | padding: $panel-heading-padding 65 | 66 | .panel-tabs 67 | align-items: flex-end 68 | display: flex 69 | font-size: $panel-tabs-font-size 70 | justify-content: center 71 | a 72 | border-bottom: $panel-tab-border-bottom 73 | margin-bottom: -1px 74 | padding: 0.5em 75 | // Modifiers 76 | &.is-active 77 | border-bottom-color: $panel-tab-active-border-bottom-color 78 | color: $panel-tab-active-color 79 | 80 | .panel-list 81 | a 82 | color: $panel-list-item-color 83 | &:hover 84 | color: $panel-list-item-hover-color 85 | 86 | .panel-block 87 | align-items: center 88 | color: $panel-block-color 89 | display: flex 90 | justify-content: flex-start 91 | padding: 0.5em 0.75em 92 | input[type="checkbox"] 93 | +ltr-property("margin", 0.75em) 94 | & > .control 95 | flex-grow: 1 96 | flex-shrink: 1 97 | width: 100% 98 | &.is-wrapped 99 | flex-wrap: wrap 100 | &.is-active 101 | border-left-color: $panel-block-active-border-left-color 102 | color: $panel-block-active-color 103 | .panel-icon 104 | color: $panel-block-active-icon-color 105 | &:last-child 106 | border-bottom-left-radius: $panel-radius 107 | border-bottom-right-radius: $panel-radius 108 | 109 | a.panel-block, 110 | label.panel-block 111 | cursor: pointer 112 | &:hover 113 | background-color: $panel-block-hover-background-color 114 | 115 | .panel-icon 116 | +fa(14px, 1em) 117 | color: $panel-icon-color 118 | +ltr-property("margin", 0.75em) 119 | .fa 120 | font-size: inherit 121 | line-height: inherit 122 | -------------------------------------------------------------------------------- /rust/pfs-unpack/src/main.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This code is based on GARbro written by morkt under MIT license. 3 | * https://github.com/morkt/GARbro 4 | */ 5 | 6 | use anyhow::Context as _; 7 | use byteorder::ReadBytesExt as _; 8 | use std::io::Read as _; 9 | use std::io::Seek as _; 10 | use std::io::Write as _; 11 | 12 | fn main() -> anyhow::Result<()> { 13 | tracing_subscriber::fmt() 14 | .with_env_filter( 15 | tracing_subscriber::EnvFilter::builder() 16 | .with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into()) 17 | .from_env_lossy(), 18 | ) 19 | .init(); 20 | 21 | for arg in std::env::args().skip(1) { 22 | unpack(&arg).with_context(|| format!("failed to unpack {}", arg))?; 23 | } 24 | Ok(()) 25 | } 26 | 27 | #[derive(Debug)] 28 | struct Entry { 29 | name: String, 30 | offset: u32, 31 | size: u32, 32 | } 33 | 34 | fn unpack

(path: P) -> anyhow::Result<()> 35 | where 36 | P: AsRef, 37 | { 38 | let file = std::fs::File::open(path)?; 39 | let mut reader = std::io::BufReader::new(file); 40 | 41 | let mut magic = [0; 2]; 42 | reader.read_exact(&mut magic)?; 43 | if &magic != b"pf" { 44 | return Err(anyhow::anyhow!("not an Artemis archive")); 45 | } 46 | let mut version = [0; 1]; 47 | reader.read_exact(&mut version)?; 48 | let version = version[0] - b'0'; 49 | if version != 8 { 50 | return Err(anyhow::anyhow!("unknown version number: {}", version)); 51 | } 52 | 53 | let index_size = reader.read_u32::()? as usize; 54 | tracing::debug!("index_size = {}", index_size); 55 | 56 | let pos = reader.stream_position()?; 57 | let mut index = vec![0u8; index_size]; 58 | reader.read_exact(&mut index)?; 59 | let key = ring::digest::digest(&ring::digest::SHA1_FOR_LEGACY_USE_ONLY, &index); 60 | let key = key.as_ref(); 61 | reader.seek(std::io::SeekFrom::Start(pos))?; 62 | 63 | let file_count = reader.read_u32::()?; 64 | tracing::debug!("file_count = {}", file_count); 65 | let mut entries = Vec::new(); 66 | for i in 0..file_count { 67 | let name_length = reader.read_u32::()? as usize; 68 | tracing::debug!("[{}] name_length={}", i, name_length); 69 | let mut name = vec![0u8; name_length]; 70 | reader.read_exact(&mut name)?; 71 | let name = String::from_utf8(name)?; 72 | tracing::debug!(" name={}", name); 73 | reader.read_u32::()?; // Skip 4 bytes 74 | let offset = reader.read_u32::()?; 75 | let size = reader.read_u32::()?; 76 | tracing::debug!(" offset={} size={}", offset, size); 77 | entries.push(Entry { name, offset, size }); 78 | } 79 | 80 | let separator = std::path::MAIN_SEPARATOR.to_string(); 81 | let mut buf = vec![0u8; 16 * 1024]; 82 | let buf_size = buf.len(); 83 | for entry in entries { 84 | reader.seek(std::io::SeekFrom::Start(entry.offset as u64))?; 85 | let p = std::path::PathBuf::from(entry.name.replace('\\', &separator)); 86 | tracing::info!("Unpack {} (size={})", p.display(), entry.size); 87 | if let Some(parent) = p.parent() { 88 | std::fs::create_dir_all(parent)?; 89 | } 90 | let file = std::fs::File::create(&p)?; 91 | let mut writer = std::io::BufWriter::new(file); 92 | let mut read_bytes = 0; 93 | let size = entry.size as usize; 94 | while read_bytes < size { 95 | let r = reader.read(&mut buf[0..std::cmp::min(buf_size, size - read_bytes)])?; 96 | for i in 0..r { 97 | buf[i] ^= key[(read_bytes + i) % key.len()]; 98 | } 99 | read_bytes += r; 100 | writer.write_all(&buf[0..r])?; 101 | } 102 | } 103 | 104 | Ok(()) 105 | } 106 | -------------------------------------------------------------------------------- /rust/unused-libsonnet/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, clap::Parser)] 2 | struct Args { 3 | dir: std::path::PathBuf, 4 | } 5 | 6 | type ImportedSet = std::cell::RefCell>; 7 | 8 | fn main() -> anyhow::Result<()> { 9 | use clap::Parser as _; 10 | let args = Args::parse(); 11 | let cwd = std::env::current_dir()?; 12 | 13 | let imported = ImportedSet::default(); 14 | let mut found_libsonnet = std::collections::HashSet::new(); 15 | 16 | for entry in walkdir::WalkDir::new(args.dir) { 17 | let entry = entry?; 18 | if entry.file_type().is_file() 19 | && entry.path().extension().is_some_and(|ext| ext == "jsonnet") 20 | { 21 | let state = create_state(imported.clone()); 22 | if let Err(e) = state 23 | .import(entry.path()) 24 | .and_then(|val| val.manifest(jrsonnet_evaluator::manifest::JsonFormat::minify())) 25 | { 26 | anyhow::bail!("{}: {}", entry.path().display(), e); 27 | } 28 | } else if entry.file_type().is_file() 29 | && entry 30 | .path() 31 | .extension() 32 | .is_some_and(|ext| ext == "libsonnet") 33 | { 34 | found_libsonnet.insert(entry.path().to_path_buf()); 35 | } 36 | } 37 | 38 | let imported = imported.into_inner(); 39 | let mut c = 0; 40 | for relative_path in found_libsonnet { 41 | let absolute_path = cwd.join(&relative_path); 42 | if !imported.contains(&absolute_path) { 43 | println!("{}", relative_path.display()); 44 | c += 1; 45 | } 46 | } 47 | 48 | if c > 0 { 49 | std::process::exit(c); 50 | } 51 | Ok(()) 52 | } 53 | 54 | #[jrsonnet_evaluator::function::builtin] 55 | fn provide_vault(_options: jrsonnet_evaluator::Val, _name: jrsonnet_evaluator::Val) -> String { 56 | "fake".to_owned() 57 | } 58 | 59 | fn create_state(imported: ImportedSet) -> jrsonnet_evaluator::State { 60 | let state = jrsonnet_evaluator::State::default(); 61 | state.set_import_resolver(ImportResolver::new(imported)); 62 | 63 | let context_initializer = jrsonnet_stdlib::ContextInitializer::new( 64 | state.clone(), 65 | jrsonnet_evaluator::trace::PathResolver::new_cwd_fallback(), 66 | ); 67 | context_initializer.add_native("provide.vault", provide_vault::INST); 68 | context_initializer.add_ext_var("appId".into(), "fake".into()); 69 | state.set_context_initializer(context_initializer); 70 | 71 | state 72 | } 73 | 74 | struct ImportResolver { 75 | inner: jrsonnet_evaluator::FileImportResolver, 76 | imported: ImportedSet, 77 | } 78 | 79 | impl ImportResolver { 80 | fn new(imported: ImportedSet) -> Self { 81 | Self { 82 | inner: jrsonnet_evaluator::FileImportResolver::default(), 83 | imported, 84 | } 85 | } 86 | } 87 | 88 | impl jrsonnet_gcmodule::Trace for ImportResolver {} 89 | 90 | impl jrsonnet_evaluator::ImportResolver for ImportResolver { 91 | fn load_file_contents( 92 | &self, 93 | resolved: &jrsonnet_parser::SourcePath, 94 | ) -> jrsonnet_evaluator::Result> { 95 | if let Some(path) = resolved.path() { 96 | self.imported.borrow_mut().insert(path.to_path_buf()); 97 | } 98 | self.inner.load_file_contents(resolved) 99 | } 100 | 101 | fn as_any(&self) -> &dyn std::any::Any { 102 | self 103 | } 104 | 105 | fn resolve( 106 | &self, 107 | path: &std::path::Path, 108 | ) -> jrsonnet_evaluator::Result { 109 | self.inner.resolve(path) 110 | } 111 | 112 | fn resolve_from( 113 | &self, 114 | from: &jrsonnet_parser::SourcePath, 115 | path: &str, 116 | ) -> jrsonnet_evaluator::Result { 117 | self.inner.resolve_from(from, path) 118 | } 119 | } 120 | --------------------------------------------------------------------------------