Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash -e
# Kubernetes api server is supposed to run compaction on etcd
# when that does not happen we need to do an emergency compaction to make etcd not lock up
# this should only be done once, so we pick the leader to do it, which we assume is healthy
# (compacting manually outside of api server can lead to watches failing / requests for specific revisions failing etc)
#
# After compacting the keyspace, the backend database may exhibit internal fragmentation.
# Any internal fragmentation is space that is free to use by the backend but still consumes storage space.
# The process of defragmentation releases this storage space back to the file system.
@nbibler
nbibler / caller.hbs
Created November 5, 2020 17:15
Video.js, TypeScript, traditional Ember Component
<MyVideo @video={{someVideoModelInstance}}/>
@tgroshon
tgroshon / oop_code_smells.md
Last active November 24, 2021 09:19
OOP Code Smells by Martin Fowler and Kent Beck grouped by Mika Mantyla

OOP Code smells

Things that might indicate a problem. RailsConf talk "Get a Whiff of This" by Sandi Metz

  • Couplers: binds objects together
    • feature envy (send more messages to object than to self)
    • inappropriate intimacy (access private methods/data)
    • message chains (law of demeter; too many dots)
    • middle man (sole purpose to forward on calls)
# сохраняем файл в корень проекта
# добавляем ссылку в гит:
# ln -s ../../rubocop_pre_commit_hook.rb .git/hooks/pre-commit
# проверяем добавился ли файл:
# ls -al .git/hooks/pre-commit
# должно быть что то типа:
# Aug 11 13:17 .git/hooks/pre-commit -> ../../rubocop_pre_commit_hook.rb
# даем права:
# chmod +x .git/hooks/pre-commit
# проверяем:
// tests/helpers/push-mirage-db-into-store.js
import { registerAsyncHelper } from '@ember/test';
import { run } from '@ember/runloop';
let pushMirageDbIntoStore = function(server, store) {
let tables = Object.keys(server.schema);
tables.forEach(table => {
if (server.schema[table].all) {
let all = server.schema[table].all();
@ccyrille
ccyrille / zero_downtime_remove_column.rb
Created February 7, 2018 16:34
Zero Downtime - Remove a column
class User < ActiveRecord::Base
...
# << REMOVE ON NEXT RELASE
def self.columns
super.reject { |c| c.name == "removed_column" }
end
# >> REMOVE ON NEXT RELEASE
...
end
@samselikoff
samselikoff / README.md
Last active June 24, 2020 19:56
How to use an `asyncThrows` custom helper.

This assert.asyncThrows custom assertion allows us to write tests against failing async code, usually as a result of a server error (4xx/5xx response).

test('If the index route errors, I see a message', async function(assert) {
  server.create('post');
  server.get('/posts/:id', { errors: ['The site is down'] }, 500); // force Mirage to error

  await assert.asyncThrows(() => {
    return visit('/posts/1');
 }, 'GET /posts/1 returned a 500');
@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@asselstine
asselstine / hotfix.sh
Last active April 3, 2020 12:12
hotfix workflow
# My Heroku git production remote is called 'production'
git remote -v
# Yields:
#
# origin git@github.com:Loft47/loft.git (fetch)
# origin git@github.com:Loft47/loft.git (push)
# production https://git.heroku.com/loft47-prod.git (fetch)
# production https://git.heroku.com/loft47-prod.git (push)
# staging https://git.heroku.com/vey-staging.git (fetch)
@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active April 2, 2024 10:04
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear