Skip to content

Instantly share code, notes, and snippets.

View ejlangev's full-sized avatar

Ethan Langevin ejlangev

View GitHub Profile
api-frontend-api-1 | ╭───────────────────── Traceback (most recent call last) ──────────────────────╮
api-frontend-api-1 | │ /app/api/middleware/access_logging.py:59 in __call__ │
api-frontend-api-1 | │ │
api-frontend-api-1 | │ 56 │ │ ): │
api-frontend-api-1 | │ 57 │ │ │ try: │
api-frontend-api-1 | │ 58 │ │ │ │ sender = partial(self._send_with_status_code_recording, │
api-frontend-api-1 | │ ❱ 59 │ │ │ │ await self.app(scope, receive, sender) │
api-frontend-api-1 | │ 60 │ │ │ except Exception as e: │
api-frontend-api-1 | │ 61 │ │ │ │ request["status_code"] = 500 │
api-frontend-api-1 | │ 62 │ │ │ │ logger.exception(e)
# db.py
engine = create_engine(
db_config.url,
echo=bool(os.getenv("DEBUG", False)),
hide_parameters=not is_pytest(),
pool_size=db_config.pool_size,
pool_pre_ping=True,
pool_timeout=db_config.pool_checkout_timeout_seconds,
max_overflow=math.ceil(db_config.pool_size * db_config.pool_overflow_fraction),
@ejlangev
ejlangev / answers.md
Last active December 28, 2021 21:18
Advent Of Code 2021
require 'pp'
require 'ostruct'
data = File.open('Query Results.csv').map do |l|
pieces = l.tr('{}"', '').strip.split(',', 2)
OpenStruct.new(loan_file_id: pieces[0], all_activities: pieces[1].split(','), all_unique_activities: pieces[1].split(',').uniq)
end
activity_frequency_map = {}
common_subset = []
name: Compliance check
on:
pull_request:
types: [opened, edited, reopened, synchronize]
issue_comment:
types: [created, edited, deleted]
jobs:
compliance-check:
{
"esformatter": {
"allowShebang": true
},
"plugins": [
"esformatter-remove-trailing-commas",
"esformatter-collapse-objects",
"esformatter-remove-object-spaces"
],
{
"size": 0,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"exists": {
"field": "address.full"
@ejlangev
ejlangev / gist:f67fadb4b5497d897452
Created July 29, 2014 19:00
Foreign Key Validator
class ForeignKeyValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value && value.to_s =~ /^\d+$/ && value.to_i > 0
record.errors[attribute] << 'is not a valid foreign key'
end
end
end
class CreditCardController < ApplicationController
def create
creator = CreditCardCreator.call(params)
# creator.respond_to?(:errors) => true
# creator.errors => [] (by default)
# when something goes wrong: creator.errors => ['Terrible Error']
respond_with(creator)
end
end
@ejlangev
ejlangev / gist:11380168
Created April 28, 2014 18:30
Example of page specific js
$ ->
$("#scared, #down-arrow, #example-button").click ->
$("html, body").animate
scrollTop: $("#dares-photos").offset().top
, 1000
return false