Skip to content

Instantly share code, notes, and snippets.

@yevgenko
yevgenko / git-jump.sh
Created November 19, 2023 18:52
Git command to jump to interesting elements in an editor
#!/bin/sh
usage() {
cat <<\EOF
usage: git jump <mode> [<args>]
Jump to interesting elements in an editor.
The <mode> parameter is one of:
diff: elements are diff hunks. Arguments are given to diff.
@yevgenko
yevgenko / script-wrapper.rb
Last active September 30, 2022 14:56
Freezing random generator and capturing output of ruby script without changing original file ['jbrains/trivia', 'golden master']
require 'stringio'
def capture_stdout_string
io = StringIO.new
capture_stdout(io) do
yield
end
io.string
@yevgenko
yevgenko / .Xdefaults
Created August 24, 2011 02:58
URxvt settings with solarized theme
!-------------------------------------------------------------------------------
! Xft settings
!-------------------------------------------------------------------------------
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
@yevgenko
yevgenko / fzp.sh
Created November 29, 2021 09:48
fzp (FuzzyPreview): FuzzyFinder with interactive ripgrep and preview with highlights
#!/bin/sh
INITIAL_QUERY=""
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
fzf --bind "change:reload:$RG_PREFIX {q} || true" \
--ansi --disabled --query "$INITIAL_QUERY" \
--height=50% --layout=reverse \
-m --delimiter : \
--preview "rg {q} --color always --line-number --passthrough {1}" \
@yevgenko
yevgenko / fzg.sh
Last active November 21, 2021 13:36
fzg (FuzzyGrep): The Silver Searcher + Fuzzy Finder with needle highlighted in preview
#!/bin/sh
usage() {
cat <<\EOF
usage: fzg <needle>
EOF
}
if test $# -lt 1; then
usage >&2
@yevgenko
yevgenko / seriallogger.js
Created January 3, 2012 17:05 — forked from voodootikigod/seriallogger.js
Log all output from a serial port connection to a log file.
/*
Simple example that takes a command line provided serial port destination and routes the output to a file of the same name with .log appended to the port name.
usage: node logger.js /dev/tty.usbserial <baudrate>
*/
var SerialPort = require("serialport");
var fs = require("fs");
var port = process.argv[2];
@yevgenko
yevgenko / pastebin.sh
Created February 11, 2012 19:02
PASTEBIN.COM BASH SCRIPT – PASTE DIRECTLY FROM YOUR TERMINAL
#!/bin/bash
# Paste at Pastebin.com using command line (browsers are slow, right?)
# coder : Anil Dewani
# date : Novemeber 7, 2010
#help function
howto()
{
echo "\
Pastebin.com Bash Script \

The Problem

bundle install
> Fetching source index from https://rails-assets.org/
> 
> Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rails-assets.org/
> Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rails-assets.org/
> Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rails-assets.org/
> Could not fetch specs from https://rails-assets.org/
@yevgenko
yevgenko / flatfile_io_json2csv.rb
Last active July 16, 2019 11:20
Convert flatfile.io output (key-value map) to CSV string.
require 'csv'
require 'json'
def flatfile_io_json2csv_string(data_as_string = '[{"sku_code": "123"}, {"sku_code": "321"}]')
CSV.generate do |csv|
json_data = JSON.parse(data_as_string)
csv << json_data.first.keys # header
json_data.each do |hash|
csv << hash.values
@yevgenko
yevgenko / single_message_listener.rb
Created May 1, 2019 12:00
GOOS: auction snipper, single message listener
#
# https://github.com/yevgenko/ruby-auction_sniper/blob/master/spec/fake_auction_server.rb
#
# https://www.safaribooksonline.com/library/view/growing-object-oriented-software/9780321574442/ch11.html
#
class SingleMessageListener
include RSpec::Matchers
def initialize
@messages = SizedQueue.new(1)