Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Writing code

Junil Jacob JunilJacob

👨‍💻
Writing code
View GitHub Profile
@JunilJacob
JunilJacob / base_controller.rb
Last active Oct 23, 2019
Request Rate Limiter
View base_controller.rb
class Api::V3::BaseController < ActionController::Base
include Limiter
before_action -> { rate_limit(key: "api_#{doorkeeper_token.application_id}", rate: 60, interval: 60) }
private
def handle_rate_limit_exception
log_exception RateLimitError.new("Rate limit reached for #{doorkeeper_token.application.name}")
render json: { error: { type: "rate_limit_exceeded", message: "Rate limit exceeded." } }, status: 429
@JunilJacob
JunilJacob / totp_2fa.rb
Created May 31, 2019 — forked from Nitrino/totp_2fa.rb
Rails mixin module for Two Factor Authentication (TOTP)
View totp_2fa.rb
module OneTimePassword
# Concern containing logic and methods for OTP authentication.
# Is used Time-based One-time Password Algorithm(TOTP)
# https://tools.ietf.org/html/rfc6238
extend ActiveSupport::Concern
OTP_DIGITS = 6
OTP_NUMBER_OF_BACKUP_CODES = 10
OTP_BACKUP_CODE_LENGTH = 12
View 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')
@JunilJacob
JunilJacob / gist:7a6dd1dae2b4da2d79ad93c98f2cab33
Created Aug 8, 2017 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup
View gist:7a6dd1dae2b4da2d79ad93c98f2cab33

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@JunilJacob
JunilJacob / clean_git_tags.sh
Created Jun 17, 2017 — forked from awilliams/clean_git_tags.sh
Delete multiple grepable tags from git
View clean_git_tags.sh
#!/bin/bash
for i in $( git tag -l | grep staging ); do
echo Tag: $i
#git tag -d $i
#git push origin :refs/tags/$i
done
@JunilJacob
JunilJacob / git-merge-tool
Created Mar 18, 2017 — forked from coderxin/git-merge-tool
How to set Sublime Text 2 as Git merge tool? https://coderwall.com/p/fypiga
View git-merge-tool
git config --global mergetool.sublime.cmd "subl -w \$MERGED"
git config --global mergetool.sublime.trustExitCode false
git config --global merge.tool sublime
git mergetool -y
@JunilJacob
JunilJacob / gist:261df8a1a9f743c6382ebfab7027a73e
Created Jun 8, 2016 — forked from ericallam/gist:1019446
How to log all queries for a PostgreSQL homebrew install on OS X
View gist:261df8a1a9f743c6382ebfab7027a73e

Open the postgresql.conf config file:

$> mate /usr/local/var/postgres/postgresql.conf

Uncomment the line with 'log_destination' and set it to 'syslog'

log_destination = 'syslog'

Open the syslog config:

View Devise login from rails console
ApplicationController.allow_forgery_protection = false
app.post('/users/sign_in', {"users"=>{"email"=>"sam@example.com", "password"=>"password"}})
@JunilJacob
JunilJacob / pre-push.sh
Last active Aug 29, 2015 — forked from pixelhandler/pre-push.sh
Git pre-push hook to prevent force pushing master branch
View pre-push.sh
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
You can’t perform that action at this time.