Skip to content

Instantly share code, notes, and snippets.

View polarlights's full-sized avatar

Polar Lights polarlights

  • Shanghai, PRC.
View GitHub Profile
@polarlights
polarlights / spring-boot-docker.md
Created July 18, 2021 01:25 — forked from msauza/spring-boot-docker.md
Multi-Layer, Multi-Stage: Spring Boot application with Docker.

Overview

Spring Boot applications can run within a container by Multi-Layer based approach. Each layer may contain different parts of the application such as dependencies, source code, resources and even snapshot dependencies.

In the other hand, with Multi-Stage Build approach, any application can be built at a separate image from the final image that will contain the runnable application.

Spring Boot Docker

Multi-Layer

@polarlights
polarlights / defaultdns.md
Created July 10, 2021 15:17 — forked from superseb/defaultdns.md
Change default DNS nameserver used by Kubernetes pods

Change default DNS nameserver used by Kubernetes pods

This can be applied generically but usually applies to Linux nodes that have a local caching nameserver running, which means pointing to an IP in the loopback range (127.0.0.0/8). Ubuntu 18.04 Bionic Beaver does this by default.

Option 1: Change host configuration

sudo systemctl mask systemd-resolved
rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop
@polarlights
polarlights / with_active_support.rb
Created June 6, 2017 08:50 — forked from tonytonyjan/rails_42_with_active_support.rb
session cookie decrypter for Rails 4.2+
require 'cgi'
require 'json'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base)
cookie = CGI::unescape(cookie)
salt = 'encrypted cookie'
signed_salt = 'signed encrypted cookie'
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key(salt)
@polarlights
polarlights / decode_session_cookie.rb
Created April 18, 2016 05:30 — forked from pdfrod/decode_session_cookie.rb
A simple script to decode Rails 4 session cookies
@polarlights
polarlights / packer_docker_log.log
Created January 11, 2016 07:41
packer_docker_log.log
ubuntu@ip-172-31-17-29:~/ansible_docker$ packer build templates/production/docker_mysql.json
docker output will be in this color.
==> docker: Creating a temporary directory for sharing data...
==> docker: Starting docker container...
docker: Run command: docker run -v /tmp/packer-docker353976599:/packer-files -d -i -t alo7/ubuntu:base_server /bin/bash
docker: Container ID: 0679b2f24b7cce27257597f18ba8cc5e1616cda9006aa93373a36ab397de1079
==> docker: Provisioning with shell script: provision/scripts/install_common.sh
docker: Install common software ...
docker: Reading package lists...
@polarlights
polarlights / deploy.rb
Created December 20, 2015 13:55 — forked from wlangstroth/deploy.rb
Capistrano + Nginx + Unicorn + Sinatra on Ubuntu
require 'bundler/capistrano'
set :application, "net"
set :repository, "git@githost.com:net.git"
set :scm, :git
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
@polarlights
polarlights / sinatra.md
Created December 19, 2015 08:37 — forked from ashrithr/sinatra.md
Intro to Sinatra

Sinatra

Installation:

Dependencies: ruby

gem install sinatra
@polarlights
polarlights / image-proxy.conf
Created December 18, 2015 11:08 — forked from tmaiaroto/image-proxy.conf
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.