Skip to content

Instantly share code, notes, and snippets.

@hieunguyentrung
hieunguyentrung / gist:2c87c3d2814f0c79a8b88676e554482d
Last active February 11, 2017 09:47
Install VirtualBox Guest Additions on a CentOS 7 via command line mode
# yum update
# yum install gcc make kernel-devel bzip2
# reboot
# mkdir -p /media/cdrom
# mount /dev/sr0 /media/cdrom
# sh /media/cdrom/VBoxLinuxAdditions.run

CentOS 7

1. Disable SE Linux

sudo vi /etc/sysconfig/selinux

Then change the directive SELinux=enforcing to SELinux=disabled
Reboot server.

2. Create deploy user

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
echo deb https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt-get update
sudo apt-get install jenkins
sudo service jenkins start
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
class MyController < ApplicationController
def options
options = {}
available_option_keys = [:first_option, :second_option, :third_option]
all_keys = params.keys.map(&:to_sym)
set_option_keys = all_keys & available_option_keys
set_option_keys.each do |key|
options[key] = params[key]
end
options

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' WITH GRANT OPTION;

Stop mysqld and restart it with the --skip-grant-tables option.
Connect to the mysqld server with just: mysql (i.e. no -p option, and username may not be required).

Issue the following commands in the mysql client:
@hieunguyentrung
hieunguyentrung / mysql-docker.sh
Created July 26, 2017 06:54 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
defaults write .GlobalPreferences com.apple.mouse.scaling -1
require 'active_record/connection_adapters/abstract_mysql_adapter'
module ActiveRecord
module ConnectionAdapters
class AbstractMysqlAdapter
NATIVE_DATABASE_TYPES[:string] = { :name => "varchar", :limit => 191 }
end
end
end
def dirReduc(arr)
dir = {"NORTH" => "SOUTH", "SOUTH" => "NORTH", "WEST" => "EAST", "EAST" => "WEST"}
length = arr.length
result = []
arr.each do |w|
if result.last != dir[w]
result << w
else
result.pop
end