Skip to content

Instantly share code, notes, and snippets.

View monogot's full-sized avatar
🎯
Focusing

Kirati Samatthanares monogot

🎯
Focusing
View GitHub Profile
@monogot
monogot / deleteAvatar.js
Created December 13, 2022 17:11 — forked from SylarRuby/deleteAvatar.js
Deletes a s3 bucket object by a known unique key 💥
/**
* Delete an image from the S3 Bucket
*
* @author Daveyon Mayne <@MirMayne>
* @date July 14th 2019
*/
const AWS = require('aws-sdk');
const deletePhoto = async (avatar_url) => {
@monogot
monogot / userAvatar.js
Created December 13, 2022 17:11 — forked from SylarRuby/userAvatar.js
NodeJs AWS S3 Upload
/**
* This gist was inspired from https://gist.github.com/homam/8646090 which I wanted to work when uploading an image from
* a base64 string.
* Updated to use Promise (bluebird)
* Web: https://mayneweb.com
*
* @param {string} base64 Data
* @return {string} Image url
*/
const imageUpload = async (base64) => {
@monogot
monogot / example_job.rb
Created November 18, 2019 15:29 — forked from wrburgess/example_job.rb
ActiveJob on Rails 5 with RSpec
# app/jobs/example_job.rb
class ExampleJob < ActiveJob::Base
queue_as :default
rescue_from(ActiveRecord::RecordNotFound) do
retry_job wait: 1.minute, queue: :default
end
def perform(param_1, param_2)
@monogot
monogot / example_activejob.rb
Created November 18, 2019 15:26 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
@monogot
monogot / rails_webpacker_bootstrap_expose_jquery.md
Created July 11, 2018 05:11 — forked from andyyou/rails_webpacker_bootstrap_expose_jquery.md
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collect all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new  --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@monogot
monogot / obervable_example.rb
Created June 27, 2018 08:30 — forked from jensendarren/obervable_example.rb
Example of using Observable in Ruby
require 'observer'
class CoffeeShop
include Observable
attr_reader :customers
def initialize(name, capacity)
@name = name
@capacity = capacity
@customers = []
@monogot
monogot / 00.md
Created November 18, 2017 11:16 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@monogot
monogot / terminal-git-branch-name.md
Created November 2, 2017 09:48 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {