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 / 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*
@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;
#!/bin/bash
#===============================================================================
#
# FILE: getgeo.sh
#
# USAGE: ./getgeo.sh
#
# DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your
# database
#
@augustine-tran
augustine-tran / S3-CORS-config.xml
Created December 23, 2015 14:05 — forked from zxbodya/S3-CORS-config.xml
Client side uploads to s3, with pre-signed upload form (PHP/JS)
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
- (IBAction)buyMoreButtonClicked:(id)sender
{
[GGProgressHUD showActivity];
NSString *productId = IAP_PRODUCT_CREDIT;
SKProduct *product = [[TNStoreHelper requestedProducts] valueForKey:productId];
if (product) {
[self purchaseProduct:product];
return;
}
- (IBAction)buyMoreButtonClicked:(id)sender
{
[GGProgressHUD showActivity];
NSString *productId = nil;
if (sender == btnCredit1) {
productId = IAP_PRODUCT_CREDIT1;
} else if (sender == btnCredit2) {
productId = IAP_PRODUCT_CREDIT2;
} else {
productId = IAP_PRODUCT_CREDIT3;
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db