Skip to content

Instantly share code, notes, and snippets.

View adrianthedev's full-sized avatar
🚀
Building Avo https://avohq.io

Adrian Marin adrianthedev

🚀
Building Avo https://avohq.io
View GitHub Profile
# frozen_string_literal: true
require "bundler/inline"
gemfile(true, quiet: true) do
source "https://rubygems.org"
gem "rails", path: "."
end
# frozen_string_literal: true
require "bundler/inline"
gemfile(true, quiet: true) do
source "https://rubygems.org"
gem "rails", path: "."
end
@adrianthedev
adrianthedev / test.rb
Created January 19, 2024 15:35
Disable logging for tests
if ENV["RAILS_LOG"].blank?
config.logger = Logger.new(nil)
config.log_level = :fatal
end
@adrianthedev
adrianthedev / reserved_words.py
Created May 11, 2023 14:28 — forked from BigelowInc/reserved_words.py
Reserved words to exclude when creating usernames (or any other resource).
# A list of possible reserved words
reserved_words = [
# Companies
'amazon', 'apache', 'apple', 'atlassian', 'facebook', 'github', 'google',
'htc', 'microsoft', 'mozilla', 'nokia', 'rim', 'samsung', 'sony', 'toshiba',
'twitter', 'wikipedia',
# Operating systems
'android', 'centos', 'debian', 'dos', 'fedora', 'ios', 'linux', 'mac',
@adrianthedev
adrianthedev / avo_tip.md
Last active April 8, 2023 20:49
Avo tip for Rails tips

Hello there,

I'm Adrian, the author of Avo, and I'm excited to share a neat trick with you today. In this tutorial, I'll be demonstrating how to attach hooks and business logic to Avo's controllers using a Current model.

You may already be familiar with Rails' Current model, which is used to set the current user, multi-tenancy accounts, or other pieces of information. Typically, before_action is used in your ApplicationController to demonstrate how Current works. However, if you attempt to apply the same changes to your app the action will not work in Avo's context. This is because Avo has its own AplicationController.

So how do we apply this behavior inside Avo? Let me walk you through it.

Firstly, we configure the Current model and create the concern that holds the business logic.

@adrianthedev
adrianthedev / gist.rb
Last active March 28, 2022 13:20
Avo Rails custom validation
class Post < ApplicationRecord
validate :url_difference
def url_difference
# try and find a post with the same URL
possible_record = Post.where(url: url).first
# If that exists add to errors
if possible_record.present?
errors.add :url, "A post with that URL exists."

Keybase proof

I hereby claim:

  • I am adrianthedev on github.
  • I am adrianthedev (https://keybase.io/adrianthedev) on keybase.
  • I have a public key whose fingerprint is 8C6B CB23 DC39 D474 AD08 563B 1960 3E2F 845F ACD8

To claim this, I am signing this object:

@adrianthedev
adrianthedev / gist:858d639db655923fcdd3
Created January 23, 2015 09:58
iis wamp port 80 fix
net stop http
@adrianthedev
adrianthedev / gist:9696902
Created March 21, 2014 21:29
laravel main
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>@yield('title', 'Home Page')</title>
@adrianthedev
adrianthedev / gist:6350690
Created August 27, 2013 07:33
order days array to start with current day
var weekdays = new Array('Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata', 'Duminica');
function startDay(days){
var d = new Date();
var n = d.getDay()-1;
var weekDays = new Array();
var t = n;