Skip to content

Instantly share code, notes, and snippets.

View chsh's full-sized avatar
👍
Love your code.

CHIKURA Shinsaku chsh

👍
Love your code.
View GitHub Profile
@chsh
chsh / ffx265.sh
Last active May 26, 2021 01:33
Aggregate pics to hevc(H.265). - ffmpeg encoding params for apple macbook with acceralation hardware.
#!/bin/bash
for arg; do
dir=${arg}
# ffmpeg -framerate 60 -i $dir/seq%06d.jpg -vf deflicker=s=10:m=2 -c:v hevc_videotoolbox -b:v 200000k -tag:v hvc1 $dir.mp4
ffmpeg -framerate 60 -pattern_type glob -i "$dir/seq*.jpg" -vf deflicker=s=10:m=2 -c:v hevc_videotoolbox -b:v 200000k -tag:v hvc1 $dir.mp4
done
@chsh
chsh / example.slim
Last active April 30, 2021 13:30
Idea: Writing Tailwind CSS with ruby's method chain.
body(class=tw.text.px_4.py_2.hover__text_gray_200)
button(class=tw.btn.btn_primary) CLICK!
@chsh
chsh / zoom_signature_generator.rb
Created April 1, 2021 13:50
Zoom Video SDK client signature generator.
require 'jwt'
def generate_instant_token(topic, password: '')
sdk_key = ENV['ZOOM_SDK_KEY']
sdk_secret = ENV['ZOOM_SDK_SECRET']
iat = Time.now.to_i
exp = iat + 60 * 60 * 2
@chsh
chsh / webloc2webarchive.rb
Last active March 14, 2021 01:35
Save webarchive using webloc file.
#!/usr/bin/env ruby
require 'tmpdir'
require 'shellwords'
webloc_file = ARGV[0]
webloc_ext = File.extname(webloc_file)
webarchive_file = webloc_file.gsub(/#{webloc_ext}$/, '.webarchive')
url = nil
@chsh
chsh / create_open_bds.rb
Last active January 12, 2021 22:44
Crawl all data using openBD API
class CreateOpenBds < ActiveRecord::Migration
def change
create_table :open_bds do |t|
t.string :isbn, null: false
t.jsonb :content
t.datetime :last_crawled_at
t.timestamps null: false
end
add_index :open_bds, :isbn, unique: true
add_index :open_bds, :content, using: :gin
@chsh
chsh / draw_barcode.js
Created February 20, 2015 15:12
Draw barcode using d3.
//= require d3
var height = 500;
var width = 800;
var margin_left = 20;
var xdim = 2;
var svgContianer = d3.select("body")
.append("svg")
.attr("width", width)
@chsh
chsh / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created October 20, 2019 11:14 — forked from shunchu/convert-seconds-into-hh-mm-ss-in-ruby.rb
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@chsh
chsh / detect_num_non_gray_colors.rb
Last active May 22, 2018 06:53
Detect num non gray colors using ImageMagick's convert command.
list = `convert 9784152097712_10.jpg -format %c histogram:info:`.split("\n")
rgbs = list.map { |line| $1 if line =~ /\s+#([\dA-F]+)\s+/ }
num_non_gray = rgbs.select { |rgb|
r = rgb[0,2]; g = rgb[2,2]; b = rgb[4,2]
r != g || g != b
}.count
num_non_gray > 0 # true: 正しい画像, false: (一色かどうかはわからないが)グレー画像
@chsh
chsh / responsivle_mediaqueries.sass
Created February 24, 2017 01:16
Responsive Media Queries example from "bulma"
// Responsiveness
$tablet: 769px !default
// 960px container + 40px
$desktop: 1000px !default
// 1152px container + 40
$widescreen: 1192px !default
// 960 and 1152 have been chosen because
// they are divisible by both 12 and 16
@chsh
chsh / Gemfile
Last active March 6, 2018 05:04
Allow to refer user related info using thread global `Current` (like CurrentAttributes in Rails 5.2 ;-)
gem 'request_store'