Skip to content

Instantly share code, notes, and snippets.

@yalab
yalab / bootstrap-memo.md
Last active July 20, 2022 20:29
rails5 + webpacker + bootstrap
$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add bootstrap@4.0.0-beta jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
@yalab
yalab / run-pod.sh
Last active September 6, 2021 00:03
#!/usr/bin/env bash
while getopts i:n: OPT
do
case "$OPT" in
"n") NAMESPACE="$OPTARG";
;;
"i") IMAGE="$OPTARG";
;;
esac

awk random extract line

$ awk '{ srand(); if(NR == (n = int(rand() * 124478))){print n, $0}}' FILEPATH
inquiries:
mail_address: Faker::Internet.email
nickname: Faker::Games::Pokemon.name
message_body: Faker::Lorem.paragraph
def fizz_buz(n)
return if n > 100
word = if n % 15 == 0
'fizz buz'
elsif n % 3 == 0
'fizz'
elsif n % 5 == 0
'buz'
end
puts word if word
#!/usr/bin/env ruby
require 'yaml'
def yaml_to_scalar(node, anchors={})
case node
when Psych::Nodes::Scalar
node.value
when Psych::Nodes::Document
node.children.map do |child|
yaml_to_scalar(child, anchors)
#!/usr/bin/env ruby
require 'csv'
body = if ARGV.length > 0
ARGF.read
else
STDIN.read
end
csv = CSV.new(body)
FROM ruby:2.6-alpine
ENV LANG=C.UTF-8 \
TZ=Asia/Tokyo \
ROOT_PATH=/app \
BUNDLE_JOBS=4 \
BUNDLE_PATH=/gems
VOLUME /gems
require 'open-uri'
require 'nokogiri'
ROOT_URI = 'https://www.google.com/search?source=hp&ei=K5YWXf3qBozK8wXsgqOYDQ&q=%E8%84%86%E5%BC%B1%E6%80%A7&oq=%E8%84%86%E5%BC%B1%E6%80%A7&gs_l=psy-ab.3..0j0i131j0l6.4101.7361..7805...2.0..0.74.1039.17......0....1..gws-wiz.....0..0i4j0i131i4j0i4i70i257.JdDB9CrU7j0'
google_html = nil
open(ROOT_URI) do |f|
google_html = f.read
end
google = Nokogiri::HTML(google_html)
REG_DOUBLE_SLASH = %r(\A//)
@yalab
yalab / README.md
Last active June 5, 2019 11:39
Bridge between C++ and ruby.

Try to implement C++ and ruby Bridge.

How to use

$ ruby extconf.rb
$ make
$ ruby test.rb