Skip to content

Instantly share code, notes, and snippets.

View hdchinh's full-sized avatar
🍀
I may be slow to respond.

hdchinh hdchinh

🍀
I may be slow to respond.
  • Viet Nam
  • 21:20 (UTC +07:00)
View GitHub Profile
require "prawn"
class AddWatermarkService
def initialize(cv)
@cv = cv
end
def perform
begin
return { cv: @cv, success: false } if File.extname(@cv.original_filename) != ".pdf"
1. Gemfile
gem 'ckeditor', github: 'galetahub/ckeditor'
2. bundle install
3. app/assets/javascripts/application.js
//= require ckeditor/init
4. config/initializers/active_admin.rb
@hdchinh
hdchinh / directions.md
Created July 18, 2021 09:00 — forked from omushpapa/directions.md
Deploy Django App on Heroku

Requirements

Run pip install pipenv to install pipenv

Run pipenv shell to create an environment, if does not exist, and activate it.

Run pipenv install python_decouple whitenoise dj_database_url Pillow gunicorn May take a while.

This should create two files: Pipfile and Pipfile.lock. Keep them in the project root.

class AppleSignInController < ApplicationController
APPLE_PEM_URL = "https://appleid.apple.com/auth/keys"
# /api/apple/validate
def validate
name = params[:name]
userIdentity = params[:userIdentity]
jwt = params[:jwt]
@hdchinh
hdchinh / react-rendering.md
Created March 28, 2021 11:43 — forked from tuhuynh27/react-rendering.md
A (Mostly) Complete Guide to React Rendering Behavior

Translated from https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-mostly-complete-guide-to-react-rendering-behavior/, author: Mark Erikson (from Redux team)

A (Mostly) Complete Guide to React Rendering Behavior

Bài viết cung cấp chi tiết về cách mà React render hoạt động, và việc sử dụng Context và Redux ảnh hưởng thế nào tới quá trình render của React.

"Render" là gì

Rendering is the process of React asking your components to describe what they want their section of the UI to look like, now, based on the current combination of props and state.

@hdchinh
hdchinh / gist:ed67daa2ca6e047e29a1ead8c320b8bf
Created January 1, 2021 03:47 — forked from eikes/gist:5a64b661022c756bd6522ed94770e2a6
List of Ruby on Rails Timezone names and their alias
["Africa/Algiers", "West Central Africa"],
["Africa/Cairo", "Cairo"],
["Africa/Casablanca", "Casablanca"],
["Africa/Harare", "Harare"],
["Africa/Johannesburg", "Pretoria"],
["Africa/Monrovia", "Monrovia"],
["Africa/Nairobi", "Nairobi"],
["America/Argentina/Buenos_Aires", "Buenos Aires"],
["America/Bogota", "Bogota"],
["America/Caracas", "Caracas"],
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
  1. Form
  2. Router
import React from 'react';
class App extends React.Component {
handleClick = (e, data) => {
console.log(data);
}
render() {
const data = 10;
const data2 = 20;
@hdchinh
hdchinh / basic-vimrc.txt
Created August 13, 2019 09:38
Basic vim config
1 filetype indent on
2 set ai
3 set mouse=r
4 set incsearch
5 set confirm
6 set number
7 set ignorecase
8 set smartcase
9 set wildmenu
10 set wildmode=list:longest,full