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 / BST
Created September 5, 2019 10:44
The easiest way to implement BST in python
class Node:
def __init__(self, val):
self.val = val
self.left_child = None
self.right_child = None
# def get(self):
# return self.val
# def set(self, val):
@monogot
monogot / docker-compose.yml
Last active September 4, 2019 07:57
Docker-compose file for ELK stack
version: '2'
services:
elasticsearch:
build:
context: elasticsearch/
args:
ELK_VERSION: $ELK_VERSION
volumes:
input {
tcp {
port => 5000
}
}
filter {
grok {
match => {
"message" => "%{SYSLOG5424PRI:pri}%{NUMBER:rfc_version} %{TIMESTAMP_ISO8601:timestamp} d.%{UUID:drain_id} %{WORD:app} %{USERNAME:dyno} - - %{GREEDYDATA:message}"
alias k='clear'
alias ll='ls -al'
alias fs='foreman start -f Procfile.dev'
alias gcd='git checkout develop'
alias gcp='git checkout -'
alias grd='git rebase develop'
alias gam='git commit --amend --no-edit'
alias gpf='git push -f'
alias gcb='git checkout -b'
alias gp='git pull origin'
@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 = []