Skip to content

Instantly share code, notes, and snippets.

View skomma's full-sized avatar

Syunsuke Komma skomma

View GitHub Profile
@justalever
justalever / validate_array_datatype.rb
Created January 3, 2020 03:08
Validate an array data type in Ruby on Rails using a custom validator - PostGresQL allows arrays as a DB type.
# Define the validator
# app/validators/array_validator.rb
class ArrayValidator < ActiveModel::EachValidator
def validate_each(record, attribute, values)
Array(values).each do |value|
options.each do |key, args|
validator_options = { attributes: attribute }
validator_options.merge!(args) if args.is_a?(Hash)
@shunirr
shunirr / criminal_jc.md
Last active December 25, 2024 04:13
女子中学生チケット詐欺事件

criminal_jc

@voluntas
voluntas / shiguredo_product.rst
Last active May 21, 2024 13:17
時雨堂自社製品コトハジメ

マージ済みのリモートブランチを全て削除

git branch -r --merged master | grep -v -e master -e develop | sed -e 's% *origin/%%' | xargs -I% git push --delete origin %
  1. remote の master に merge済み の branch をすべて表示して
  2. master と develop は消えてほしくないので除外して
  3. origin/ を削除して
  4. xargs (-I% % で ブランチ名を渡しつつ、全て削除する)
@kyledrake
kyledrake / gist:d7457a46a03d7408da31
Last active October 22, 2023 12:25
Creating a self-signed SSL certificate, and then verifying it on another Linux machine
# Procedure is for Ubuntu 14.04 LTS.
# Using these guides:
# http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/
# https://turboflash.wordpress.com/2009/06/23/curl-adding-installing-trusting-new-self-signed-certificate/
# https://jamielinux.com/articles/2013/08/act-as-your-own-certificate-authority/
# Generate the root (GIVE IT A PASSWORD IF YOU'RE NOT AUTOMATING SIGNING!):
openssl genrsa -aes256 -out ca.key 2048
openssl req -new -x509 -days 7300 -key ca.key -sha256 -extensions v3_ca -out ca.crt
@okunishinishi
okunishinishi / Remove all git tags
Created March 8, 2014 03:12
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d
@vjt
vjt / copy-from-time-machine.sh
Last active January 29, 2025 13:27
Copy data from a Time Machine volume mounted on a Linux box.
#!/bin/bash
#
# Copy data from a Time Machine volume mounted on a Linux box.
#
# Usage: copy-from-time-machine.sh <source> <target>
#
# source: the source directory inside a time machine backup
# target: the target directory in which to copy the reconstructed
# directory trees. Created if it does not exists.
#
@masaakif
masaakif / return_every_80chars.txt
Created January 28, 2013 11:24
Vimの正規表現で、80文字ごとに改行する
:%s/\(.\{80}\)/\1\r/g
@narusemotoki
narusemotoki / tailer.py
Created July 30, 2012 15:30
日付などでファイルが切り替わるログをtailで表示します.新しいファイルができると,そちらに切り替わります.引数でログファイルが置かれるディレクトリを指定してください.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import time
import subprocess
from threading import Thread
import signal