This is the simplest solution I could come up with. It ain't robust, but it's the easiest to understand.
function onlyEvens(arr) {
return arr.filter(num => num % 2 === 0).sort((a, b) => a - b);
}
#!/bin/bash | |
# Chatwoot SMTP Diagnostics Script (Clean Version) | |
SMTP_HOST="smtp.gmail.com" | |
PORTS=(465 587) | |
echo "=== Chatwoot SMTP Diagnostics ===" | |
echo |
# Script to fix reply_time events that occur after conversation_resolved events | |
# Usage in Rails console: | |
# load 'fix_reply_time_after_resolved.rb' | |
# find_conversations_to_fix(account_id: 1) # returns array of conversation IDs | |
# fix_reply_times(account_id: 1) # dry run by default | |
# fix_reply_times(account_id: 1, dry_run: false) # actual fix | |
def verify_conversation(conversation) | |
events = conversation.reporting_events.order(created_at: :asc).to_a |
/** | |
* Browser Bot Script | |
* ----------------- | |
* | |
* This script uses Puppeteer to simulate real browser behavior by: | |
* - Using random viewport sizes and user agents | |
* - Simulating human-like scrolling (50% chance) | |
* - Clicking FAQ links (30% chance) | |
* | |
* Usage: |
const fs = require('fs'); | |
const path = require('path'); | |
const glob = require('glob'); | |
// Directory containing your Vue components | |
const componentsDir = path.resolve(__dirname, 'app/javascript'); | |
// Use glob.sync() for synchronous file matching | |
const files = glob.sync(`${componentsDir}/**/*.vue`); |
const darkColors = { | |
primary: { | |
25: '#0B101F', | |
50: '#101729', | |
75: '#142251', | |
100: '#182B6D', | |
200: '#1F3581', | |
300: '#284092', | |
400: '#304CA8', | |
500: '#3959C4', |
SELECT relname, heap_blks_read, heap_blks_hit,
(heap_blks_hit / NULLIF(heap_blks_hit + heap_blks_read, 0)) AS hit_ratio
FROM pg_statio_user_tables
ORDER BY hit_ratio ASC, heap_blks_read DESC
LIMIT 10;
-- hit_ratio: Represents the proportion of times data requested from a table was
import json | |
from collections import defaultdict | |
LEADING = """MutexApplicationJob::LockAcquisitionError: Failed to acquire lock for key: FB_MESSAGE_CREATE_LOCK::""" | |
def get_logs(): | |
f = open('logs.json') | |
return json.load(f) |
module ColorHelper | |
def hex_to_rgb(hex_color) | |
# Remove the '#' character if it's there | |
hex_color = hex_color.tr('#', '') | |
# Split the hex color string into the RGB components | |
r = hex_color[0..1].to_i(16) | |
g = hex_color[2..3].to_i(16) | |
b = hex_color[4..5].to_i(16) |
module ColorHelper | |
def hex_to_rgb(hex_color) | |
# Remove the '#' character if it's there | |
hex_color = hex_color.tr('#', '') | |
# Split the hex color string into the RGB components | |
r = hex_color[0..1].to_i(16) | |
g = hex_color[2..3].to_i(16) | |
b = hex_color[4..5].to_i(16) |