Skip to content

Instantly share code, notes, and snippets.

View lym's full-sized avatar
🎾

salym lym

🎾
View GitHub Profile
@lym
lym / git-conventions.md
Created December 10, 2021 17:40 — forked from mhartington/git-conventions.md
Git Conventions

You've been working locally for awhile. You're ready to push some changes, but someone else pushed something! You have to pull in their changes before you can push yours.

git pull origin master forces you to create a merge commit, which is annoying.

Instead, do git pull --rebase origin master. This will effectively:

  1. Stash your changes
  2. Pull in the changes from origin
  3. Apply your changes on top

No merge commit!

@lym
lym / secret-key-gen.py
Created September 23, 2020 14:30 — forked from ndarville/secret-key-gen.py
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@lym
lym / random_string_generator.rb
Created September 2, 2019 20:09 — forked from KamilLelonek/random_string_generator.rb
Ruby random string generator with particular length
class RandomStringGenerator
def without_numbers(length)
random_string(length, alphabet)
end
def with_numbers(length)
random_string(length, alphabet + numbers)
end
private
@lym
lym / macos-recovery-server.md
Created November 3, 2018 13:14
Fixing "The recovery server could not be contacted" in MacOS High Sierra

I was trying to reinstall High Sierra on an older MacBook Air using internet recovery and I kept on getting an error message when trying to reinstall High Sierra.

The recovery server could not be contacted

It appears that this has to do with the time on the machine not being synchronized, so when the MacBook tries to reach out to the recovery server the certificates do not validate and we get this useless error message.

To fix this.

  1. Open up a Terminal from the utilities menu
  2. Enter the following command
@lym
lym / capybara cheat sheet
Created April 18, 2018 11:41 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@lym
lym / rubocop_pre_commit_hook
Created April 16, 2018 11:40 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED