Skip to content

Instantly share code, notes, and snippets.

View Mayurifag's full-sized avatar
🗨️
hey

Mayurifag

🗨️
hey
View GitHub Profile
@Mayurifag
Mayurifag / instruction.md
Created May 23, 2025 08:09
probable durable steamos win ntfs mount

Find UUID

sudo blkid | grep ntfs # Find UUID of device

Create folder and add file

sudo mkdir -p /var/lib/systemd/system/
@Mayurifag
Mayurifag / IPA-Sources
Created May 21, 2025 22:43 — forked from ongkiii/IPA-Sources.md
REPOS/TELEGRAM CHANNELS LIST BY u/angkitbharadwaj
REPOS/TELEGRAM CHANNELS LIST BY u/angkitbharadwaj (visit https://fmhy.net/android-iosguide#ios-ipas for more sources)
**These are links to be used with Feather, ESign, Scarlet, etc.**
-ethMods Repo Access:
https://repo.ethsign.fyi
Esign:https://repo.ethsign.fyi
Gbox:https://repo.ethsign.fyi
Trollstore:https://repo.ethsign.fyi
@Mayurifag
Mayurifag / ahkv2.ahk
Created March 14, 2025 10:25
my ahk v2 hotkeys for windows (partial Ilya Birman layout)
#Requires AutoHotkey v2.0+
#SingleInstance Force
#Warn
SetTitleMatchMode 2 ; Allows partial title matching
FileEncoding "UTF-8"
DOTA_WINDOW := "ahk_exe dota2.exe"
CapsLock::
{
@Mayurifag
Mayurifag / has_many_attached.rb
Created October 26, 2023 06:19 — forked from fractaledmind/has_many_attached.rb
Vanilla Rails isomorphic attachment validations
# /app/models/concerns/has_many_attached.rb
module HasManyAttached
extend ActiveSupport::Concern
class_methods do
def has_many_attached(name, dependent: :purge_later, service: nil, strict_loading: false, **options)
super(name, dependent: :purge_later, service: nil, strict_loading: false)
if options[:file_types].any?
validate "validate_#{name}_file_types".to_sym
@Mayurifag
Mayurifag / preload_first_n_records_of_association.rb
Created September 28, 2023 17:32 — forked from Envek/preload_first_n_records_of_association.rb
Preload first N records of an association in ActiveRecord (Ruby on Rails)
# Collection has and belongs to many Projects through CollectionProject
# Usage
@collections = current_user.collections.page(1)
ActiveRecord::Associations::Preloader.new.preload(@collections, :projects, limited_projects(3))
# Now @collections.first.projects will have only first 3 projects accessible
# Constructs SQL like this to preload limited number of recent projects along with collections:
# SELECT * FROM (
# SELECT "projects".*, row_number() OVER (PARTITION BY collection_projects.collection_id ORDER BY collection_projects.created_at) AS collection_position
@Mayurifag
Mayurifag / rescue-from-git-push-force.md
Created September 28, 2023 17:31 — forked from Envek/rescue-from-git-push-force.md
Откат ошибочной команды git push --force

Откат ошибочной команды git push --force

Иногда при работе с несколькими удалёнными репозиториями в git, может произойти страшное: git push --force в не тот remote и/или не в ту ветку.

Такое может случиться, например, если вы используете [Deis], в котором деплой запускается при git push нужного коммита в сборщик, когда при отладке деплоя после очередного git commit --amend по запарке вместо git push deis master --force делается просто git push --force. Упс.

Как результат, последние коммиты коллег безвозвратно потеряны, и вы чувствуете неотвратимость их ярости…

Но это git, а значит всё можно починить!

#!/bin/sh
set -eu
AGGRESSIVE=0
PARAMS=""
while [ "$#" -gt 0 ]; do
case "$1" in
--aggressive)
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
# Makes git push and creates Merge Request at the same time
# If you follow branch naming convention like "ucp-123/new-authorization", MR title will be "UCP-123 New authorization", which will be cross-linked to Jira
# Make sure to replace "ucp" with your shortcut.
# IMPORTANT PREREQUISITE: to run `git config committer.name <your_gitlab_username>` once, so that it gets used for `make publish!` to assign MR to you
USERNAME := $(shell git config committer.name)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
ticket_pattern := ucp-[0-9][0-9][0-9]
TICKET := $(shell git rev-parse --abbrev-ref HEAD | grep -o '$(ticket_pattern)' | tr [:lower:] [:upper:])
@Mayurifag
Mayurifag / test_helper.rb
Created January 26, 2022 14:10 — forked from DavertMik/test_helper.rb
Better debugging for rails tests: logs and custom output to stdout
# run it as DEBUG=true rails test
if ENV['DEBUG']
Rails.logger = Logger.new(STDOUT)
Rails.logger.level = Logger::INFO
Rails.logger.datetime_format = ""
Rails.logger.formatter = proc do |severity, _time, _progname, msg|
"#{severity.green}: #{msg}\n"
end