Skip to content

Instantly share code, notes, and snippets.

View coalwater's full-sized avatar

Mohammad AbuShady coalwater

  • Amsterdam, Netherlands
  • 02:54 (UTC +01:00)
View GitHub Profile
@coalwater
coalwater / gist:2e5c5fbe69edf3defcbd3cae09573547
Created November 14, 2018 12:54
Mounting another linux system on your already running system
# 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
#!/bin/bash
ls | dmenu
@coalwater
coalwater / colors.sh
Created May 26, 2016 09:16
List the terminal colors
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
---
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 11:25
null objects pattern
class NullBook
def title
'No book exists'
end
end
@coalwater
coalwater / sandbox.rb
Last active August 29, 2015 14:20
rails console tips
bin/rails c --sandbox
User.destroy_all
exit
@coalwater
coalwater / logger_levels.rb
Last active August 29, 2015 14:19
Active Record logger examples
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 April 2, 2015 16:06
Using rails low level caching
Rails.cache.read 'my_caching_key'
@coalwater
coalwater / download_and_install.sh
Last active August 29, 2015 14:16
installing elasticsearch
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 August 29, 2015 14:16
rails transactions
ActiveRecord::Base.transaction do
raise AcitveRecord::Rollback if something_bad_happens
end