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 / pg_pub_sub.rb
Last active April 4, 2024 11:58
PostgreSQL LISTEN/NOTIFY example for ruby
#
# A:
# pubsub = PgPubSub.new('channelname')
# pubsub.subscribe do |data|
# puts "data: #{data} is coming!"
# end
#
# B:
# pubsub = PgPubSub.new('channelname')
# pubsub.publish("hello world")
@chsh
chsh / Flat UI Colors.clr
Last active December 19, 2023 15:22
Some color pallets with Apple Color List (.clr) format
@chsh
chsh / mastodon-sources.md
Last active August 24, 2022 15:30
mastodonのソースコード一覧

mastodonのソースコード一覧

pawoo.netやfriends.nicoなどのように、大手企業がmastodonインスタンスを提供し始めています。 それぞれは独自の拡張を行い、魅力を高めています。 mastodonそのものはAGPLのため、改変したソースコードが入手できるようにする必要がありますが、その一覧があったらいいかなと思ってまとめることにしました。 とは言え、私が知っているのはごく一部。もしみかけたら @chsh@bookn.me へのメンションにてお知らせください。

インスタンス

提供会社(団体・個人) インスタンスURL ソースコードURL 本家masterからの差分 追加日
ピクシブ 🐘 https://pawoo.net/ :octocat: pixiv/mastodon/tree/pawoo 📊 2017/4/23
@chsh
chsh / git-issue
Created April 26, 2014 15:54
Create issue for GitLab and create task for Todoist same time.
#!/usr/bin/env ruby
require 'cgi'
gem 'gitlab'
gem 'todoist'
require 'gitlab'
require 'todoist'
class IssueCreator
@chsh
chsh / orders_controller_spec.rb
Created April 30, 2013 13:35
RSpec controller example
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
@chsh
chsh / to-circle.sh
Created April 14, 2022 05:10
Crop square image to circle.
#!/bin/bash
#
# usage: to-path.sh files(to crop circle)
#
for path in "$@"
do
convert $path \( +clone -threshold -1 -negate -fill white -draw "circle `identify -format %w $path | awk '{print $1/2}'`, `identify -format %h $path | awk '{print $1/2}'` `identify -format %w $path | awk '{print $1/2}'`, 0" \) -alpha Off -compose copy_opacity -composite circle-`basename $path`
done
@chsh
chsh / rials-template-with-good-job.rb
Created January 23, 2022 05:29
rails template with goo_job
# rails basic configuration
environment_development_data = <<CODE
config.action_mailer.default_url_options = { host: 'http://localhost:3000' }
config.active_job.queue_adapter = :good_job
CODE
environment environment_development_data, env: 'development'
environment_production_data = <<CODE
config.action_mailer.default_url_options = { host: 'SET-YOUR-SERVICE-HOST-HERE' }
@chsh
chsh / htpasswd_creator.rb
Last active November 23, 2021 15:35
Generate apache compatible htpasswd file using Ruby.
# generate apache compatible htpasswd file using Ruby.
require 'webrick'
if ARGV.size < 3
puts "usage: #{$0} password-file user password"
exit 1
end
# create htpassword instance
@chsh
chsh / hash_pathable.rb
Created July 10, 2021 23:46
Allow to lookup ruby's Hash using xpath like syntax.
# usage:
# hash = { a: 1, b: { x: 'y'}, c: [{m: 10, n: 2}, { m: 20, n: 3} ] }
# hash.path('/a') => 1
# hash.path('b/x') => 'y'
# hash.path('/c[0]/n') => 2
# hash.path('/not/existent/key') => nil
# GenericUtils
module GenericSupport
module Pathable
@chsh
chsh / view_component_helper.rb
Created June 4, 2021 11:54
ViewComonent helper using DSL flavor.
# usage:
# = render vc.path1.path2(:name, arg1: 'a')
# or
# = render vc('path1/path2/name', arg1: 'a')
module ViewComponentHelper
class VisualComponentChainer
def initialize
@nest = []