Skip to content

Instantly share code, notes, and snippets.

@augustine-tran
augustine-tran / 01_extract_crt.rb
Created January 19, 2019 04:39 — forked from miry/01_extract_crt.rb
Extract certificate from the kubernetes config.
require 'optparse'
require 'yaml'
require 'base64'
options = {
config_path: File.join(ENV['HOME'], '.kube', 'config'),
write_dir: File.join(ENV['HOME'], '.kube')
}
OptionParser.new do |opts|
@augustine-tran
augustine-tran / cloudSettings
Last active November 8, 2019 02:58
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-11-08T02:58:25.662Z","extensionVersion":"v3.4.3"}
@augustine-tran
augustine-tran / download-file.js
Created August 11, 2018 08:27 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@augustine-tran
augustine-tran / docker-cleanup-resources.md
Created April 4, 2017 09:19 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@augustine-tran
augustine-tran / gist:c7098b1a2e14d3260503a0ed027b6ecb
Created March 6, 2017 04:11 — forked from seanmcn/gist:62a021a765ad4f8e593b
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
find . -type f | wc -l
@augustine-tran
augustine-tran / pagination.js
Created February 15, 2017 16:35
Adding pagination to knex.js
var Knex = require('knex');
var Promise = require('bluebird');
Object.assign(Knex.Client.prototype.QueryBuilder.prototype, {
paginate(per_page, current_page) {
var pagination = {};
var per_page = +per_page || 8;
var page = +current_page || 1;
if ( page < 1 ) page = 1;
var offset = (page - 1) * per_page;
@augustine-tran
augustine-tran / NodeJS Atom snippets
Created June 30, 2016 19:41
My Atom snippets for NodeJS
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
#!/bin/bash
#===============================================================================
#
# FILE: getgeo.sh
#
# USAGE: ./getgeo.sh
#
# DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your
# database
#
beta.seorank.net:80 ::1 - - [08/Apr/2016:06:59:32 +0000] "OPTIONS * HTTP/1.0" 200 125 "-" "Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.14 OpenSSL/1.0.1f (internal dummy connection)"
version=2
rule=:%clientip:word% %auth:word% - - [%timestamp:char-to:]%] "%verb:word% %request:word% HTTP/%httpversion:float%" %response:number% %bytes:number% "%apacheserver:char-to:/%/%version:word% (%os:char-to:)%)%blob:rest%