Skip to content

Instantly share code, notes, and snippets.

@beaugaines
beaugaines / gist:7ce9dc386662e820a0cdab6410337267
Last active July 13, 2024 21:02
Working setup for Manning 'Chatbot with Llama' project
# I got this working on a AWS EC2 G5 extra large instance with 80gb of storage

# Install required build packages and Python libraries
sudo ACCEPT_EULA=Y apt-get update
sudo ACCEPT_EULA=Y apt-get upgrade
sudo apt-get install software-properties-common build-essential libopenblas-dev ninja-build pkg-config cmake-data clang nvidia-cuda-toolkit
sudo apt-get install git git-lfs curl wget zip unzip
git lfs install
<body id="collection-5670de8aa128e6d40ec12999" class="transparent-header enable-nav-button nav-button-style-outline nav-button-corner-style-pill banner-button-style-solid banner-button-corner-style-pill banner-slideshow-controls-arrows meta-priority-date center-entry-title--meta hide-entry-author hide-list-entry-footer center-navigation--info event-show-past-events event-thumbnails event-thumbnail-size-32-standard event-date-label event-list-show-cats event-list-date event-list-time event-list-address event-icalgcal-links event-excerpts gallery-design-grid aspect-ratio-auto lightbox-style-light gallery-navigation-bullets gallery-info-overlay-show-on-hover gallery-aspect-ratio-32-standard gallery-arrow-style-no-background gallery-transitions-fade gallery-show-arrows gallery-auto-crop product-list-titles-under product-list-alignment-center product-item-size-11-square product-image-auto-crop product-gallery-size-11-square show-product-price show-product-item-nav product-social-sharing newsletter-style-dark hide-
report = 'code_report_' + Time.now.strftime('%Y-%m-%d')
`rubocop app spec lib config --format simple --out #{report}.txt`
`echo "\n\n\nCANE REPORT\n\n-----------" >> #{report}.txt`
`cane >> #{report}.txt`
`echo "\n\n\nSANDI METER REPORT\n\n-----------" >> #{report}.txt`
`sandi_meter -d >> #{report}.txt`
@beaugaines
beaugaines / wiki_policy.rb
Created November 15, 2017 21:32
wiki policy refactor
class WikiPolicy < ApplicationPolicy
attr_reader :user, :wiki
def initialize(user, wiki)
@user = user
@wiki = wiki
end
def update?
user.present?
@beaugaines
beaugaines / stories.rb
Created October 7, 2017 20:22
Sinatra stories app
require 'sinatra'
get '/' do
erb :index
end
__END__
@@index
def tiaosheng(failed_counter)
jumps = []
[*1..60].map do |s|
if failed_counter.include?(s)
jumps << s << s << s << s
else
jumps << s
end
end
jumps[59]
class TopicsController < ApplicationController
before_action :require_sign_in, except: [:index, :show]
before_action :authorize!, except: [:index, :show]
def index
@topics = Topic.all
end
def new
@topic = Topic.new

Checkpoint:

git checkout -b branch-name
git status (use often as needed)
git add .
git commit -m "Description"

git checkout master
git merge branch-name
<% flash.each do |k,v| %>
<div class="alert alert-<%= k == 'notice' ? 'info' : 'danger' %> fade in">
<button class="close" data-dismiss="alert">
<i class="fa fa-fw fa-info"></i>
<strong><Info><%= k %>!</strong> <%= raw(v) %>
</button>
</div>
<% end %>
@beaugaines
beaugaines / show.html.erb
Created July 8, 2016 17:18
complete items with checkbox
<% @items.each do |item| %>
<p>
<%= item.name %>
<%= form_for [current_user, item], method: :delete do |f| %>
<%= check_box_tag :complete, nil, false, onclick: "this.form.submit()" %>
<%= label_tag :complete, 'Complete' %>
<% end %>
</p>
<% end %>