Skip to content

Instantly share code, notes, and snippets.

@pirey
pirey / auxiliary.js
Created December 2, 2018 16:26
Collection of javascript helper functions
// convert FormData to Object
export const fd2obj = (fd) => Array.from(fd.entries()).reduce((acc, i) => Object.assign({}, acc, { [i[0]]: (acc[i[0]] || Array.isArray(acc[i[0]])) ? [].concat(acc[i[0]]).concat(i[1]) : i[1] }), {})
@pirey
pirey / git-intro.md
Last active November 15, 2021 17:46
Yet another introduction to git

Keep track of our works (man git)

Git is a command line application, meaning it's an application that we run in the terminal / command prompt.

The purpose of git is to keep track of our works. As a programmer, what we usually do at work is write code. With git, we can see what are the things that we added, edited, or removed from our project's source code.

By default, git doesn't just track everything we do to our source code. Therefore we need to tell git which changes we made to the source code that we want to keep track later, as we discuss later.

Get a repo (git init, clone)

@pirey
pirey / select_all_count.sql
Created August 24, 2019 16:49
select row count for all tables in postgresql
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
@pirey
pirey / arch-pacstrap.md
Last active August 23, 2020 04:04
personal note for arch linux installation guide
@pirey
pirey / reddit-ip
Created November 17, 2019 03:26
reddit ip
151.101.129.140 i.redditmedia.com
52.34.230.181 www.reddithelp.com
151.101.65.140 g.redditmedia.com
151.101.65.140 a.thumbs.redditmedia.com
151.101.1.140 redditgifts.com
151.101.1.140 i.redd.it
151.101.1.140 old.reddit.com
151.101.1.140 new.reddit.com
151.101.129.140 reddit.com
151.101.129.140 gateway.reddit.com
!#/bin/sh
# search for PATTERN
rg PATTERN
# search for files containing PATTERN
rg -l PATTERN
# search for files
rg --files -g FILE_PATTERN
chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts
chmod 644 ~/.ssh/config
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/github_rsa
chmod 644 ~/.ssh/github_rsa.pub
chmod 600 ~/.ssh/mozilla_rsa
chmod 644 ~/.ssh/mozilla_rsa.pub
" vim-airline/vim-airline {{{
set laststatus=2
set noshowmode
let g:airline_powerline_fonts = 1
" powerline symbols
" let g:airline_left_sep = ''
" let g:airline_left_alt_sep = ''
" let g:airline_right_sep = ''
" let g:airline_right_alt_sep = ''
" let g:airline_left_sep = ''
@pirey
pirey / centos-7.sh
Last active March 21, 2020 16:16
personal note for setting up centos 7 for laravel deployment
#!/bin/sh
sudo yum update
sudo yum install vim
sudo yum install epel-release
sudo yum update
sudo yum install nginx
@pirey
pirey / react-build.sh
Created April 18, 2020 12:39
Script to build react app as archive
#!/bin/sh
CURRENT_TAG=$(git tag --points-at HEAD)
CURRENT_DATE=$(date +%Y-%m-%d_%H%M%S)
rm -rf ./build
npm run build
mkdir -p dist
cd build && tar -zcvf ../dist/build-${CURRENT_TAG}-${CURRENT_DATE}.tar.gz . && cd -