Skip to content

Instantly share code, notes, and snippets.

View willywg's full-sized avatar
🏠
Working from home

William Wong Garay willywg

🏠
Working from home
View GitHub Profile
@rothgar
rothgar / install-tmux
Last active April 5, 2023 06:53 — forked from ekiara/how_to_install_tmux_on_centos
Install tmux 1.9 on rhel/centos 6
# Install tmux on Centos release 6.5
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
@servel333
servel333 / db_seeds.rb
Last active March 1, 2024 21:13
Rails seeds for environments
## db/seeds.rb
['all', Rails.env].each do |seed|
seed_file = Rails.root.join('db', 'seeds', "#{seed}.rb")
if File.exists?(seed_file)
puts "*** Loading #{seed} seed data"
require seed_file
end
seed_dir = Rails.root.join('db', 'seeds', seed)
@fabianvelizok
fabianvelizok / gist:c929c8edaa3a4d6a5873
Last active February 27, 2024 22:34
devise views to slim
rails generate devise:views
gem install html2slim
for file in app/views/devise/**/*.erb; do erb2slim $file ${file%erb}slim && rm $file; done
@erichrobinson
erichrobinson / README.md
Last active February 24, 2024 08:32
SwitchResX Configuration

#SwitchResX Settings for LG 21:9 UltraWide

SwitchResX is a utility that allows users to override the default resolution settings in OSX. For more information, including download links, vist http://www.madrau.com/ .

##Disabling System Integrity Protection (SIP)

If you are running OSX 10.11 or higher, SIP must be disabled. To disable SIP do the following:

  • Boot into the recovery partition by pressing CMD + R when starting up your Mac.
  • Once in recovery mode, open a terminal window.
  • Type the command csrutil disable
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active April 24, 2024 22:56
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@zentetsukenz
zentetsukenz / ruby_on_rails_deployment.md
Last active September 22, 2023 18:32
Deploy Ruby on Rails application with Docker Compose and Capistrano with ease

Docker

Files and Folders.

|
|\_ app
|...
|\_ docker
| |
@willywg
willywg / devise_helper.rb
Last active November 5, 2016 15:46 — forked from seyhunak/devise_helper.rb
Devise Error Messages with Bootstrap 3 style
# /app/helpers/devise_helper.rb
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t('errors.messages.not_saved',
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
@carlosramireziii
carlosramireziii / attached_validator.rb
Last active April 10, 2024 11:11
A validator and RSpec matcher for requiring an attachment using Active Storage
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
end
end
@alexrudall
alexrudall / #ChatGPT Streaming.md
Last active April 17, 2024 01:12
ChatGPT streaming with ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind!

How to add ChatGPT streaming to your Ruby on Rails 7 app!

This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!

Alt Text

First, add the ruby-openai gem! Needs to be at least version 4. Add Sidekiq too.