Skip to content

Instantly share code, notes, and snippets.

@yalab
yalab / post-checkout
Created January 14, 2018 05:43
ブランチを切り替えて Gemfile.lock や yarn.lock に変更があったら勝手に install する git hook
#!/bin/bash
PREV=$1
POST=$2
TRUE="1"
FALSE="0"
isChanged (){
FILE_CHANGED="$(git log $PREV..$POST --pretty='format:' --name-only | grep $1)"
if [ -n "$FILE_CHANGED" ];then
echo $TRUE
@yalab
yalab / find_copy_and_paste_method.rb
Created March 13, 2019 06:59
find method that write by copy and paste.
# USAGE find_copy_and_paste_method.rb MOD_NAME
Rails.application.eager_load!
base_class = ARGV[0].constantize
def all_subclasses(klasses)
if klasses == []
klasses
else
klasses.map{|k| all_subclasses(k.subclasses) << klasses }.flatten
end
end

別ウインドウの pts を調べる

vagrant@ubuntu-xenial:~$ w
 07:50:17 up 27 min,  3 users,  load average: 1.17, 1.12, 0.95
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
vagrant  pts/0    10.0.2.2         07:23   26:25   0.30s  0.00s /bin/sh -c set 
vagrant  pts/1    10.0.2.2         07:24    1.00s  0.06s  0.00s w
vagrant  pts/2    10.0.2.2         07:25   57.00s  0.04s  0.04s -bash
@yalab
yalab / sprockets-extend.rb
Created April 7, 2018 09:29
User definition sprockets function
module Sprockets::SassProcessor::Functions
def cdn_path(path, options={})
prefix = if (asset_host = Rails.application.config.action_controller.asset_host)
asset_host.scan(%r(/[^/]+\Z)).first
else
""
end
prefixed = prefix + asset_path(path, options).to_s
Sass::Script::String.new(prefixed)
end
wpa_passphrase SSID
# => write your WIFI PASSWORD then show encoded password
iwconfig wlan0 essid SSID enc s:ENCODED_PASSWORD
(defun rb-strkeytosym (start end)
"ruby Hash key string to symbol"
(interactive "r")
(replace-regexp "\"\\([a-z_]+\\)\"=>" "\\1: " nil start end))
(defun rb-htmlopttoerb (start end)
"html attreibute to erb option"
(interactive "r")
(replace-regexp " \\([a-z_]+\\)=" ", \\1: " nil start end))
@yalab
yalab / process.md
Created November 20, 2017 09:02
LinuxKernel勉強会2017-11.md

プロセス

プロセスってどうやって起動するのか調べる

linux kernel process invoke で検索すると http://www.tldp.org/LDP/tlk/kernel/processes.html

Linux の process とは task_struct 構造体の事で、task vector に 512 個まで格納される

process と task の違い?

スタッフ
1, yuukyun
2,yamazoeakiyo
3,
4,morisaki
5, higaki
6, aki
7, kyara
8,
@yalab
yalab / iptables.md
Created September 24, 2017 07:32
iptables の設定

iptables の設定

# apt-get install iptables-persistent
# cd /etc
# git add -A
# git commit -m 'apt-get install iptables-persistent'
# vi /root/iptables.sh
FROM alpine
MAINTAINER yalab <rudeboyjet@gmail.com>
RUN apk --update --no-cache add alpine-sdk ncurses-dev bc linux-headers perl
ENV ARCH="x86_64"
RUN git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git /linux
WORKDIR /linux