Skip to content

Instantly share code, notes, and snippets.

trying to quit vim

Anton Maminov mamantoha

trying to quit vim
View GitHub Profile
mamantoha /
Created Aug 21, 2019
A quick way to find out if a given port is open with Crystal.
require "socket"
def is_port_open?(ip : String, port : Int32, timeout = 5)
s =, port, dns_timeout: timeout, connect_timeout: timeout)
rescue IO::Timeout
View pry_everywhere.rb
# config/initializers/pry_everywhere.rb
require 'sidekiq'
# Perform Sidekiq jobs immediately in development,
# so you don't have to run a separate process.
# You'll also benefit from code reloading.
if Rails.env.development? && ENV['SIDEKIQ_INLINE'].present?
require 'sidekiq/testing'
mamantoha /
Created Apr 5, 2018

Polymorphic many-to-many association in Rails


class CreateBannerCategories < ActiveRecord::Migration
  def change
    create_table :banner_categories do |t|
      t.integer :banner_id
      t.integer :category_id
# ilsap - Intellij License Server Active Proxy
# Since Jetbrains started to blacklist license servers by hostname, it's being a pain in the ass
# to find a working one. So this is an active proxy for Intellij license servers, that masks
# a license server into your localhost. Just create a startup script to call ilsap,
# configure your IDE to activate from the localhost and YOLO!
require "http/server"
require "http/client"
mamantoha /
Last active Jun 15, 2017
Ruby goto
mamantoha / uk.rb
Created Apr 18, 2017
Ukrainian language support for Ruby on Rails
View uk.rb
# config/locales/defaults/uk.rb
uk: {
date: {
# In Ukrainian month name with day and standalone day are different
month_names: lambda do |key, options|
if options[:format] && options[:format] =~ /%-?d %B/
mamantoha / query.rb
Created Nov 17, 2016
PostgreSQL: query to select records from last week on weekdays between 9:00 and 18:00
View query.rb
"EXTRACT(dow FROM log_in) IN (1,2,3,4,5)"
"log_in::time BETWEEN '9:00' AND '18:00'"
"log_in BETWEEN now()::timestamp - (interval '1 week' AND now()::timestamp)"
mamantoha / is_github_down.rb
Last active Oct 6, 2016
Small CLI tool to tell you if GitHub is online
View is_github_down.rb
require 'net/http'
def warning_message
puts <<~HEREDOC
$ is_github_down
🦄 It's down. Go outside!
mamantoha / set_kde_wallpaper.rb
Last active Apr 16, 2018
Ruby script to change desktop wallpaper in Plasma > 5.7 from GoPro photo of the day
View set_kde_wallpaper.rb
require 'net/http'
require 'open-uri'
require 'open3'
require 'json'
require 'optparse'
require 'tempfile'
options = {} do |opts|
opts.banner = "Usage: #{__FILE__} [options]"
mamantoha / set_wallpaper
Created Jul 22, 2016
Set desktop wallpaper in Plasma5 via a dbus command
View set_wallpaper
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = "org.kde.image";d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");d.writeConfig("Image", "file:///path/to/image.png")}'