Skip to content

Instantly share code, notes, and snippets.

View Zlatov's full-sized avatar
:octocat:

Maksim Zlatov Zlatov

:octocat:
View GitHub Profile
#!/usr/bin/env bash
cleanup() {
tput cnorm > /dev/tty
stty "$_stty" <> /dev/tty
}
_stty=$(stty -g < /dev/tty)
trap cleanup exit SIGTERM SIGQUIT
menu() {
@mlanett
mlanett / rails http status codes
Last active April 13, 2024 13:40
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@jbgo
jbgo / wtf_notepad.md
Last active March 10, 2023 12:53
Safely remove byte order marks (BOM) and carriage returns (^M) from files edited with Notepad on windows

TLDR: File.read(a_file).sub("\xEF\xBB\xBF", "").gsub("\r", "")

I tried using combinations of find/awk/sed, but I ended up corrupting my project files including the git index because I don't understand those commands very well. So instead, I turned to my good old friend ruby. This also has the advantage that I can use it in my program that processes these files. They've been ninja-edited (modfied outside of source control) in the past, which makes it likely that someone will come by and ninja edit them again in the future. But instead of convincing people that it's bad to edit files in notepad or outside of source control, we can just silently fix it on the fly and smile and say "Happy Friday!"

Here is the example of what I'm cleaning up. Thankfully, git's diff viewer is brutally honest and shows these characters. Unfortunately, most editors (including the good ones) simply hide these characters and put them back in when you save the file. The byte order marks were causing browsers to skip CSS declarations

@MicahElliott
MicahElliott / rbenv-howto.md
Created April 17, 2012 18:11
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev