Skip to content

Instantly share code, notes, and snippets.

View majedbojan's full-sized avatar
We turn coffee into code

MaJeD BoJaN majedbojan

We turn coffee into code
View GitHub Profile
def csv(data)
arr = Array.wrap(data)
CSV.open(csv_filename, 'wb') do |csv|
keys = arr.first.keys
# header_row
csv << keys
arr.each do |hash|
csv << hash.values_at(*keys)
end
end
# config/initializers/string.rb
class String
##---------------bg Color-----------------##
def black; "\e[30m#{self}\e[0m" end
def red; "\e[31m#{self}\e[0m" end
def green; "\e[32m#{self}\e[0m" end
def brown; "\e[33m#{self}\e[0m" end
def blue; "\e[34m#{self}\e[0m" end
@majedbojan
majedbojan / ShellCommands.sh
Last active July 23, 2020 08:22
Daily Shell Commands
# Rotate logs
1) vim or nano /etc/logrotate.conf
2) Add these lines to the bottom of the file
/home/deploy/APPNAME/current/log/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
@majedbojan
majedbojan / install.sh
Last active July 16, 2020 08:20 — forked from mhmdAljefri/install.sh
Setup Ubuntu Server with Ngnix + MySQL + Redis + Git + RVM + Ruby 2.4.0 + Ruby On Rails
#!/bin/sh
# ngix + required packages
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install curl git-core nginx build-essential tcl8.5 -y
# mysql
# sudo apt-get install libmysqlclient-dev mysql-server