Skip to content

Instantly share code, notes, and snippets.

View dhamkur's full-sized avatar
🏠
Working from home

dhamkur dhamkur

🏠
Working from home
  • VirtualSpirit
  • Indonesia
View GitHub Profile
@dhamkur
dhamkur / rails http status codes
Created June 14, 2023 11:25 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@dhamkur
dhamkur / postgres.md
Created May 11, 2023 02:03 — forked from phortuin/postgres.md
Set up postgres + database on MacOS (M1)

Based on this blogpost.

Install with Homebrew:

$ brew install postgresql@14

(The version number 14 needs to be explicitly stated. The @ mark designates a version number is specified. If you need an older version of postgres, use postgresql@13, for example.)

@dhamkur
dhamkur / api_controller.rb
Created May 8, 2023 19:18 — forked from ArturT/api_controller.rb
How to rescue ActionDispatch::Http::MimeNegotiation::InvalidType in API controller for Rails 6.1+ and render nice JSON error. Learn more how you could run RSpec/Minitest tests faster in Rails app https://docs.knapsackpro.com/2020/how-to-speed-up-ruby-and-javascript-tests-with-ci-parallelisation
# This is example how to rescue from exception ActionDispatch::Http::MimeNegotiation::InvalidType
# and show nice JSON error in your API
module API
class BaseController < ActionController::API
def process_action(*args)
super
rescue ActionDispatch::Http::MimeNegotiation::InvalidType => exception
# set valid Content-Type to be able to call render method below
request.headers['Content-Type'] = 'application/json'
render status: 400, json: { errors: [exception.message] }
@dhamkur
dhamkur / submit.md
Created May 8, 2023 19:15 — forked from tanaikech/submit.md
Sample Scripts for Creating New Event with Google Meet Link to Google Calendar using Various Languages

Sample Scripts for Creating New Event with Google Meet Link to Google Calendar using Various Languages

This is the sample scripts for creating new event with Google Meet link to Google Calendar using various languages. When I saw the official document of "Add video and phone conferences to events", in the current stage, I can see only the sample script for Javascript. But I saw the several questions related to this for various languages. So I published the sample scripts for creating new event with Google Meet link to Google Calendar using various languages.

In order to create new event with Google Meet link to Google Calendar, it is required to set the request body and query parameter as follows.

Please add the following object to the request body.

conferenceData: {
@dhamkur
dhamkur / Webpack and toastr
Created February 16, 2023 16:58 — forked from MFry/Webpack and toastr
Getting toastr npm to play with webpack
//In case anyone was having the same issue in getting toastr to run with webpack and es6
class ImageUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
process :tags => ['post_picture']
version :standard do
process :resize_to_fill => [100, 150, :north]
end
version :article do
@dhamkur
dhamkur / application_helper.rb
Created January 20, 2019 06:58
Ruby on Rails. Class "active" for menu items based on Path or Controller and Action names
module ApplicationHelper
def active_for(options = {})
name_of_controller = options[:controller] || nil
name_of_action = options[:action] || nil
request_path = options[:path] || nil
if request_path.nil?
if (name_of_action.nil? or name_of_action == action_name) and
name_of_controller == controller_name
'active'