Skip to content

Instantly share code, notes, and snippets.

@isorsa
isorsa / install-latest-ruby-on-centos-7.sh
Created October 26, 2022 15:02
ruby latest setup for centos 7.x
#!/usr/bin/env bash
set -ex
toolset=devtoolset-7
yum install -y epel-release # EPEL repo
yum install -y centos-release-scl # shiny-new(er) compliers
# make sure there are no surprises installing from repos
grep -r gpgkey= /etc/yum.repos.d/ | cut -d= -f2 | xargs -L1 rpm --import
yum update -y # system update
# misc dev tools, but we're not going to use the ancient toolchain
@isorsa
isorsa / import_feed.rb
Created September 7, 2022 17:25
Ruby/Rails Challenge
require 'csv'
class User < ApplicationRecord
has_many :posts
has_many :comments
end
class Comment < ApplicationRecord
belongs_to :user
belongs_to :post

Access macOS localhost from IE or Edge within Parallels Desktop

This issue is so infuriating that I'm going to take some time to write about it.

  1. MOST IMPORTANT. Your local development server must be bound to IP address 0.0.0.0. Some do this by default, but many don't. You need to make sure that you run your local server with correct IP bindings. You may need to provide additional flags to your serve commands e.g. polymer serve --hostname domain.local, hugo serve --bind 0.0.0.0. If you use a named domain like domain.local, it has to be defined in /etc/hosts and pointing at 0.0.0.0.

  2. My Parallels setting is using Shared Network, nothing special there.

  3. Open macOS Terminal and type ifconfig. Look for the value under vnic0 > inet. It is typically 10.211.55.2.

@isorsa
isorsa / Rakefile
Created March 3, 2022 14:25 — forked from schickling/Rakefile
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@isorsa
isorsa / table_to_csv.rb
Created January 20, 2016 09:10 — forked from sandys/table_to_csv.rb
convert a html table to CSV using ruby
# run using ```rvm jruby-1.6.7 do jruby "-J-Xmx2000m" "--1.9" tej.rb```
require 'rubygems'
require 'nokogiri'
require 'csv'
f = File.open("/tmp/preview.html")
doc = Nokogiri::HTML(f)
csv = CSV.open("/tmp/output.csv", 'w',{:col_sep => ",", :quote_char => '\'', :force_quotes => true})