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 / 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() {
@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 / 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 / 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
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'
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}"
@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:
@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 / 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 / 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)