Skip to content

Instantly share code, notes, and snippets.

View lightyrs's full-sized avatar
🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)

Harris Novick lightyrs

🌒
ლ(▀̿̿Ĺ̯̿̿▀̿ლ)
View GitHub Profile
@lightyrs
lightyrs / search-git-history.md
Created September 28, 2021 17:40 — forked from lyoshenka/search-git-history.md
Search Git commit history for a string and see the diffs

Searching Git commit history

This should be one of the core features of Git, but for some reason it's impossible to figure out how to search for a string in your commit history and see the diffs that that string is in. Here's the best I've come up with:

To find which commits and which files a string was added or removed in:

git log -S'search string' --oneline --name-status

To see the diff of that

@lightyrs
lightyrs / gist:6aa6bb4fb6b92b87f8f21879c683eee8
Created December 17, 2020 04:09 — forked from dedy-purwanto/gist:11312110
Bulk remove iTerm2 color schemes.
# There was a day where I have too many color schemes in iTerm2 and I want to remove them all.
# iTerm2 doesn't have "bulk remove" and it was literally painful to delete them one-by-one.
# iTerm2 save it's preference in ~/Library/Preferences/com.googlecode.iterm2.plist in a binary format
# What you need to do is basically copy that somewhere, convert to xml and remove color schemes in the xml files.
$ cd /tmp/
$ cp ~/Library/Preferences/com.googlecode.iterm2.plist .
$ plutil -convert xml1 com.googlecode.iterm2.plist
$ vi com.googlecode.iterm2.plist
@lightyrs
lightyrs / .gitattributes
Created November 1, 2020 00:45 — forked from tekin/.gitattributes
An example .gitattributes file that will configure custom hunk header patterns for some common languages and file formats. See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details.
*.c diff=cpp
*.h diff=cpp
*.c++ diff=cpp
*.h++ diff=cpp
*.cpp diff=cpp
*.hpp diff=cpp
*.cc diff=cpp
*.hh diff=cpp
*.m diff=objc
*.mm diff=objc
@lightyrs
lightyrs / simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Created October 29, 2020 02:21 — forked from iscott/simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

Cheat Sheet: Simple Authentication in Rails 6 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4, 5, or 6
@lightyrs
lightyrs / db.rake
Created September 26, 2020 01:28 — forked from khalilgharbaoui/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6
# Benefits of: https://gist.github.com/e12e/e0c7d2cc1d30d18c8050b309a43450ac
# And fixes of: https://gist.github.com/joelvh/f50b8462611573cf9015e17d491a8a92
namespace :db do
desc 'Dumps the database to backups'
task dump: :environment do
dump_fmt = ensure_format(ENV['format'])
dump_sfx = suffix_for_format(dump_fmt)
backup_dir = backup_directory(Rails.env, create: true)
@lightyrs
lightyrs / voices.txt
Created August 28, 2020 16:24 — forked from mculp/voices.txt
List of voices available by the `say` command on OS X
Agnes en_US # Isn't it nice to have a computer that will talk to you?
Albert en_US # I have a frog in my throat. No, I mean a real frog!
Alex en_US # Most people recognize me by my voice.
Alice it_IT # Salve, mi chiamo Alice e sono una voce italiana.
Alva sv_SE # Hej, jag heter Alva. Jag är en svensk röst.
Amelie fr_CA # Bonjour, je m’appelle Amelie. Je suis une voix canadienne.
Anna de_DE # Hallo, ich heiße Anna und ich bin eine deutsche Stimme.
Bad News en_US # The light you see at the end of the tunnel is the headlamp of a fast approaching train.
Bahh en_US # Do not pull the wool over my eyes.
Bells en_US # Time flies when you are having fun.
@lightyrs
lightyrs / weighted_random_sampling.md
Created June 1, 2019 23:11 — forked from O-I/weighted_random_sampling.md
[TIx 8] Weighted Random Sampling in Ruby

One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.

Let's take the example of simulating the rolling of a die.

We can represent a die as an array of its faces.

die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
@lightyrs
lightyrs / favorites.css
Last active March 30, 2017 01:16
Favorite Simple CSS Styles
.subtle-gradient-1 {
background-image: linear-gradient(to right, #f0fcff 0%, #f2f4ff 100%);
}
.pastel-gradient-1 {
background-image: linear-gradient(to left bottom, hsl(253, 100%, 85%) 0%, hsl(132, 100%, 85%) 100%);
}
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@lightyrs
lightyrs / aspect-ratio-container.styl
Last active December 3, 2015 05:31 — forked from brianmcallister/maintain-ratio.scss
Sass mixin for a responsive box that maintains an aspect ratio.
aspect-ratio-container($horizontal, $vertical)
height 0
padding-bottom ( $vertical / $horizontal * 100 ) %