Skip to content

Instantly share code, notes, and snippets.

View ryochin's full-sized avatar
🏠
Working at home

Ryo Okamoto ryochin

🏠
Working at home
View GitHub Profile
diff --git a/package.json b/package.json
index c0fc22b..6af8771 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
"sass": "^1.49.0",
"ts-loader": "^8.0.11",
"typescript": "^4.1.2",
+ "uglifyjs-webpack-plugin": "^2.2.0",
"urijs": "^1.19.7",
@ryochin
ryochin / my.css
Last active July 13, 2022 02:38
Typora custom css
/* https://theme.typora.io/doc/Write-Custom-Theme/ */
@import "night.css";
:root {
--text-color: #c8cfd6;
}
p {
color: #eeeeee;
@ryochin
ryochin / mackerel-plugin-puma-process
Last active May 6, 2021 05:36
mackerel plugin for puma processes
#!/bin/sh
#
# [plugin.metrics.puma_process]
# command = ["/usr/bin/mackerel-plugin-puma-process"]
if [ "$MACKEREL_AGENT_PLUGIN_META" = "1" ]; then
echo "# mackerel-agent-plugin"
cat << EOS
{
"graphs": {
@ryochin
ryochin / create_pkcs12_der.rb
Created October 24, 2020 09:49
Ruby: how to create .der (pkcs12) file
require 'openssl'
key = OpenSSL::PKey::RSA.new(File.read('./server_key.pem'))
cert = OpenSSL::X509::Certificate.new(File.read('./server_crt.pem'))
cacert = OpenSSL::X509::Certificate.new(File.read('./cacert.pem'))
pass = 'Chi3Lee9'
# encode
@ryochin
ryochin / epoch.rs
Created September 26, 2020 09:48
Rust: epoch
use std::time::{SystemTime, UNIX_EPOCH};
pub fn epoch() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
}
@ryochin
ryochin / gunzip.ex
Last active September 13, 2020 07:18
Elixir: gunzip
@spec gunzip(binary) :: {:ok, binary} | {:error, term}
def gunzip(data) when is_binary(data) do
try do
z = :zlib.open()
:ok = :zlib.inflateInit(z, 16 + 15)
result =
z
|> :zlib.inflate(data)
|> List.flatten()
@ryochin
ryochin / chunked_download.rb
Created May 21, 2020 01:39
[Ruby] roughly split & save the downloaded file.
#!/usr/bin/env ruby
# frozen_string_literal: true
# roughly split & save the downloaded file.
class Main
require 'uri'
require 'net/http'
require 'fileutils'
require 'thwait'
@ryochin
ryochin / colorize_rails.pl
Last active April 16, 2020 09:33
Colorize Rails production log (filter)
#!/usr/bin/env perl
use strict;
use warnings;
use Term::ANSIColor;
local $| = 1;
while (<STDIN>) {
my $line = $_;
@ryochin
ryochin / colorize_elixir.pl
Last active April 16, 2020 09:31
Colorize Elixir production log (filter)
#!/usr/bin/env perl
use strict;
use warnings;
use Term::ANSIColor;
local $| = 1;
while (<STDIN>) {
my $line = $_;
@ryochin
ryochin / remove_bom.exs
Last active January 18, 2021 11:37
[Elixir] remove UTF-8's BOM
@doc """
remove UTF-8's BOM
### Example
```
iex> "\\uFEFFHello" |> MyProject.Util.remove_bom()
"Hello"
```
"""