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 / stdin_stream.hpp
Last active August 29, 2015 14:26 — forked from kikairoya/stdin_stream.hpp
boost::asio AsyncReadStream for console input
class stdin_stream: boost::noncopyable {
typedef boost::function<void (const boost::system::error_code &, size_t bytes_transferred)> read_handler_type;
public:
stdin_stream(boost::asio::io_service &io, HANDLE hin): io(io), hin(hin), hev(CreateEvent(0, 0, 0, 0)), handler(), buffer(0), size(0) {
_beginthread(&stdin_stream::thread_handler_gateway, 0, this);
}
~stdin_stream() {
buffer = 0;
CloseHandle(hev);
}
@romansavrulin
romansavrulin / disk_wipe.sh
Created December 20, 2015 16:21 — forked from Kromey/disk_wipe.sh
This simple Bash script functions as a wrapper around dd, for the purpose of wiping a disk or partition while providing progress feedback to the user.
#!/bin/bash
# disk_wipe.sh
# Author: Kromey (http://kromey.us/)
# This simple Bash script leverages the dd utility to provide user feedback
# as progress is made, designed for the purpose of wiping hard drives or
# partitions. This script reads from /dev/zero to most efficiently zero-out
# the target device or partition.
#
# BEGIN CONFIG
@romansavrulin
romansavrulin / gittruncatehistory.sh
Created January 8, 2018 19:08 — forked from magnetikonline/gittruncatehistory.sh
Truncate Git history to a specific SHA1, dropping everything before it.
#!/bin/bash -e
# Lifted from: https://github.com/adrienthebo/git-tools/blob/master/git-truncate
# Note: seem to be finding the need to run this twice over to commit the truncate
if [[ (-z $1) || (-z $2) ]]; then
echo "Usage: $(basename "$0") <drop before SHA1 commit> <branch>"
exit 1
fi
git filter-branch --parent-filter "sed -e 's/-p $1[0-9a-f]*//'" \
@romansavrulin
romansavrulin / # carthage - 2019-04-10_15-10-24.txt
Created April 10, 2019 12:10
carthage on macOS 10.14.4 - Homebrew build logs
Homebrew build logs for carthage on macOS 10.14.4
Build date: 2019-04-10 15:10:24
@romansavrulin
romansavrulin / multiple_ssh_setting.md
Created July 30, 2019 16:56 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@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")
@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 / 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
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 / 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