Skip to content

Instantly share code, notes, and snippets.

View sainu's full-sized avatar
😄
Let's make it!

sainu sainu

😄
Let's make it!
View GitHub Profile
@sainu
sainu / .vimrc
Created March 23, 2018 15:05
vimrc for server os
set fenc=utf-8
set nobackup
set noswapfile
set autoread
set hidden
set showcmd
set number
set smartindent
set showmatch
set laststatus=2
@sainu
sainu / download-file.js
Created March 19, 2018 19:41 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@sainu
sainu / ResizeTextarea.js
Last active January 24, 2018 17:41
textareaを中身に応じて自動リサイズする ref: https://qiita.com/sainu__/items/4b3dab630688e6a3803f
/*
* How to use
*
* import ResizeTextarea from './path/to/ResizeTextarea';
* let textarea = document.querySelector('#textarea');
* const resizeTextarea = new ResizeTextarea(textarea);
* textarea.addEventListener('input', () => {
* resizeTextarea.resize();
* });
*/
@sainu
sainu / .tmux.conf
Last active April 21, 2023 11:58
tmuxを2.6にアップグレードした時に bind-key と vi-copy 周りが動作しなくなったので.tmux.confの内容を変更した時の差分
-bind-key -t vi-copy v begin-selection
-bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
-unbind -t vi-copy Enter
-bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
+bind-key -T copy-mode-vi v send-keys -X begin-selection
+bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
+bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
@sainu
sainu / README.md
Last active November 25, 2017 04:21
HTMLを含んだcontenteditable内のカーソル位置取得

HTMLを含んだcontenteditable内のカーソル位置取得 DEMO

@sainu
sainu / README.md
Last active November 14, 2017 15:20
contenteditableの最初の行をタグでラップさせる
@sainu
sainu / ImeChecker.js
Created November 14, 2017 14:37
日本語入力が確定しているかどうかを判定するクラス
/*
* How to use in Vue
* export default {
* template: `
* <input type="text" @keydown="imeChecker.keydownEvent" @keyup.enter="keyupEvent">
* `,
* data() {
* return {
* imeChecker: new ImeChecker()
* }
@sainu
sainu / file0.sh
Last active April 15, 2017 10:15
Dropbox/.ssh/の鍵ファイルを全て~/.sshにシンボリックリンクを貼るスクリプトを書いた ref: http://qiita.com/saino-katsutoshi/items/216f594468d0b79bdb54
$ pwd
/path/to/Dropbox/.ssh
$ tree .
.
├── config
├── id_hoge_rsa
├── id_hoge_rsa.pub
└── hoge.pem
@sainu
sainu / useful_linux_cmd.md
Last active April 15, 2017 08:57
便利なlinuxコマンド集

ファイル名検索

現在のフォルダ直下に存在する全てのファイル名を取得する

$ find . -maxdepth 1 -type f | sed "s!^.*/!!"

特定のファイル名を除いて取得
ex) hoge.rb以外のファイル名を取得

@sainu
sainu / googleAnalyticsSlackNotifier.js
Last active December 25, 2016 07:06
google analyticsのデータをslackに通知するGASを作成しました。
// google analytics api reference: https://developers.google.com/apps-script/advanced/analytics
function runReport(profileId, startDate, endDate) {
var tableId = 'ga:' + profileId;
var metric = 'ga:pageviews';
var options = {};
var report = Analytics.Data.Ga.get(tableId, startDate, endDate, metric, options);
return report;
// 以下Spread Sheetに出力