Skip to content

Instantly share code, notes, and snippets.

Avatar

Mohammad AbuShady coalwater

View GitHub Profile
@coalwater
coalwater / gist:2e5c5fbe69edf3defcbd3cae09573547
Created Nov 14, 2018
Mounting another linux system on your already running system
View gist:2e5c5fbe69edf3defcbd3cae09573547
# run as root or add sudo
mount /dev/sdX /mnt
mount --rbind /dev /mnt/dev
mount --make-rslave /mnt/dev
mount -t proc /proc /mnt/proc
mount --rbind /sys /mnt/sys
mount --make-rslave /mnt/sys
mount --rbind /tmp /mnt/tmp
chroot /mnt /bin/bash
source /etc/profile
@coalwater
coalwater / colors.sh
Created May 26, 2016
List the terminal colors
View colors.sh
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
View .kitchen.yml
---
driver:
name: docker
use_sudo: false
platforms:
- name: centos
driver_config:
image: centos:latest
provision_command: curl -L https://www.opscode.com/chef/install.sh | bash
@coalwater
coalwater / null_book.rb
Created May 9, 2015
null objects pattern
View null_book.rb
class NullBook
def title
'No book exists'
end
end
@coalwater
coalwater / sandbox.rb
Last active Aug 29, 2015
rails console tips
View sandbox.rb
bin/rails c --sandbox
User.destroy_all
exit
@coalwater
coalwater / logger_levels.rb
Last active Aug 29, 2015
Active Record logger examples
View logger_levels.rb
ActiveRecord::Base.logger.level = :debug
ActiveRecord::Base.logger.level = :info
ActiveRecord::Base.logger.level = :warn
ActiveRecord::Base.logger.level = :error
ActiveRecord::Base.logger.level = :fatal
ActiveRecord::Base.logger.level = :unknown
@coalwater
coalwater / basic_read.rb
Created Apr 2, 2015
Using rails low level caching
View basic_read.rb
Rails.cache.read 'my_caching_key'
@coalwater
coalwater / download_and_install.sh
Last active Aug 29, 2015
installing elasticsearch
View download_and_install.sh
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.2.deb
sudo dpkg -i elasticsearch-1.5.2.deb
@coalwater
coalwater / manual_rollback.rb
Last active Aug 29, 2015
rails transactions
View manual_rollback.rb
ActiveRecord::Base.transaction do
raise AcitveRecord::Rollback if something_bad_happens
end
You can’t perform that action at this time.