Skip to content

Instantly share code, notes, and snippets.

👺
hmmmmmm

Kouji OKAMOTO motchang

👺
hmmmmmm
Block or report user

Report or block motchang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@motchang
motchang / bm.rb
Last active Jun 20, 2019
big set
View bm.rb
require 'set'
require 'benchmark'
Benchmark.bm 10 do |r|
limit = 65535*1000
r.report "to_a" do
(1..limit).to_a
end
r.report "to_set" do
(1..limit).to_set
@motchang
motchang / personal_motchang.json
Created Sep 14, 2018
左 Option を単体で押した時に英数キーにする
View personal_motchang.json
{
"title": "Personal rules @motchang",
"rules": [
{
"description": "左 Option を単体で押した時に英数キーにする",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_option",
View helm.el
;;; package --- Summary
;;; Commentary:
;;; Code:
(when (require 'helm-config nil t)
(helm-mode 1)
(global-set-key (kbd "M-x") #'helm-M-x)
(global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(global-set-key (kbd "C-x b") #'helm-mini)
View micropost.rb
class Micropost < ApplicationRecord
belongs_to :user
before_save { self.in_reply_to = reply_user }
default_scope -> { order(created_at: :desc) }
mount_uploader :picture, PictureUploader
validates :user_id, presence: true
validates :content, presence: true, length: { maximum: 140 }
validate :picture_size
scope :including_replies, ->(user) { where("user_id = ? OR (user_id IN (SELECT followed_id FROM relationships WHERE follower_id = ?) AND (in_reply_to = ? OR in_reply_to LIKE ?))", user.id, user.id, "", "%@#{user.id}\-#{user.name.sub(/\s/,'-').downcase}%" ) }
View deep_cache.rb
#
# USAGE1:
# User.find(1).deepcache.friends.count.fetch
#
# 上記のような呼び出しをすると以下のキーで Redis に問い合わせてなければキャッシュします。
# get deepcache:User:1:friends.count
#
# USAGE2:
# Category.deepcache.co_cats.where(slug: URI.encode(request_manager.params['slug'] || '')).limit(1).to_a.fetch
#
View crontab
5 9 * * * root /sbin/swapoff -a && /root/bin/mkswap.sh
@motchang
motchang / xvfb.sh
Last active Jun 17, 2016
/etc/init.d/xvfb
View xvfb.sh
#!/bin/bash
#
# Xvfb
#
# chkconfig: - 90 30
# description: Xvfb
# Source function library.
. /etc/init.d/functions
lockfile="/var/lock/subsys/xvfb"
@motchang
motchang / file0.txt
Created Jul 5, 2015
sakura に入れてるやつの configure オプション ref: http://qiita.com/motchang/items/ea9eb8149dec11e3096a
View file0.txt
./configure --prefix=/usr/local/etc/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-cc-opt='-O2 -g -m64 -mtune=generic' --with-http_stub_status_module
@motchang
motchang / file0.txt
Created Apr 14, 2015
ユーザーの公開鍵の一覧をつくる ref: http://qiita.com/motchang/items/cc1e979a2d1c712bc741
View file0.txt
ls -nd /home/* | sort -n -k 3,3 | awk '{ print $NF }' | while read user
do
echo ${user}
cat ${user}/.ssh/authorized_keys
done
@motchang
motchang / file0.txt
Last active Aug 29, 2015
aws cli で iam の group に紐づく user, policy を見る ref: http://qiita.com/motchang/items/aee024fad5e49ce872d1
View file0.txt
#!/bin/bash
aws iam list-groups | jq '.Groups[].GroupName' | xargs -I{} echo {} | \
while read g
do
echo ${g} "-------------------------------------------------------------";
aws iam get-group --group-name ${g} | jq '(.Group | {GroupName, Arn}), (.Users[] | {UserName, Arn})'
aws iam list-group-policies --group-name ${g} | jq '.PolicyNames[]' | xargs -I{} echo {} | \
while read p
You can’t perform that action at this time.