Skip to content

Instantly share code, notes, and snippets.

View keymastervn's full-sized avatar
🥐
salted egg yolk croissant

Dat Le-Tien keymastervn

🥐
salted egg yolk croissant
  • Employment Hero
  • HCMC, Vietnam
  • 13:30 (UTC +07:00)
View GitHub Profile
@keymastervn
keymastervn / gist:41f1322ad405141f49762a6132a1243e
Created March 27, 2021 12:57
Dockerfile run fullstaq-ruby:2.6.6-jemalloc-buster
## Installing the NodeSource Node.js 10.x repo...
## Populating apt-get cache...
+ apt-get update
Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://security.debian.org/debian-security buster/updates InRelease
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Ign:4 https://dl.bintray.com/fullstaq/fullstaq-ruby-apt debian-10 InRelease
@keymastervn
keymastervn / gist:207566b4d05063237292fd87cc39dc8c
Last active May 3, 2021 15:48
Heroku is simple, but I need to search a lot because only AWS and GCP involve me
$ heroku login
# remember heroku instance is wellplayed with platform below
$ bundle lock --add-platform x86_64-linux --add-platform ruby
# remember postgres is wellplayed too
$ rails new app --database=postgresql
Assume you push already
@keymastervn
keymastervn / Dockerfile
Created November 3, 2020 12:29
The flex Dockerfile for jemalloc ruby-2.6.6
#fullstaq-ruby enables malloc-trim and jemalloc which is said to save up to 50% memory consumption
#ARG RUBY_VERSION=2.6.6-jemalloc
#FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-slim
FROM swipesense/ruby-jemalloc:2.6-buster-slim
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
# Specify JP mirror, other mirrors are less stable than JP's
RUN echo 'deb http://ftp.jp.debian.org/debian/ buster main contrib non-free' > /etc/apt/sources.list
@keymastervn
keymastervn / introrx.md
Created September 28, 2020 11:12 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@keymastervn
keymastervn / Gemfile
Created June 27, 2020 17:50 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@keymastervn
keymastervn / gist:57b1e7da6a762e179e847962febb070c
Created June 23, 2020 15:09
Sanitizable lambda exec raw SQL eliminating params
// non param lambda as a method
def insert_sql
-> (controller, action, title, url, user_id) {
ActiveRecord::Base.connection.execute <<~SQL, [controller, action, title, url, user_id]
insert into dummy(controller, action, title, url, user_id, created_at, updated_at)
values(
$1,
$2,
$3,
$4,
# frozen_string_literal: true
require "spec_helper"
describe PgSearch::Multisearch do
with_table "pg_search_documents", &DOCUMENTS_SCHEMA
with_model :MultisearchableModel do
table do |t|
t.string :title
@keymastervn
keymastervn / EB config to fix rails assets:precompile get EACCES
Last active August 16, 2019 07:58
ERROR in EACCES: permission denied, mkdir '/var/app/ondeck/node_modules/.cache'
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn.sh" :
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
@keymastervn
keymastervn / slim-redux.js
Created August 6, 2019 08:20 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@keymastervn
keymastervn / gist:fd21ac90792a01dfd64c4ba5dd387432
Last active February 17, 2019 10:33
Elastic Beanstalk extension - Nginx example with GZIP configuration
files:
'/etc/nginx/conf.d/01_proxy.conf':
mode: '000644'
owner: root
group: root
content: |
client_max_body_size 10M;
'/etc/nginx/default.d/01_locations.conf':
mode: '000644'
owner: root