Skip to content

Instantly share code, notes, and snippets.

View pocheptsov's full-sized avatar

slava pocheptsov pocheptsov

View GitHub Profile
@pocheptsov
pocheptsov / appcues_controller.ts
Last active December 9, 2022 23:24
Hotwired Turbo and partial page update patch
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static values = {
userId: String,
data: Object,
}
dataValue: object
userIdValue: string
@pocheptsov
pocheptsov / ruby_hash_merge_benchmark.rb
Created October 30, 2021 18:59
Ruby Hash merge benchmark
require 'benchmark/ips'
h = { a: 1 }
=> {:a=>1}
Benchmark.ips do |x|
x.report('merge') { {b: 12}.merge(h) }
x.report('merge!') { {b: 12}.merge!(h) }
x.report('merge ** ') { {b: 12, **h} }
x.compare!
end
@pocheptsov
pocheptsov / install_rds_certs_on_windows.md
Last active December 17, 2020 03:57 — forked from gingerjoos/install_rds_certs_on_windows.md
How to import Amazon RDS CA certificates into Windows 10

The official instructions will ask you to download a [pem file]. Windows will not read this PEM file properly; instead download the corresponding p7b file - https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.p7b.

Once you download the file, invoke the Certificate Manager program, certmgr.exe, from the command box that opens when you click the Start button. Instructions here. Make sure you import it into the "Trusted Root Certification Authorities" logical store.

certmgr /add /c rds-combined-ca-bundle.p7b /s /r localMachine root
https://www.chargerforums.com/threads/2018-uconnect-8-4-reboot.381191/
https://www.youtube.com/watch?v=pPGezSeNLFo
1. Put your vehicle into the accessories mode.
2a. Hold down the volume and browse knob buttons for 30 seconds or until the screen goes black and restarts.
- or -
2b. Hold down the voice command and phone button on steering wheel for 30 seconds.
3. Let go of the buttons and turn vehicle off.
4. Open driver's side door for 30 seconds.
5. Close door.
@pocheptsov
pocheptsov / client\.env.development
Created January 24, 2020 20:21
Dockerized Create React App and Proxied Backend
HOST=0.0.0.0
PROXY=http://localhost:3001
@pocheptsov
pocheptsov / get-unused-routes.rb
Created November 7, 2019 20:02
Get Rails App unused routes
# https://hackernoon.com/get-unused-routes-of-large-rails-app-0h1cu32lj
Rails.application.eager_load!
unused_routes = {}
# Iterating over all non-empty routes from RouteSet
Rails.application.routes.routes.map(&:requirements).reject(&:empty?).each do |route|
name = route[:controller].camelcase
next if name.start_with?("Rails")
@pocheptsov
pocheptsov / loadStateReducer.ts
Created February 7, 2019 22:29
Initial redux-orm state loading
import orm from 'schema/orm'
export function loadStateReducer(state = orm.getEmptyState(), payload) {
// Create a Redux-ORM session from our entities "tables"
const session = orm.session(state)
const parseEntity = (modelName, stateSlotName) => {
const ModelClass = session[modelName]
const modelStates = payload.entities[stateSlotName]
@pocheptsov
pocheptsov / rebase-feature-branch-on-squashed-commit.sh
Last active September 27, 2018 00:35
Rebase feature branch on top of squashed feature-base branch commit
# optionally set editor to the modern https://github.com/zyedidia/micro editor
git config --global core.editor micro
# find next commit after common commit of the long running side branches
COMMON_COMMIT="$(git merge-base long-running-feature-branch feature-branch-development)"
# get next to common commit
git log --pretty=format:"%h" "$COMMON_COMMIT...feature-branch-development" | tail -n1
> 50b1ed6
@pocheptsov
pocheptsov / merging_git_repositories_into_another_repository_subfolder.sh
Created August 30, 2018 21:44
Merging Git Repositories Into Another Repository Subfolder
git remote add -f js-tests [email protected]:cambridgebrainsciences/js-tests.git
git merge --no-commit -s ours js-tests/master
git read-tree --prefix=frontend/tests -u js-tests/master
git commit -m "Subtree merged in frontend/tests"
git remote remove js-tests
@pocheptsov
pocheptsov / migrate_terraform_state_into_module.sh
Created July 9, 2018 17:40
Migrate multiple terraform resources under module structure
# grab all resources that will be marked for deletion and has [prefix]_[name].[suffix] template
# change module.name with yours naming
terraform plan -no-color awk '$1 == "-" && $2 ~ /.*_.*\..*/ { print "terraform state mv " $2 " module.name." $2 }' > mv_state.sh
# apply state changes
./mv_state.sh
# remove backups after checking state
rm -f terraform.tfstate.*