Skip to content

Instantly share code, notes, and snippets.

@sankalpk
sankalpk / api.swagger.json
Last active March 31, 2023 00:46
Swagger
{
"swagger": "2.0",
"info": {
"title": "alias OpenAPI",
"description": "A place to get currency for things",
"version": "1.0.1"
},
"tags": [
{
"name": "TestAPI"
{
"openapi": "3.0.0",
"servers": [
{
"url": "https://gist.githubusercontent.com/"
}
],
"info": {
"title": "alias OpenAPI",
"description": "A place to get currency for things",
@sankalpk
sankalpk / README.md
Created February 3, 2023 13:11
Resque Jobs
@sankalpk
sankalpk / print_rails_headers.md
Created December 12, 2020 06:51
Print headers in a Rails request

Print Headers in a Rails request:

request.headers.env.reject { |key| key.to_s.include?('.') }
@sankalpk
sankalpk / settings.rb
Created December 7, 2020 22:13
See Rails config settings command
Rails.application.config_for(:storage)
@sankalpk
sankalpk / delete_sidekiq_retry_jobs.rb
Created September 1, 2020 21:19
Delete Sidekiq Retry Jobs
query = Sidekiq::RetrySet.new
query.each do |job|
job.delete if job.jid == 'abcdef1234567890'
end
@sankalpk
sankalpk / debugReactHook.js
Last active August 28, 2020 23:16
Add react-hook-form debug component
// Import component and react-hook-form
import { DevTool } from "@hookform/devtools";
import { useForm } from "react-hook-form";
// Grab the control object form from the useForm hook
const { control, register, handleSubmit, errors } = useForm()
// Add component to wherever on the page
<DevTool control={control} />
@sankalpk
sankalpk / log_constants.rb
Created July 21, 2020 01:17
Log Constants
#config/initializers/log_constants
module LogConstantLoading
@@log_depth = 0
def load_missing_constant(from_mod, const_name)
log_loading("load_missing_constant(#{from_mod}, #{const_name})") do
super
end
end
class ArrayValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
array_elements_are_unique(record, attribute, value)
array_elements_are_subset_of_valid_list(record, attribute, value, options[:with])
field_is_present(record, attribute, value)
end
def array_elements_are_unique(record, attribute, value)
if value.present? && (value.uniq.size < value.size)
record.errors.add(attribute, 'are duplicated')
import React, { Component } from 'react'
import mobiscroll from '@mobiscroll/react'
import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles'
import TextInput from 'components/TextInput'
mobiscroll.settings = {
theme: 'material',
themeVariant: 'light',