Skip to content

Instantly share code, notes, and snippets.

View vlasikhin's full-sized avatar
:octocat:

Pavel Vlasikhin vlasikhin

:octocat:
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env ruby
# frozen_string_literal: true
require "net/http"
require "uri"
require "json"
require "logger"
require_relative "../config/environment"
@vlasikhin
vlasikhin / up.sh
Created November 28, 2023 18:56 — forked from milushov/up.sh
up.sh
#!/bin/bash
# Don't forget chmod +x up.sh
# Installation:
# brew install jq
#
# Define function in ~/.zshrc
# container_name() {
# docker ps --format "{{.Names}}" | grep "app-1"
@vlasikhin
vlasikhin / convert_ruby_hash_string_to_json.rb
Created November 27, 2018 11:47 — forked from gene1wood/convert_ruby_hash_string_to_json.rb
A set of regex converstions to turn a ruby hash output string into a json parseable string
require 'json'
# Example ruby hash string which exercises all of the permutations of position and type
# See http://json.org/
ruby_hash_text='{"alpha"=>{"first second > third"=>"first second > third", "after comma > foo"=>:symbolvalue, "another after comma > foo"=>10}, "bravo"=>{:symbol=>:symbolvalue, :aftercomma=>10, :anotheraftercomma=>"first second > third"}, "charlie"=>{1=>10, 2=>"first second > third", 3=>:symbolvalue}, "delta"=>["first second > third", "after comma > foo"], "echo"=>[:symbol, :aftercomma], "foxtrot"=>[1, 2]}'
puts ruby_hash_text
# Transform object string symbols to quoted strings
ruby_hash_text.gsub!(/([{,]\s*):([^>\s]+)\s*=>/, '\1"\2"=>')
@vlasikhin
vlasikhin / example_activejob.rb
Created October 31, 2018 18:58 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end