Skip to content

Instantly share code, notes, and snippets.

View romansavrulin's full-sized avatar
❤️
Creating wonderful things

Roman Savrulin romansavrulin

❤️
Creating wonderful things
View GitHub Profile
@romansavrulin
romansavrulin / iso_date.groovy
Created April 7, 2021 13:23 — forked from kdabir/iso_date.groovy
current date in iso 8601 in groovy
new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC"))
@romansavrulin
romansavrulin / remove-slack-settings.sh
Created March 25, 2021 19:03 — forked from skoji/remove-slack-settings.sh
remove Slack settings (OS X)
rm -rf ~/Library/Application\ Support/Slack/
rm -rf ~/Library/Containers/com.tinyspeck.slackmacgap/
rm -rf ~/Library/Preferences/com.tinyspeck.slackmacgap.plist
rm -rf ~/Library/Saved\ Application\ State/com.tinyspeck.slackmacgap.savedState
rm ~/Library/Safari/LocalStorage/*slack*
@romansavrulin
romansavrulin / server.py
Created June 8, 2020 21:51 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@romansavrulin
romansavrulin / mocks_and_stubs.md
Created June 1, 2020 16:24 — forked from mlovic/mocks_and_stubs.md
Difference between mocks and stubs using ruby with mocha library

This gist aims to explain the difference between stubs and mocks and when each should be used. For an introduction to stubs and mocks, start somewhere else, like here.

 

  • Stub: used to isolate the object under test from its dependencies, preventing the test from being influenced by code outside the object. This way the test can't be made to fail or be broken by code which is not part of the specific functionality being tested. Stubs also lead to less code being run, which helps keep tests fast. A stub has no expectations. It doesn't care if it is called or how many times.

    For example, you might stub out a message sent to a database connection if all you are trying to test is the type of the method's return value.

 

@romansavrulin
romansavrulin / Gemfile
Created May 22, 2020 13:13 — forked from bf4/Gemfile
Rails lograge and logstash request logging
gem 'lograge' # more readable logs
gem 'logstash-event' # for logstash json format
gem 'mono_logger' # threadsafe logging
@romansavrulin
romansavrulin / delete_git_submodule.md
Created March 25, 2020 15:18 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####
@romansavrulin
romansavrulin / repo-rinse.sh
Created September 16, 2019 14:30 — forked from nicktoumpelis/repo-rinse.sh
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@romansavrulin
romansavrulin / virtual.rb
Created September 2, 2019 13:06 — forked from mssola/virtual.rb
Simple and stupid code to emulate pure virtual methods in Ruby.
##
# This file describes a simple way to implement the idea of pure virtual
# methods (abstract methods in Java, C#,...) in Ruby. Personally, I haven't
# used this pattern while programming in Ruby, but I thought it could be fun.
#
##
# This class provides a fancy way to show an error when a virtual method
# is being used but the subclass hasn't implemented it.
@romansavrulin
romansavrulin / __readme.md
Created August 27, 2019 15:54 — forked from maxivak/__readme.md
Load code in libraries in Rails 5

Load lib files in production (Rails 5)

If you have your code defined in classes in lib/ folder you may have problems to load that code in production.

Autoloading is disabled in the production environment by default because of thread safety.

Change config/application.rb:

    config.autoload_paths << Rails.root.join("lib")
 config.eager_load_paths &lt;&lt; Rails.root.join("lib")