Skip to content

Instantly share code, notes, and snippets.

View pechorin's full-sized avatar
🌴
(do (code) (love life))

andrey pechorin pechorin

🌴
(do (code) (love life))
View GitHub Profile
@pechorin
pechorin / grep.md
Created April 15, 2024 12:55 — forked from romainl/grep.md
Instant grep + quickfix

FOREWORDS

I don't mean the snippet at the bottom of this gist to be a generic plug-n-play solution to your search needs. It is very likely to not work for you or even break things, and it certainly is not as extensively tested and genericised as your regular third-party plugin.

My goal, here and in most of my posts, is to show how Vim's features can be leveraged to build your own high-level, low-maintenance, workflows without systematically jumping on the plugins bandwagon or twisting Vim's arm.


Instant grep + quickfix

@pechorin
pechorin / ANSI.md
Created October 3, 2023 08:50 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@pechorin
pechorin / git-deployment.md
Created December 12, 2019 14:29 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@pechorin
pechorin / osx_bootstrap.sh
Created December 6, 2019 20:44 — forked from mrichman/osx_bootstrap.sh
Bootstrap script for setting up a new OSX machine
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Twitter (app store)
@pechorin
pechorin / protobuf260.rb
Created November 16, 2019 17:58 — forked from shlima/protobuf260.rb
brew formula to install [email protected]
class Protobuf260 < Formula
desc "Protocol buffers - Google data interchange format"
homepage "https://github.com/google/protobuf/"
stable do
url "https://github.com/google/protobuf/releases/download/v2.6.0/protobuf-2.6.0.tar.bz2"
sha256 "0a2f8533b2e0587a2b4efce0c4c8aea21bbfae1c41c466634d958dedf580f6aa"
# Fixes the unexpected identifier error when compiling software against protobuf:
# https://github.com/google/protobuf/issues/549
@pechorin
pechorin / latency.markdown
Created November 10, 2019 16:21 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@pechorin
pechorin / custom-logger.rb
Created August 19, 2019 20:08 — forked from Filirom1/custom-logger.rb
How to customize a logger in ruby
require 'logger'
module Dim
class Logger < ::Logger
def initialize(*)
super
@formatter = NoTimestampFormatter.new
end
end
@pechorin
pechorin / latency.txt
Created December 26, 2018 21:40 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@pechorin
pechorin / query_planner.markdown
Created March 26, 2018 23:46 — forked from hgmnz/query_planner.markdown
PostgreSQL query plan and SQL performance notes

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.