Skip to content

Instantly share code, notes, and snippets.

View zelic91's full-sized avatar
💭
It's always good to write down something

Thuong Nguyen zelic91

💭
It's always good to write down something
  • Restaff
  • Vietnam
View GitHub Profile
@zelic91
zelic91 / secure.conf
Last active June 29, 2021 09:39
Secure Nginx Config
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
add_header Content-Security-Policy "default-src 'self'; font-src *;img-src * data:; script-src *; style-src *";
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
add_header Referrer-Policy "strict-origin";
add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()";
add_header Access-Control-Allow-Origin 'https://<some full domain>';
add_header Access-Control-Allow-Methods 'GET, OPTIONS, HEAD, POST, PUT, DELETE';
add_header Access-Control-Allow-Headers 'Authorization, X-App-Token, X-Access-Token, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type';
@zelic91
zelic91 / .bashrc
Created June 9, 2021 11:23
CURL with various time info
curl_time() {
curl -so /dev/null -w "\
namelookup: %{time_namelookup}s\n\
connect: %{time_connect}s\n\
appconnect: %{time_appconnect}s\n\
pretransfer: %{time_pretransfer}s\n\
redirect: %{time_redirect}s\n\
starttransfer: %{time_starttransfer}s\n\
-------------------------\n\
total: %{time_total}s\n" "$@"
@zelic91
zelic91 / sample.conf
Created June 3, 2021 06:14
Log rotate template
/home/<some directories>/log/*.log {
daily
rotate 7
size 10M
compress
delaycompress
}
@zelic91
zelic91 / sample-exec.rb
Created June 2, 2021 10:06
Sample ruby executable
require_relative 'base_exec'
class SampleExec < BaseExec
def initialize()
super()
end
def run!
super
@zelic91
zelic91 / base-exec.rb
Created June 2, 2021 02:59
Ruby standalone daemon base app
class BaseExec
def initialize()
@prefix = self.class.name.underscore
@pid_file = Rails.root.join("pids/#{@prefix}.pid")
@log_file = Rails.root.join("logs/#{@prefix}.log")
end
def run!
@zelic91
zelic91 / index.js
Created May 30, 2021 07:11
Lambda Function for Slack Notification
var https = require('https');
var util = require('util');
exports.handler = (event, context) => {
const message = JSON.parse(event.Records[0].Sns.Message);
console.log(JSON.stringify(event, null, 2));
console.log('Data From SNS: ', message);
const postData = {
@zelic91
zelic91 / IconView.kt
Created May 12, 2021 10:10 — forked from nickbutcher/IconView.kt
A prototype implementation of a shadow effect inspired by the Google Play Games app (https://play.google.com/store/apps/details?id=com.google.android.play.games).
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@zelic91
zelic91 / install_ssl.txt
Created June 19, 2020 08:09 — forked from emprit1988/install_ssl.txt
Install Entrust SSL in NGINX Server running in Ubuntu 14.04
Step 1: Create chained certificate with the provided crt files. Ordering is important.
~$ cat Server.crt Intermediate.crt Root.crt > Chained_certificate.crt
Step 2: Format the concatenation
The crt file should Follow the syntax
-----Start Certificate-----
############################
############################
-----End Certificate-----
info face="Arial-BoldMT" size=37 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2
common lineHeight=42 base=35 scaleW=128 scaleH=64 pages=1 packed=0
page id=0 file="bitmap-font-sample-1.png"
chars count=11
char id=32 x=103 y=33 width=0 height=0 xoffset=0 yoffset=34 xadvance=10 page=0 chnl=0 letter="space"
char id=48 x=86 y=2 width=19 height=29 xoffset=2 yoffset=5 xadvance=21 page=0 chnl=0 letter="0"
char id=49 x=88 y=33 width=13 height=28 xoffset=3 yoffset=6 xadvance=21 page=0 chnl=0 letter="1"
char id=50 x=46 y=33 width=19 height=28 xoffset=1 yoffset=6 xadvance=21 page=0 chnl=0 letter="2"
char id=51 x=23 y=2 width=19 height=29 xoffset=1 yoffset=5 xadvance=21 page=0 chnl=0 letter="3"
char id=52 x=2 y=33 width=21 height=28 xoffset=1 yoffset=6 xadvance=21 page=0 chnl=0 letter="4"
@zelic91
zelic91 / FadeScrollView.swift
Created November 15, 2018 02:45 — forked from luismachado/FadeScrollView.swift
Custom UIScrollView with fade effect
//
// FadeScrollView.swift
//
// Created by Luís Machado on 23/06/2017.
// Copyright © 2017 Luis Machado. All rights reserved.
//
import UIKit
class FadeScrollView: UIScrollView, UIScrollViewDelegate {