This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration files for Rails-driven project basic continuous integration using GitHub Actions and GitLab CI. | |
2020, amkisko (Andrei Makarov). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FILEPATH: .github/workflows/workflow.yml | |
# AUTHOR: Andrei Makarov (github.com/amkisko) | |
name: Workflow | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
S3_BUCKET: testbucket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Types | |
class BaseObject < GraphQL::Schema::Object | |
field_class Types::BaseField | |
def self.listable(name, object_type, name_suffix: "", override_options: {}) | |
list_type = Class.new(Types::BaseObject) do | |
graphql_name "#{name}#{name_suffix}" | |
field :rows, [object_type], null: true | |
field :totalCount, Integer, null: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AUTHOR: Andrei Makarov (github.com/amkisko) | |
require "packetfu" | |
require "redis" | |
require "discordrb/webhooks" | |
require "telegram/bot" | |
require "time" | |
require "httpx" | |
require "dotenv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FieldExtensions::ListExtension < GraphQL::Schema::FieldExtension | |
def apply | |
object_type = field.type.unwrap | |
list_type_name = object_type.graphql_name | |
namespace = options[:namespace] || "default" | |
list_type = | |
Class.new(Objects::BaseObject) do | |
self.graphql_name("#{namespace}_#{list_type_name}_list") | |
self.field(:rows, [object_type], null: true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Relation | |
def safe_order(field, direction = "asc") | |
direction = direction.downcase.to_sym | |
# NOTE: https://gist.github.com/amkisko/aec1283b9797e94348f89e3a2b934bc0 | |
raise Error::CustomError, code: "QUERY_ORDER_INVALID_DIRECTION" unless %i[asc desc].include?(direction) | |
# field = connection.quote_table_name(field) | |
order(field => direction) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AUTHOR: github.com/amkisko | |
module Error | |
class CustomError < StandardError | |
attr_accessor :status | |
attr_accessor :message | |
attr_accessor :code | |
attr_accessor :vars | |
def initialize(params = {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Relation | |
def efilter(filter) | |
where(ExtFilter.new(self, filter).to_s) | |
end | |
end | |
class ExtFilter | |
attr_accessor :relation | |
attr_accessor :conn | |
attr_accessor :filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Brakeman test | |
* Bundle audit test | |
* Rubocop test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rubygems" | |
require "bundler/setup" | |
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")) | |
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir) | |
# NOTE: https://github.com/piotrmurach/tty-command | |
require "tty-command" |
OlderNewer