Skip to content

Instantly share code, notes, and snippets.

View mkhairi's full-sized avatar
🤜
Hello, Nice to meet you

Khairi Adnan mkhairi

🤜
Hello, Nice to meet you
View GitHub Profile
@mkhairi
mkhairi / check_record_dig
Created July 24, 2014 04:23
check match record from list and dig result
require 'csv'
@servers =["server_ip1","server_ip2", "server_ip3"]
list = {}
host = []
result = {}
CSV.foreach("mx_records.csv") do |row|

Commands examples

If the namespace is not used then the commands will perform on top of the default database. bundle exec rake db:create bundle exec rake db:migrate

By using the namespace we are going to use all the configuration for our alternate DB. bundle exec rake store:db:create bundle exec rake store:db:migrate

@mkhairi
mkhairi / index.md
Last active August 29, 2015 14:13 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

class ApplicationController < ActionController::Base
include Pundit
# Verify that controller actions are authorized. Optional, but good.
after_filter :verify_authorized, except: :index
after_filter :verify_policy_scoped, only: :index
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
private
# Permissions cheatsheet
`chmod [a]bcd`
* bit a — sticky:1/setgid:2/setuid:4 (optional, default: 0)
* bit b — owner | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7
* bit c — group | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7
* bit d — everyone | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7
note: only file/dir owner can chmod it
@mkhairi
mkhairi / server.md
Last active August 29, 2015 14:17 — forked from jtadeulopes/server.md

Update and upgrade the system

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo reboot
@mkhairi
mkhairi / activerecord_without_rails.rb
Created November 21, 2015 22:07 — forked from jimmynguyc/activerecord_without_rails.rb
ActiveRecord without Rails
require 'active_record'
require 'sqlite3'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "teachers.db"
)
# Migration
ActiveRecord::Schema.define do
@mkhairi
mkhairi / postgresql_cmd.md
Last active January 3, 2024 23:33
common postgresql command

#install

sudo apt-get install postgresql
sudo apt-get install libpq-dev
# for hstore
sudo apt-get install postgresql-contrib

##Modify /etc/postgresql/9.3/main/pg_hba.conf access control, local TCP access set to full trust

@mkhairi
mkhairi / dnsmasq OS X.md
Created July 18, 2016 07:10 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.

Requirements

Install

#respond remote true redirect
def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.js { redirect_to post_comments_path(@post), turbolinks: false}
#or
#redirect_to post_comments_path(@post), status: 303, turbolinks: false
else
format.html { render :new }