Skip to content

Instantly share code, notes, and snippets.

Avatar

Moncef Belyamani monfresh

View GitHub Profile
@monfresh
monfresh / caseflow_code_quality.md
Last active Jun 2, 2020
Caseflow code quality talk
View caseflow_code_quality.md

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 Jul 30, 2020
Guide to getting your FERS contribution refund for former 18F employees
View fers_contribution_refund_guide.md

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 Mar 27, 2019
Notes on installation of fish shell on macOS
View fish_shell_notes.md

notes on installing fish shell

brew install fish

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

chsh -s /usr/local/bin/fish
View keybase.md

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:

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)
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
View gist:9678741
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 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
end

class Comment < ActiveRecord::Base
  belongs_to :post
end
@monfresh
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
...
end
# app/models/api_application.rb
class ApiApplication
include Mongoid::Document
@monfresh
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
recipes:
- setup
- readme
- gems
- testing
- controllers
- routes
- extras
prefs:
@monfresh
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.