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
# catches errors from any ActiveJob::Base inherited classes like ApplicationJob | |
# and often overlooked ActionMailer::MailDeliveryJob which is wrapper for i.e: YourMailer.deliver_later | |
module SolidErrors::ActiveJob | |
extend ActiveSupport::Concern | |
included do | |
around_perform do |job, block| | |
Rails.error.record(StandardError, context: {job: job.class.name, job_id: job.job_id}) do | |
block.call | |
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
// Converts Excel Column name to zero-based index | |
// A => 0, B => 1, Z => 25 AA => 26). | |
function excelColumnNameToInteger(columnName) { | |
if !(/^[A-z]+$/.test(columnName)) { | |
let result = 0; | |
for (let i = 0; i < columnName.length; i++) { | |
result += (columnName.charCodeAt(i) - 64) * Math.pow(26, columnName.length - i - 1); | |
} | |
return result - 1 // shift the result by 1 to get zero-based numbering; |
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
# USAGE: retry 3 times on specified errors and wait 5s between retries | |
# when maximum retries is run then raise exception | |
# with_retries(on: [Errno::EHOSTUNREACH], tries: 3, interval: 5) do | |
# Net::HTTP.get('example.com', '/index.html') | |
# end | |
module WithRetries | |
def with_retries(on: [StandardError], tries: 3, interval: 0.5) | |
interval = 0 if Rails.env.test? # speed up tests |
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
-- SQL: https://clickhouse.com/docs/en/sql-reference | |
-- top db | |
SELECT endpoint, AVG(db) AS average_db, MIN(db) AS min_db, MAX(db) AS max_db, COUNT(*) AS count FROM ( | |
SELECT | |
CONCAT( | |
JSON_VALUE(json, '$.message.controller'), | |
'#', | |
JSON_VALUE(json, '$.message.action') | |
) AS endpoint, | |
simpleJSONExtractFloat(message, 'db') / 1000 as db |
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
// app.js | |
import React from 'react'; | |
class App extends React.Component { | |
componentDidMount() { | |
const retrieveImageFromClipboardAsBlob = (pasteEvent, callback) => { | |
if(pasteEvent.clipboardData === false){ | |
if(typeof(callback) === "function"){ |
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
# please set up following github secrets in your repo: | |
# HEROKU_PIPELINE_NAME (https://devcenter.heroku.com/articles/pipelines#creating-pipelines) | |
# HEROKU_USER (your heroku username/email) | |
# HEROKU_API_KEY (use: 'heroku authorizations:create' for creating separate api_key for this purpose) | |
name: Heroku Review App Create | |
on: | |
pull_request: | |
types: opened |
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
FROM alpine:latest | |
RUN apk add \ | |
py3-pip \ | |
py3-pillow \ | |
py3-cffi \ | |
py3-brotli \ | |
gcc \ | |
musl-dev \ | |
python3-dev \ |
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
FROM debian:buster | |
RUN apt-get update -qq && apt-get install -qqy \ | |
build-essential \ | |
python3-pip \ | |
python3-cffi \ | |
libpango-1.0-0 \ | |
libpangocairo-1.0-0 \ | |
libgdk-pixbuf2.0-0 |
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
window.flattenJSON = (obj) -> | |
flattened = {} | |
join = (path, key) -> | |
(if path is "" then "" else path + "_") + key | |
flattenArray = (arr, path) -> | |
flattenElement(arr, path, i) for i in [0...arr.length] | |
flattenObject = (obj, path) -> |
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
# TPD<<T220001293<<<<<<<<<<<<<<< | |
# 6408125<2010315D<<<<<<<<<<<<<4 | |
# MUSTERMAN<<ERIKA<<<<<<<<<<<<<< | |
class PersonalId | |
attr_reader :code, :data | |
# 9 alphanumeric | |
def initialize(machinecode = "TPD<<2406055684D<<<<<<<<<<<<<<6810203<0705109D<<<<<<<<<<<<<6MUSTERMAN<<ERIKA<<<<<<<<<<<<<<") | |
@code = machinecode |
NewerOlder