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
def search | |
@pagy, @bookmarks = if params[:search].present? | |
pagy(@bookmarks.search(params[:search]), params: ->(params) { params.merge!({search: params[:search]}) }) | |
else | |
pagy(@bookmarks) | |
end | |
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
service: wordsweeper | |
image: spencerldixon/wordsweeper | |
servers: | |
web: | |
hosts: | |
- 78.47.88.46 | |
labels: | |
traefik.http.routers.domain.rule: Host(`wordsweeper.fun`, `www.wordsweeper.fun`) | |
traefik.http.routers.domain.entrypoints: websecure |
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
import { Controller } from "@hotwired/stimulus"; | |
import SlimSelect from 'slim-select'; | |
// A generic base controller for doing async API searching via slim select with baked in rate limiting | |
// You'll can extend this controller and define two methods, query(searchTerm) for your GraphQL query, | |
// and formatData(data) to format your data for presentation | |
export default class extends Controller { | |
static targets = ["selector"] | |
static values = { |
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
def update_params | |
params.require(:thing).permit(:date).tap do |param| | |
param["date(1i)"] = Date.current.year if param["date(1i)"] == "1" | |
# Can merge in other things here | |
end | |
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
# Service object azure_api.rb for interfacing with azure blob storage. Handles getting a list of files as well as | |
# getting files by top_level_directory/prefix and multiple prefixes. Also caches requests to ensure a fast response. | |
require 'azure/storage/blob' | |
CACHE_LENGTH = 3.hours | |
PREFIX_DELIMITER = ',' | |
class AzureApi | |
def self.get_files_for(directory, prefix=nil) |
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
# Recent things with optional period parameter | |
scope :recent, ->(period = 30.days) { where("created_at >= ?", period.ago.beginning_of_day) } | |
# With Active::Text :notes field | |
scope :with_notes, -> { left_joins(:rich_text_notes).where('action_text_rich_texts.id is NULL') } | |
# Between two optional dates (uses keyword arguments for optional params) | |
scope :between, ->(from: 30.days.ago, to: Date.current) { where(created_at: from.beginning_of_day..to.end_of_day) } |
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
require 'rails_helper' | |
RSpec.feature "Groups", type: :feature do | |
let(:user) { FactoryBot.create(:user) } | |
let(:admin) { FactoryBot.create(:user, :with_admin) } | |
let(:group) { FactoryBot.create(:group) } | |
let(:groups) { FactoryBot.create_list(:group, 2) } | |
let(:new_group) { FactoryBot.build(:group) } | |
scenario 'require authentication' do |
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
'use strict'; | |
const puppeteer = require('puppeteer'); | |
const fs = require('fs'); //Filesystem | |
let content = fs.readFileSync(process.argv[2], "utf-8"); | |
const createPdf = async() => { | |
let browser; | |
try { |
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
require 'rails_helper' | |
RSpec.feature 'User Registration', type: :feature do | |
let(:new_user) { FactoryBot.build(:user) } | |
let(:user) { FactoryBot.create(:user) } | |
scenario 'User can sign up' do | |
visit root_path | |
first(:link, 'Sign up').click | |
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
config.include FactoryBot::Syntax::Methods | |
config.include Devise::Test::ControllerHelpers, type: :controller | |
config.include Devise::Test::ControllerHelpers, type: :view | |
config.include Devise::Test::IntegrationHelpers, type: :feature |
NewerOlder