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 / 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'
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
app/assets/javascripts/custom.js
$(document).ready(function() {
let arraySelect2 = [".select2-yourvarname"]
function select2Dynamic(name) {
let id = $(name).attr("data-id")
let text = $(name).attr("data-name")
$(name).select2({
placeholder: "Select Data",
@dhamkur
dhamkur / Basic trello access authorization
Last active February 14, 2022 03:33
basic-trello-access-attachment.txt
How to get your key?
- https://trello.com/app-key
- Copy developer api key
How to get your token?
- https://trello.com/1/authorize?expiration=1day&name=MyPersonalToken&scope=read&response_type=token&key={YourAPIKey}
curl -H "Authorization: OAuth oauth_consumer_key=\"yourKey\", oauth_token=\"yourToken\"" "https://api.trello.com/1/cards/idCard/attachments/idAttachment/download/namefile.jpg" --output "namefile.jpg"
curl -H "Authorization: OAuth oauth_consumer_key=\"yourKey\", oauth_token=\"yourToken\"" "https://api.trello.com/1/members/me"
import ActionCable from "actioncable";
import { ActionCableProvider } from "react-actioncable-provider";
import cookie from "js-cookie";
import constants from "@/libs/constants";
import { useState, useEffect } from "react";
import "react-notifications/lib/notifications.css";
import {
NotificationContainer,
NotificationManager,
} from "react-notifications";
// Documentation Websocket Payload Sample
// Notes: For each available type creating, updating, and deleting
// For "creating" will be send all attributes to payload instead
// of "updating" only send changed attributes to payload
// For comment task and attachment task payload using same
// payload type: "comment"
// URL Connection: wss://cable.staging.virtualspace.ai:3334/cable?config=base64_result(token + auth_key)
@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
@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 / 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 / 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.)