Skip to content

Instantly share code, notes, and snippets.

View adis-io's full-sized avatar

Adis Osmonov adis-io

View GitHub Profile
adis-io /
Last active January 31, 2023 18:20
Gopass + Chrome + TouchID
adis-io / database_state_loader.rb
Created June 10, 2022 16:32 — forked from keithpitt/database_state_loader.rb
Note that this code only works with PostgreSQL, but it wouldn’t be too hard to adapt our approach for other relational databases.
View database_state_loader.rb
# Add to `spec/support/database_state_loader.rb`
class DatabaseStateLoader
class EnvironmentError < RuntimeError; end
def self.load(path)
def initialize(path)
adis-io / gist:022588f1a989bf2dfa23f5aa08decd34
Created June 10, 2022 11:30 — forked from 13k/gist:3086739
Capybara in Rails Console
View gist:022588f1a989bf2dfa23f5aa08decd34
# rails console test
# # or
# RAILS_ENV=test rails console
require 'capybara/dsl' = app.instance_variable_get("@app")
cap = { extend Capybara::DSL; self }
# cap.visit '/'
# 'h1'
adis-io / Dockerfile
Created May 13, 2022 21:20 — forked from pdonorio/Dockerfile
A template for best practices in writing a docker image
View Dockerfile
# Small image
FROM alpine:3.5
# or
FROM ubuntu:16.04
adis-io /
Created May 13, 2022 13:50
How jenkins initializes repo
mkdir <dir>
git init .
git fetch --no-tags --force --progress --<org>/<repo>.git +refs/heads/<branch>:refs/remotes/origin/<branch>
git config remote.origin.url<org>/<repo>.git
git config --add remote.origin.fetch +refs/heads/<branch>:refs/remotes/origin/<branch>
git config core.sparsecheckout
git checkout -f <sha>
adis-io / remove_nth_node_from_end_of_list.c
Last active January 12, 2022 13:42
Remove Nth Node From End of List #leetcode #c
View remove_nth_node_from_end_of_list.c
#include <stdio.h>
#include <stdlib.h>
struct ListNode {
int val;
struct ListNode *next;
struct ListNode* createNodeList(int arr[], int numSize);
struct ListNode* removeNthFromEnd(struct ListNode* head, int n);
adis-io / category.rb
Created September 15, 2020 08:04
Rails models with Wordpress DB
View category.rb
class Category < Taxonomy
def self.sti_name
adis-io /
Created May 4, 2020 03:51
How to solve Dry::Struct::Error <attribute> is missing in Hash input

I'm using dry-rb and dry-struct. And I wanted make some attributes optional, but I was confused with optional.

So the thing is, you can't use optional for skipping attributes. Optional means you can pass nil values, that's all.

So if you want to skip attributes, use this attribute by calling attribute?

class User < Dry::Struct
  attribute :name, Types::String
 attribute? :age, Types::Integer
adis-io /
Last active February 28, 2020 15:54
Find tables in postgres with deleted_at column and unique indexes without condition #postgres #query #sql #safe_deletion

So in Postgres you can create partial indexes with condition.
Let's say you have soft deletion in you table and you don't want them to be indexed.

You added deleted_at column, but forget change unique indexes. To find those tables manually will be a bit longer.

Here is SQL query which will help you find them faster:

SELECT tables.table_name
FROM information_schema.tables as tables
adis-io /
Last active April 5, 2019 11:35 — forked from bufordtaylor/
Upgrading from MySQL 5.6 to 5.7 on OS X
mysql.server stop # kill the process if it fails
brew uninstall mysql56
brew update
brew install mysql@5.7
brew link mysql@5.7 --force
mysql.server stop
brew services start mysql # don't run via tmux
mysql_upgrade -u root --force
brew services restart mysql # don't run via tmux
cd ~/Code/17hats/17hats