Skip to content

Instantly share code, notes, and snippets.

@t-cyrill
t-cyrill / pigz_rsync.sh
Last active January 16, 2024 00:23
rsync with pigz
#!/bin/bash
# Usage:
# rsync_pigz $REMOTE:$SRC $DEST
# rsync_pigz $SRC $REMOTE:$DEST
SRC=$1
DEST=$2
if [[ $SRC == *:* ]] && [[ $DEST == *:* ]]; then
echo "Cannot use remote both SRC and DEST"
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'gollum'
---
version: 0.4
# Global environment variables
env:
DEPLOY_TO: /tmp/deploy
networks:
local:
hosts:
@t-cyrill
t-cyrill / sort.php
Created March 1, 2016 05:43
php sort non ufo
<?php
$c = [
'6.9.3-1' => '10',
'6.9.3-10' => '10',
'6.9.3-2' => '10',
];
uksort($c, function ($a, $b) {
$a = preg_split('/[^0-9]/', $a);
$b = preg_split('/[^0-9]/', $b);
class Dir
class << self
alias_method :orig, :[]
end
def self.[](pattern)
binding.pry
self.orig(pattern)
end
end
@t-cyrill
t-cyrill / Gemfile
Last active January 29, 2016 16:59
Ruby ffi examples
source "https://rubygems.org"
gem 'ffi'
#!/bin/bash
# more safety iptables-rule checker script
# Example
# iptables -A INPUT -p tcp --dport 22 -j REJECT
iptables-save > /tmp/iptables.up.rules.bak
( sleep 3; iptables-restore < /tmp/iptables.up.rules.bak; echo "Discard changes") &
iptables-restore < /etc/iptables.up.rules
@t-cyrill
t-cyrill / preg_match_any.php
Created November 13, 2015 09:09
preg_match_any
/**
* preg_match
*
* @param array $patterns preg_matchに渡せるpattern文字列の配列
* @param string $subject 調べる文字列
*/
function preg_match_any(array $patterns, $subject) {
foreach ($patterns as $pattern) {
if (preg_match($pattern, $subject) === 1) return true;
}
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${application.home}/logs/application.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- Daily rollover without compression -->
<fileNamePattern>application-log-%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
@t-cyrill
t-cyrill / check_sidekiq_queue.sh
Created October 1, 2015 09:57
sidekiq enqueued check
#!/bin/bash
PROJECT_ROOT="/var/www/current"
WARN_LIMIT=64
CRIT_LIMIT=128
export RAILS_ENV=production
### rbenvを使う場合、RBENV_ROOTとPATHを適切に設定する必要がある
# export RBENV_ROOT="/usr/local/rbenv"
# export PATH="${RBENV_ROOT}/bin:${RBENV_ROOT}/shims:${PATH}"