Skip to content

Instantly share code, notes, and snippets.

@rocLv
rocLv / custom_logger.rb
Created April 7, 2017 10:34 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@rocLv
rocLv / 0_reuse_code.js
Created March 31, 2017 08:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rocLv
rocLv / upgrade_pg.sh
Last active December 12, 2018 02:44 — forked from edib/upgrade_pg.sh
Upgrade PostgreSQL 9.3 to 9.6 on Ubuntu 16.04
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6 postgresql-server-dev-9.6 postgresql-contrib-9.6 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
@rocLv
rocLv / imagemagick-install-steps
Last active March 1, 2017 04:07 — forked from rodleviton/imagemagick-install-steps
Installing Image Magick on Ubuntu 14.04
sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall
@rocLv
rocLv / Rails Controller.md
Created February 22, 2017 10:27 — forked from stevenyap/Rails Controller.md
Rails controller cheatsheet

Flash

# supports only notice and alert by default
# the rest has to go into flash hash
redirect_to :index, notice: "success"
redirect_to :new, notice: "errors"
redirect_to :new, flash: { success: "yeah" }
flash[:info] = "updated"
@rocLv
rocLv / postgresql_configuration_on_ubuntu_for_rails.md
Created December 4, 2016 14:27 — forked from p1nox/postgresql_configuration_on_ubuntu_for_rails.md
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev
@rocLv
rocLv / country-code-to-currency-code-mapping.csv
Created June 17, 2016 09:55 — forked from HarishChaudhari/country-code-to-currency-code-mapping.csv
Country, Country Code, Currency code mapping in CSV format Taken from https://gist.github.com/304261 Contains 249 countries.
Country CountryCode Currency Code
New Zealand NZ New Zealand Dollars NZD
Cook Islands CK New Zealand Dollars NZD
Niue NU New Zealand Dollars NZD
Pitcairn PN New Zealand Dollars NZD
Tokelau TK New Zealand Dollars NZD
Australian AU Australian Dollars AUD
Christmas Island CX Australian Dollars AUD
Cocos (Keeling) Islands CC Australian Dollars AUD
Heard and Mc Donald Islands HM Australian Dollars AUD
@rocLv
rocLv / awesome_report_test.rb
Created June 12, 2016 11:26 — forked from sideshowcoder/awesome_report_test.rb
Helper for testing rake tasks in rails using minitest.
require 'test_helper'
# testing rake task app:awesome_report
# defined in file lib/tasks/app/awesome_report.rake
describe 'App::AwesomeReportTaskTest' do
it 'generates the awesomeness report' do
subject.invoke
assert File.exists?('awesomeness_report.csv')
end
@rocLv
rocLv / index.html
Created May 2, 2016 04:48 — forked from anonymous/index.html
JS Bin redux react todo list example <filter todos> // source http://jsbin.com/gigihur
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="redux react todo list example <filter todos>">
<script src="https://fb.me/react-0.14.7.min.js"></script>
<script src="https://fb.me/react-dom-0.14.7.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.0.4/redux.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
@rocLv
rocLv / index.html
Created May 1, 2016 02:31 — forked from anonymous/index.html
JS Bin redex react todo list example add todo // source http://jsbin.com/wivuyi
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="redex react todo list example add todo">
<script src="https://fb.me/react-0.14.7.min.js"></script>
<script src="https://fb.me/react-dom-0.14.7.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.0.4/redux.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>