Skip to content

Instantly share code, notes, and snippets.

View monfresh's full-sized avatar

Moncef Belyamani monfresh

View GitHub Profile
@monfresh
monfresh / code_smells.md
Last active May 31, 2023 18:54
Wisdom Wednesday Code Smells

PDF

PAIN

DREAM

  • Wouldn't it be nice to be able to quickly make changes and add new features?
  • Wouldn't it be nice for new team members to jump in to the code faster?
@monfresh
monfresh / ruby_refactoring.md
Last active May 31, 2023 18:55
Wisdom Wednesday - Refactoring

Intros

Code Climate guidelines

  • If PR is urgent, ask a GitHub repo admin to approve in Code Climate, then immediately fix the offenses. Don't open a new ticket.
  • If PR is not urgent, take the time to understand the issue and fix it, unless it's a false positive.
  • Walk through reading up on offense in CC

OO principles

Sandi Metz

@monfresh
monfresh / caseflow_code_quality.md
Last active March 29, 2023 17:42
Caseflow code quality talk

Wisdom Wednesday on Code Quality, March 6, 2019

Moncef's Background:

  • Developed interest and focus on code quality and refactoring over past 4 years

  • Helped start 18F Development Guide

  • Spent lots of time reading and learning

Recommended courses, books, tutorials, newsletters

@monfresh
monfresh / fers_contribution_refund_guide.md
Last active March 26, 2024 18:23
Guide to getting your FERS contribution refund for former 18F employees

For best results, all forms mentioned below must be printed out, filled out and signed in ink, and mailed directly to OPM at the following address:

U.S. Office of Personnel Management
Attn: Federal Employee Retirement System 
Post Office Box 45
Boyers, PA 16017-0045

In order to send directly to OPM, you must wait 30 days after your last day at GSA. However, because part of the process requires you to mail some forms to your financial institution and wait for them to send them back, you can start the process about 15 days after your last day.

@monfresh
monfresh / fish_shell_notes.md
Last active March 27, 2019 03:14
Notes on installation of fish shell on macOS

notes on installing fish shell

brew install fish

add /usr/local/bin/fish to /etc/shells

chsh -s /usr/local/bin/fish

Keybase proof

I hereby claim:

  • I am monfresh on github.
  • I am monfresh (https://keybase.io/monfresh) on keybase.
  • I have a public key whose fingerprint is AFF2 F9F5 3A67 074A 9D56 742F 17D0 259C C64C E075

To claim this, I am signing this object:

@monfresh
monfresh / controller_refactor.rb
Last active June 10, 2016 14:11
Refactor exercise
def update
# reset attempt count if user is no longer locked out
unless resource.otp_time_lockout? || resource.second_factor_locked_at.nil?
resource.update(second_factor_attempts_count: 0, second_factor_locked_at: nil)
end
if resource.authenticate_otp(params[:code].strip)
warden.session(resource_name)['need_two_factor_authentication'] = false
sign_in resource_name, resource, bypass: true
set_flash_message :notice, :success
while getopts ":a:o:" opt; do
case $opt in
a)
echo "Getting ready to set environment variables for $2"
echo "Setting CANONICAL_URL"
heroku config:set CANONICAL_URL=$2.herokuapp.com --app $2
echo "Setting DOMAIN_NAME"
heroku config:set DOMAIN_NAME=herokuapp.com --app $2
@monfresh
monfresh / gist:9009832
Last active August 29, 2015 13:56
Is there a way to disable eager loading if the query doesn't return any results?
# Models
class Post < ActiveRecord::Base
  has_many :comments
end

class Comment < ActiveRecord::Base
  belongs_to :post
end
@monfresh
monfresh / gist:5816579
Last active December 18, 2015 17:09
Rails controller create action for Mongoid embedded_in model. What is the right way to test the post :create action in this situation?
# app/models/user.rb
class User
include Mongoid::Document
embeds_many :api_applications
...
end
# app/models/api_application.rb
class ApiApplication
include Mongoid::Document