Skip to content

Instantly share code, notes, and snippets.

View mgramin's full-sized avatar

Maksim Gramin mgramin

View GitHub Profile
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active August 5, 2026 17:54
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@AtulKsol
AtulKsol / psql-error-fix.md
Last active September 30, 2025 18:28
Solution of psql: FATAL: Peer authentication failed for user β€œpostgres” (or any user)

psql: FATAL: Peer authentication failed for user β€œpostgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@kyptov
kyptov / rabbitmq_cheatsheet_ru.md
Last active August 21, 2025 08:02
RabbitMQ Cheat Sheet (russian)

ΠžΠ±Ρ‰ΠΈΠ΅ ΡƒΠΏΡ€ΠΎΡ‰Π΅Π½Π½Ρ‹Π΅ понятия. Π’ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΡΡƒΡ‰Π΅ΡΡ‚Π²ΡƒΡŽΡ‚ способы Π·Π°Π΄Π°Ρ‚ΡŒ Π΄Ρ€ΡƒΠ³ΠΎΠ΅ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ Π½Π΅ΠΆΠ΅Π»ΠΈ Π΄Π°Π½Π½ΠΎΠ΅ ΡƒΠΏΠΎΡ‰Π΅Π½Π½ΠΎΠ΅.

ΠŸΠΎΠ½ΡΡ‚ΠΈΡ

  • producer - ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚Π΅Π»ΡŒ, ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½Ρ‹ΠΉ ΠΊΠΎΠ΄, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ отправляСт сообщСниС.
  • consumer - ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚Π΅Π»ΡŒ, ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½Ρ‹ΠΉ ΠΊΠΎΠ΄, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ сообшСниС.
  • exchange - ΠΎΠ±ΠΌΠ΅Π½Π½ΠΈΠΊ, Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π» RabbitMQ, ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ сообщСниС с Π·Π°Π΄Π°Π½Π½Ρ‹ΠΌΠΈ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°ΠΌΠΈ ΠΎΡ‚ отправитСля ΠΈ:
    • ΠΌΠΎΠΆΠ΅Ρ‚ ΡΠ±Ρ€ΠΎΡΠΈΡ‚ΡŒ(ΡƒΠ΄Π°Π»ΠΈΡ‚ΡŒ) сообщСниС ΠΈΠ»ΠΈ Π²Π΅Ρ€Π½ΡƒΡ‚ΡŒ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚Π΅Π»ΡŽ (зависит ΠΎΡ‚ Π°Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚ΠΎΠ² сообщСния),
    • ΠΌΠΎΠΆΠ΅Ρ‚ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ сообщСниС Π² ΠΎΡ‡Π΅Ρ€Π΅Π΄ΡŒ,
    • ΠΌΠΎΠΆΠ΅Ρ‚ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ сообщСниС Π² нСсколько ΠΎΡ‡Π΅Ρ€Π΅Π΄Π΅ΠΉ (сообщСниС Π±ΡƒΠ΄Π΅Ρ‚ скопировано для ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΎΡ‡Π΅Ρ€Π΅Π΄ΠΈ)
  • queue - ΠΎΡ‡Π΅Ρ€Π΅Π΄ΡŒ, Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΎΠ½Π°Π» RabbitMQ, Ρ…Ρ€Π°Π½ΠΈΡ‚ всС сообщСния ΠΈ Ρ€Π°Π·Π΄Π°Π΅Ρ‚ ΠΈΡ… получатСлям.
  • message - сообщСниС, содСрТит Π°Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚Ρ‹ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΡ‹Π΅ RabbitMQ, Π° Ρ‚Π°ΠΊΠΆΠ΅ Π΄Π°Π½Π½Ρ‹Π΅ для ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‡ΠΈ ΠΎΡ‚ отправитСля ΠΊ ΠΏΠΎΠ»ΡƒΡ‡Π°Ρ‚Π΅Π»ΡŽ
@jimschubert
jimschubert / Markdown-JavaScript.markdown.js
Last active April 1, 2025 17:51
DataGrip (IntelliJ) output SQL results to Markdown
if (!String.prototype.repeat) {
// polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
String.prototype.repeat = function(count) {
'use strict';
if (this == null) {
throw new TypeError('can\'t convert ' + this + ' to object');
}
var str = '' + this;
count = +count;
if (count != count) {
@QuantumGhost
QuantumGhost / example.puml
Last active June 18, 2025 14:09
A simple template for PlantUML to draw ER diagram.The basic idea comes from http://plantuml.sourceforge.net/qa/?qa=331/database-modeling
@startuml
' uncomment the line below if you're using computer with a retina display
' skinparam dpi 300
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
' we use bold for primary key
' green color for unique
' and underscore for not_null
!define primary_key(x) <b>x</b>
!define unique(x) <color:green>x</color>
!define not_null(x) <u>x</u>
@james2doyle
james2doyle / vue.pretty-bytes.filter.js
Last active November 28, 2021 01:07
Vue.js pretty bytes filter. This filter formats bytes into human readable formats
// usage: {{ file.size | prettyBytes }}
Vue.filter('prettyBytes', function (num) {
// jacked from: https://github.com/sindresorhus/pretty-bytes
if (typeof num !== 'number' || isNaN(num)) {
throw new TypeError('Expected a number');
}
var exponent;
var unit;
var neg = num < 0;
public <T> T streamQuery(String sql, Function<Stream<SqlRowSet>, ? extends T> streamer, Object... args) {
return jdbcTemplate.query(sql, resultSet -> {
final SqlRowSet rowSet = new ResultSetWrappingSqlRowSet(resultSet);
final boolean parallel = false;
// The ResultSet API has a slight impedance mismatch with Iterators, so this conditional
// simply returns an empty iterator if there are no results
if (!rowSet.next()) {
return streamer.apply(StreamSupport.stream(Spliterators.emptySpliterator(), parallel));
}
@jamescmartinez
jamescmartinez / slack_delete.rb
Last active March 14, 2025 19:45
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@jbnv
jbnv / NameGenPostgreSQLEnglish.sql
Created June 2, 2015 01:07
Name Generator (PostgreSQL; English)
SELECT
arrays.firstnames[s.a % ARRAY_LENGTH(arrays.firstnames,1) + 1] AS firstname,
substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ' from s.a%26+1 for 1) AS middlename,
arrays.lastnames[s.a % ARRAY_LENGTH(arrays.lastnames,1) + 1] AS lastname
FROM generate_series(1,300) AS s(a) -- number of names to generate
CROSS JOIN(
SELECT ARRAY[
'Adam','Bill','Bob','Calvin','Donald','Dwight','Frank','Fred','George','Howard',
'James','John','Jacob','Jack','Martin','Matthew','Max','Michael',
'Paul','Peter','Phil','Roland','Ronald','Samuel','Steve','Theo','Warren','William',
@rxaviers
rxaviers / gist:7360908
Last active August 5, 2026 05:25
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue: