Skip to content

Instantly share code, notes, and snippets.

View uplus's full-sized avatar
🌏
Working from the earth

Yuto Ito uplus

🌏
Working from the earth
View GitHub Profile
@uplus
uplus / file0.txt
Created January 22, 2016 13:31
Ubuntu コマンドでサスペンド&ロックする ref: http://qiita.com/uplus_e10/items/203fb3297c784c669c9a
dbus-send --system --print-reply=literal --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend boolean:true
@uplus
uplus / file0.txt
Created March 6, 2016 15:46
virt-manager(KVM)で共有フォルダを使うには(Ubuntu15) ref: http://qiita.com/uplus_e10/items/91b64111d153fe8d7c1f
$ sudo apt-get install nfs-common nfs-kernel-server
@uplus
uplus / file0.vim
Created March 24, 2016 12:05
vimのコマンドライン補完を自作する。 ref: http://qiita.com/uplus_e10/items/294524fc9dd5063b6a3b
command! -nargs=1 -complete=customlist,{func} {cmd} {rep}
#include <stdio.h>
int main(){
int a = 0;
if (a == 0)
for(int i = 0; i < 10; ++i)
if (i % 2 == 0)
printf("even\n");
else if (i % 2 != 0)
function! s:bufdo(bufname, cmd) abort
let wn = bufwinnr(a:bufname)
if wn == -1
return 0
endif
exe wn 'wincmd w'
exe a:cmd
wincmd p
endfunction
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, const char* argv[]){
int n = argc == 1? 1: atoi(argv[1]);
if(n%15 == 0) cout << "FizzBuzz" << endl;
else if(n%3 == 0) cout << "Fizz" << endl;
@uplus
uplus / proxy-on.sh
Last active September 24, 2017 04:28
proxy-on () {
proxy="${1:? server:port}"
export http_proxy="${proxy}"
export https_proxy="${proxy}"
export ftp_proxy="${proxy}"
export rsync_proxy="${proxy}"
export all_proxy="${proxy}"
export HTTP_PROXY="${proxy}"
export HTTPS_PROXY="${proxy}"
export FTP_PROXY="${proxy}"
echo_color(){
color="${1}"
shift
echo -e "\e[38;5;${color}m${*}\e[00m"
}
@uplus
uplus / colors.sh
Last active December 13, 2016 13:25
colorso () {
local c
echo
for c in {000..255}
do
echo -n "\e[38;5;${c}m $c"
[ $(($c%16)) -eq 15 ] && echo
done
echo
}
function g:RubyBlockOneline(strs, cnt, def) abort
s/\v\s*do\s*(\|.*\|)?\_s*(.*)\_s*end/{\1 \2}
endfunction
function g:RubyBlockMultiline(strs, cnt, def) abort
let save_pos = getpos('.')
s/\v\s*\{(\|.*\|)?\_s*(.*)\_s*\}$/ do \1\r\2\rend
call feedkeys('3==')
call setpos('.', save_pos)
endfunction