Skip to content

Instantly share code, notes, and snippets.

View X0nic's full-sized avatar

Nathan Lee X0nic

View GitHub Profile
@X0nic
X0nic / postgresql_configuration_on_ubuntu_for_rails.md
Created November 4, 2018 01:33 — 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
@X0nic
X0nic / application.rb
Last active October 12, 2018 04:33
How can I make the rails console prompt standout in production?
# config/application.rb
class Application < Rails::Application
console do
console_settings = File.join(Rails.root, "lib/console.rb")
if File.exists?(console_settings)
puts "Loading lib/console.rb ..."
ARGV.push "-r", root.join("lib/console.rb")
end
end
// I got tired of checking the webpage periodically.
var webPage = require('webpage');
var page = webPage.create();
page.onConsoleMessage = function(msg) {
console.log(msg);
}
page.open('http://www.memoryexpress.com/Products/MX64875', function(status) {
@X0nic
X0nic / commands.md
Created June 1, 2017 17:04
Helpful Habitat commands

Execute binary from package

# Exec inside studio
hab pkg exec myorigin/package <binary> <flags>
@X0nic
X0nic / convert-csv-to-json.rb
Created August 29, 2016 16:52
Convert a csv to json
#! /usr/bin/env ruby
require 'csv'
require 'json'
csv = CSV.parse(File.read(file_name).scrub, headers: true)
hash = csv.map{ |row| { code: row["Classification Code"], description: row["Classification Code Description English"] } }
json = hash.to_json
@X0nic
X0nic / step1.sh
Last active August 9, 2016 10:32
Habitat Rails Sample Comands
# hab studio enter
hab pkg export docker core/postgresql
hab pkg export docker core/ruby-rails-sample
# Terminal - 1
docker run -e HAB_POSTGRESQL='initdb_superuser_password = "rails_sample"' -p 9631:9631 -p 5432:5432 -v rails_pg_data:/hab/svc/postgresql/data -it core/postgresql
# Terminal - 2
@X0nic
X0nic / hab.sh
Created July 5, 2016 05:04
Install Habitat
wget -O hab.tar.gz 'https://api.bintray.com/content/habitat/stable/linux/x86_64/hab-$latest-x86_64-linux.tar.gz?bt_package=hab-x86_64-linux'
tar xf hab.tar.gz
cd hab-0.7.0-20160614230104-x86_64-linux/
sudo ./hab install core/hab
sudo ./hab pkg binlink core/hab hab
sudo useradd hab -u 42 -g 42 -d / -s /bin/sh -r
sudo groupadd -og 42 hab
@X0nic
X0nic / chruby_ruby-build.sh
Created June 19, 2016 05:09 — forked from havenwood/chruby_ruby-build.sh
On Debian, Ubuntu, or Mint: install Ruby with chruby and ruby-build
# Install apt-get packages:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
# Install chruby:
cd
wget https://github.com/downloads/postmodern/chruby/chruby-0.2.3.tar.gz
tar -xzvf chruby-0.2.3.tar.gz
cd chruby-0.2.3
sudo make install
@X0nic
X0nic / advcomp.rb
Created July 23, 2014 20:28
advcomp Homebrew Formula (advpng and advdef)
require 'formula'
class Advcomp < Formula
homepage 'http://advancemame.sourceforge.net/'
url 'http://downloads.sourceforge.net/project/advancemame/advancecomp/1.19/advancecomp-1.19.tar.gz'
sha256 'd594c50c3da356aa961f75b00e958a4ed1e142c6530b42926092e46419af3047'
def install
system "./configure"
system "make install"
@X0nic
X0nic / Vagrantfile
Created July 3, 2014 22:36
Vagrantfile loading run_list via json
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'multi_json'
Vagrant::Config.run do |config|
# Will load nodes/vagrant.json
VAGRANT_JSON = MultiJson.load(Pathname(__FILE__).dirname.join('nodes', 'vagrant.json').read)