Skip to content

Instantly share code, notes, and snippets.

View dthtien's full-sized avatar
🎯
Focusing

The Tiến dthtien

🎯
Focusing
View GitHub Profile
@dthtien
dthtien / gist:0501c725af1b8a5a0125f35dcb1ad166
Last active November 5, 2024 11:59
Show Ruby and Node versions in ZSH terminal.
function ruby_version()
{
  if which rvm-prompt &> /dev/null; then
    rvm-prompt i v g
  else
    if which ruby &> /dev/null; then
      ruby -v | sed -E 's/.*ruby ([0-9]+\.[0-9]+\.[0-9]+).*/\1/'
 fi
@dthtien
dthtien / post_to_slack.rb
Created March 28, 2020 16:47 — forked from jlecour/post_to_slack.rb
How to post alerts from Monit to Slack
# encoding: UTF-8
require 'optparse'
require 'net/http'
require 'json'
def parse_options(argv)
opts = {}
@parser = OptionParser.new do |o|

Typical rails setup with docker+puma+nginx+postgres

Zaid Annas

Devsinc inc. 30/08/2018

Overview

@dthtien
dthtien / ruby-1.9.3.markdown
Created March 15, 2020 04:41 — forked from pbyrne/ruby-1.9.3.markdown
Comparison of our core Rails app using Webrick, Puma, and Unicorn. Almost no effort was made to optimize either application server. Tests were performed on a MacBook Air using `siege` to hit the application homepage.

TL;DR

Unicorn was by far the best performing (5.94 trans/sec over the 1-minute test, 352 total). Puma (3.95 trans/sec, 235 total) appeared to perform no better than Webrick, despite the default behavior of using up to 16 threads. Perhaps increasing its worker count to the number of cores will improve its performance.

I've tried to run multiple Puma workers with the workers directive (per their sample documentaiton), but I receive errors about undefined method 'workers' for #<Puma::Configuration::DSL:0x007ffca4bde798>).

Webrick

Server

$ bundle exec rails server

@dthtien
dthtien / box-shadow.html
Created February 5, 2020 07:18 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@dthtien
dthtien / 1-setup.md
Created February 3, 2020 08:08 — forked from troyfontaine/1-setup.md
Signing your Git Commits using GPG on MacOS Sierra/High Sierra

Methods of Signing with GPG

There are now two ways to approach this:

  1. Using gpg and generating keys
  2. Using Kryptonite by krypt.co

This Gist explains how to do this using gpg in a step-by-step fashion. Kryptonite is actually wickedly easy to use-but you will still need to follow the instructions

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing with either GPG or Krypt.co.

@dthtien
dthtien / uri.js
Created January 30, 2020 08:20 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@dthtien
dthtien / config.yml
Created November 7, 2019 14:51 — forked from osulyanov/config.yml
Circle CI workflows config to test and deploy Ruby on Rails application with PostgreSQL database. Test with Rspec, precompile assets then deploy with Capistrano.
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/ruby:2.4.1-node-browsers
environment:
@dthtien
dthtien / SomeComponent.js
Last active April 14, 2022 20:22
React Redux code splitting
//views/SomeComponent/index.js
import React from "react";
import { connect } from "react-redux";
import { compose } from "redux";
import reducer, { reducerName as key } from "./reducer";
// import reducerRegistry from "utils/reducerRegistry";
import reducerInjector from "utils/reducerInjector";
function SomeComponent() {
const classes = useStyles();

Keybase proof

I hereby claim:

  • I am dthtien on github.
  • I am dthtien (https://keybase.io/dthtien) on keybase.
  • I have a public key ASAFVpfQFTeq3lXSupt5p-1dWsHzO8bTo5KNoDRkNCPmPQo

To claim this, I am signing this object: