Skip to content

Instantly share code, notes, and snippets.

View harrymahardhika's full-sized avatar

Harry Mahardhika harrymahardhika

View GitHub Profile
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
def current_user
@current_user ||= User.find_by_auth_token(cookies.signed[:auth_token]) if cookies[:auth_token]
end
def authenticate_user!
redirect_to login_url unless current_user
@harrymahardhika
harrymahardhika / airports.sql
Created August 23, 2018 06:27 — forked from tanerdogan/airports.sql
airports.sql - airport list (total 8800 airport)
This file has been truncated, but you can view the full file.
DROP TABLE IF EXISTS `airports`;
CREATE TABLE IF NOT EXISTS `airports` (
`code` varchar(50) COLLATE utf8_turkish_ci DEFAULT NULL,
`name` varchar(200) COLLATE utf8_turkish_ci DEFAULT NULL,
`cityCode` varchar(50) COLLATE utf8_turkish_ci DEFAULT NULL,
`cityName` varchar(200) COLLATE utf8_turkish_ci DEFAULT NULL,
`countryName` varchar(200) COLLATE utf8_turkish_ci DEFAULT NULL,
`countryCode` varchar(200) COLLATE utf8_turkish_ci DEFAULT NULL,
@harrymahardhika
harrymahardhika / zsh.md
Created August 25, 2017 04:39 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@harrymahardhika
harrymahardhika / tmux.md
Created May 27, 2017 05:37 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@harrymahardhika
harrymahardhika / fix_zsh_history.sh
Created February 23, 2017 15:52 — forked from kolach/fix_zsh_history.sh
Fix for zsh: corrupt history file /home/marc/.zsh_history
#!/bin/sh
# Borrowed from http://marcparadise.com/blog/2013/09/21/how-to-fix-a-corrupt-history-file/
# If you ever see a message like this upon starting a new shell
# zsh: corrupt history file /home/marc/.zsh_history
# here is a quick fix
cd ~
mv .zsh_history .zsh_history_bad
strings .zsh_history_bad > .zsh_history
# And reload history
fc -R .zsh_history