Skip to content

Instantly share code, notes, and snippets.


Moncef Belyamani monfresh

View GitHub Profile
monfresh /
Last active Jun 2, 2020
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 /
Last active Jul 30, 2020
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 /
Last active Mar 27, 2019
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 ( 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:

View controller_refactor.rb
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)
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
View gist:9678741
while getopts ":a:o:" opt; do
case $opt in
echo "Getting ready to set environment variables for $2"
echo "Setting CANONICAL_URL"
heroku config:set CANONICAL_URL=$ --app $2
echo "Setting DOMAIN_NAME"
heroku config:set --app $2
monfresh / gist:9009832
Last active Aug 29, 2015
Is there a way to disable eager loading if the query doesn't return any results?
View gist:9009832
# Models
class Post < ActiveRecord::Base
  has_many :comments

class Comment < ActiveRecord::Base
  belongs_to :post
monfresh / gist:5816579
Last active Dec 18, 2015
Rails controller create action for Mongoid embedded_in model. What is the right way to test the post :create action in this situation?
View gist:5816579
# app/models/user.rb
class User
include Mongoid::Document
embeds_many :api_applications
# app/models/api_application.rb
class ApiApplication
include Mongoid::Document
monfresh / gist:5663043
Created May 28, 2013
Defaults file for Rails Apps Composer for a basic Rails API app that uses MongoDB and Mongoid
View gist:5663043
- setup
- readme
- gems
- testing
- controllers
- routes
- extras
monfresh / gist:5663004
Created May 28, 2013
README.rdoc generated by Rails Apps Composer
View gist:5663004
== Welcome to Rails
Rails is a web-application framework that includes everything needed to create
database-backed web applications according to the Model-View-Control pattern.
This pattern splits the view (also called the presentation) into "dumb"
templates that are primarily responsible for inserting pre-built data in between
HTML tags. The model contains the "smart" domain objects (such as Account,
Product, Person, Post) that holds all the business logic and knows how to
persist themselves to a database. The controller handles the incoming requests
You can’t perform that action at this time.