Skip to content

Instantly share code, notes, and snippets.

View bhushangahire's full-sized avatar

Bhushan Ahire bhushangahire

View GitHub Profile
@bcnzer
bcnzer / postman-pre-request.js
Last active July 16, 2024 12:05
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@goncalvesjoao
goncalvesjoao / Gemfile
Last active November 13, 2020 01:52
Changes you need to make in order to make Devise use JWT Header Authentication
# Add the "https://github.com/jwt/ruby-jwt" gem to your "Gemfile"
gem 'jwt'
@Val
Val / build_rest-like_api.rb
Created January 19, 2016 14:28
Token protected REST-like API using Grape, Swagger on top of Rails. Based on http://www.toptal.com/ruby/grape-gem-tutorial-how-to-build-a-rest-like-api-in-ruby/
# -*- mode:ruby;tab-width:2;indent-tabs-mode:nil;coding:utf-8 -*-
# vim: ft=ruby syn=ruby fileencoding=utf-8 sw=2 ts=2 ai eol et si
#
# build_rest-like_api.rb: sample REST-like API server
# (c) 2016 Laurent Vallar <val@zbla.net>, WTFPL license v2 see below.
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
@Brunas
Brunas / FC-Screenshot.png
Last active September 15, 2020 22:53
Freeday Countdown widget
FC-Screenshot.png
@stevegrossi
stevegrossi / jmeter.rb
Last active March 19, 2018 16:16
Sample JMeter test plan using the ruby-jmeter gem
#!/usr/bin/env ruby
require 'ruby-jmeter'
test do
defaults domain: 'beta.stevegrossi.com'
cookies clear_each_iteration: true
@adamico
adamico / en.yml
Last active June 21, 2017 05:46 — forked from johnjohndoe/uri_validator.rb
Rails 4 with I18n working interpolations
en:
errors: &errors
messages:
bad_uri: is an invalid url
bad_protocol: must start with %{protocols}
activemodel:
errors:
<<: *errors
activerecord:
errors:
source 'https://rubygems.org'
gem 'dashing'
gem 'activesupport'
gem 'zabby'
gem 'therubyracer', :platforms => :ruby
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@tinynumbers
tinynumbers / active_admin.rb
Last active April 21, 2024 08:57
ActiveAdmin controller extension to persist resource index filters between requests.
# this stuff goes in config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# ...
# put these lines in the "Controller Filters" section of the ActiveAdmin.setup block
# These two are defined in ActiveAdmin::FilterSaver::Controller, which is loaded below.
config.before_filter :restore_search_filters
@rlmattax
rlmattax / gist:3962926
Created October 27, 2012 04:20
Active Admin User Impersonation
ActiveAdmin.register User do
menu :parent => "Users"
member_action :impersonate, :method => :get do
user = User.find(params[:id])
flash[:notice] = "Successfully logged in as : #{user.email} #{view_context.link_to('Be careful!', root_path)}".html_safe
begin
warden.set_user(resource,{:scope=>:user,:run_callbacks=>false})
rescue
flash[:error] = "Unable to log you in. Poop."