Skip to content

Instantly share code, notes, and snippets.

View dungdm93's full-sized avatar
🏁
Working hard

Đặng Minh Dũng dungdm93

🏁
Working hard
  • VPBank
  • Hanoi, Vietnam
  • Facebook dungdm93
View GitHub Profile
@dungdm93
dungdm93 / 0-README.md
Last active July 7, 2019 04:10
Django serve staticfiles

Django Staticfiles

Django staticfiles is the most common problem you need to solve before putting your app on the production. In this tutorial, I and you will walk through the solution options, included.

  • runserver: Only in development environment.
  • gunicorn: Use gunicorn as your app server.
  • nginx: Put nginx web server in a front of your app server (gunicorn).
  • whitenoise: Let your django app self-serve static files.
@dungdm93
dungdm93 / bash-color.sh
Created October 23, 2018 04:16
Colorize terminal
#!/bin/bash
##### Color table #####
# Black 0;30 Dark Gray 1;30
# Red 0;31 Light Red 1;31
# Green 0;32 Light Green 1;32
# Brown/Orange 0;33 Yellow 1;33
# Blue 0;34 Light Blue 1;34
# Purple 0;35 Light Purple 1;35
# Cyan 0;36 Light Cyan 1;36
@dungdm93
dungdm93 / jinja-cli.py
Last active October 18, 2018 14:31
Render Jinja template
import jinja2
loader = jinja2.FileSystemLoader(searchpath="./")
env = jinja2.Environment(loader=loader)
TEMPLATE_FILE = "template.j2"
template = env.get_template(TEMPLATE_FILE)
output = template.render()
print(f"[{output}]")
@dungdm93
dungdm93 / paas-gae.yml
Last active August 20, 2021 14:08
GitLab-CI: Deploy Scripts
deploy:paas-gae:
stage: deploy
image: google/cloud-sdk
before_script:
- echo "${GCLOUD_SERVICE_KEY}" > /tmp/.gsa.key
- gcloud auth activate-service-account --key-file /tmp/.gsa.key
- gcloud config set project "${PROJECT_NAME}" # TODO: change this
script:
- gcloud app deploy
environment:
@dungdm93
dungdm93 / android-gradle.yml
Last active January 26, 2024 06:49
GitLab-CI: Caching by package manager
variables:
ANDROID_COMPILE_SDK: "28"
test:unit:
image: circleci/android:api-${ANDROID_COMPILE_SDK}
cache:
key: gradle-cache
paths: [ .gradle ]
variables:
# GRADLE_OPTS: "-Dorg.gradle.daemon=false"
alias ..='cd ..'
if [[ ! "$PATH" =~ (^|:)"$HOME/.local/bin"(:|$) ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]] && source "$SDKMAN_DIR/bin/sdkman-init.sh"
export NVM_DIR="$HOME/.nvm"
@dungdm93
dungdm93 / gitlab.rb
Last active July 1, 2023 12:48
Gitlab OAuth2 with Google
### OmniAuth Settings
###! Docs: https://docs.gitlab.com/ce/integration/omniauth.html
gitlab_rails['omniauth_enabled'] = true # Show "Signin with..." button in Login page
gitlab_rails['omniauth_allow_single_sign_on'] = ['google_oauth2'] # Create account automatically
# gitlab_rails['omniauth_sync_email_from_provider'] = 'saml'
gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'google_oauth2' # Redirect to provider login page when enter gitlab login page
# gitlab_rails['omniauth_block_auto_created_users'] = true # true: auto-created user must be admin approved
# gitlab_rails['omniauth_auto_link_ldap_user'] = false
# gitlab_rails['omniauth_auto_link_saml_user'] = false
# gitlab_rails['omniauth_external_providers'] = ['twitter', 'google_oauth2']
@dungdm93
dungdm93 / web-fragment.xml
Last active May 7, 2016 07:16
Sample web.xml
<web-fragment version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd">
</web-fragment>
@dungdm93
dungdm93 / serializable.rb
Created March 19, 2016 11:20
Serializable Attribute
module Serializable
extend ActiveSupport::Concern
module ClassMethods
def dump(obj)
return if obj.nil?
assert_valid_value obj
ActiveSupport::JSON.encode obj
end
@dungdm93
dungdm93 / YAML.rb
Created March 16, 2016 09:24
serialize using YAML coder
###
# define serialize in +ActiveRecord::AttributeMethods::Serialization#serialization+
# => create coder
# which is used in +ActiveRecord::Type::Serialized+
# attr is loaded in +ActiveRecord::Type::Serialized#type_cast_from_database+
# attr is dumped in +ActiveRecord::Type::Serialized#type_cast_for_database+
###
# active_record/coders/yaml.rb
module ActiveRecord::Coders