Skip to content

Instantly share code, notes, and snippets.

View ben-gy's full-sized avatar
🏠
Working from home

Ben Richardson ben-gy

🏠
Working from home
View GitHub Profile
@kieranklaassen
kieranklaassen / chat_gpt_service.rb
Created December 5, 2022 14:07
Unofficial ChatGPT API Wrapper Ruby
# The ChatGptService class provides an easy way to integrate with the OpenAI ChatGPT API.
# It allows you to send and receive messages in a conversation thread, and reset the thread
# if necessary.
#
# Example usage:
# chat_gpt_service = ChatGptService.new(BEARER_TOKEN)
# response = chat_gpt_service.chat("Hello, how are you?")
# puts response
# # => {"message"=>
# # {"id"=>"8e78691a-1fde-4bd5-ad68-46b23ea65d8f",
@tiagoamaro
tiagoamaro / about.md
Last active May 15, 2021 00:04
searchkick-apartment-example-codes
@gbuesing
gbuesing / ml-ruby.md
Last active February 28, 2024 15:13
Resources for Machine Learning in Ruby

UPDATE a fork of this gist has been used as a starting point for a community-maintained "awesome" list: machine-learning-with-ruby Please look here for the most up-to-date info!

Resources for Machine Learning in Ruby

Gems

@itskingori
itskingori / application_controller.rb
Last active March 4, 2024 09:07 — forked from speed-of-light/application_controller.rb
How to handle exceptions like 401, 501, 404 in Rails
# As used with CanCan and Devise
class ApplicationController < ActionController::Base
protect_from_forgery
include ErrorResponseActions
rescue_from CanCan::AccessDenied, :with => :authorization_error
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found
before_filter :authenticate!
anonymous
anonymous / gist:5737b58edb271428ffdd
Created June 20, 2014 06:56
Rails selective loading of assets based on current controller/action name
def load_assets
@stylesheets, @javascripts = [], []
[controller_path, "#{controller_path}/#{action_name}"].each do |i|
@stylesheets << "pages/#{i}" if File.exists? "#{Rails.root}/app/assets/stylesheets/pages/#{i}.css.scss"
@javascripts << "pages/#{i}" if File.exists? "#{Rails.root}/app/assets/javascripts/pages/#{i}.js.coffee"
end
end
@robertmarsal
robertmarsal / README.md
Last active March 20, 2022 02:26 — forked from mtowers/README.md
Google Analytics Real Time Visitors Widget for Dashing with OAuth2 Authentication
@andrewzimmer906
andrewzimmer906 / Gemfile
Created September 19, 2012 12:22
MailChimp Integration using Gibbon
# This is done on Rails 3.2.2
# Make sure to define your signup route in routes.rb as a POST
# Mailchimp
gem 'gibbon'
gem 'thin'
@lancejpollard
lancejpollard / meta-tags.md
Created March 5, 2012 13:54
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@isaacsanders
isaacsanders / Equity.md
Created January 21, 2012 15:32
Joel Spolsky on Equity for Startups

This is a post by Joel Spolsky. The original post is linked at the bottom.

This is such a common question here and elsewhere that I will attempt to write the world's most canonical answer to this question. Hopefully in the future when someone on answers.onstartups asks how to split up the ownership of their new company, you can simply point to this answer.

The most important principle: Fairness, and the perception of fairness, is much more valuable than owning a large stake. Almost everything that can go wrong in a startup will go wrong, and one of the biggest things that can go wrong is huge, angry, shouting matches between the founders as to who worked harder, who owns more, whose idea was it anyway, etc. That is why I would always rather split a new company 50-50 with a friend than insist on owning 60% because "it was my idea," or because "I was more experienced" or anything else. Why? Because if I split the company 60-40, the company is going to fail when we argue ourselves to death. And if you ju

@victorbstan
victorbstan / paperclip_image_dimensions_validation.rb
Created November 23, 2011 01:21
Paperclip Validate minimum image dimensions
validate :check_dimensions
def check_dimensions
temp_file = background_image.queued_for_write[:original]
unless temp_file.nil?
dimensions = Paperclip::Geometry.from_file(temp_file)
width = dimensions.width
height = dimensions.height
if width < 800 && height < 600