Skip to content

Instantly share code, notes, and snippets.

View tridungle's full-sized avatar

Trí Dũng Lê tridungle

  • Independent
  • Ho Chi Minh
View GitHub Profile
@tridungle
tridungle / svn_autocommit.sh
Created October 3, 2015 09:25 — forked from niwo/svn_autocommit.sh
Bash script for auto-committing from a SVN working copy
#!/bin/bash
### Settings
svn_wk='/srv/tftp/data/'
svn_user='user'
svn_passwd='passwd'
### Variables
date=`date +"%F %T"`
svn='/usr/bin/svn'
@tridungle
tridungle / mingw-w64-3.10-osx10.9.sh
Created October 4, 2015 09:27 — forked from Drakulix/mingw-w64-3.10-osx10.9.sh
Script to install a Mingw-w64 Cross-Compiler Suite on Mac OS X 10.9
#!/bin/sh
# dependencies
echo "Installing dependencies via Homebrew (http://brew.sh)"
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew update
brew install gcc48
@tridungle
tridungle / gist:b371f983d8cfcf0d8ae6
Created November 21, 2015 19:09 — forked from ericandrewlewis/gist:95239573dc97c0e86714
Setting up a WordPress site on AWS

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

@tridungle
tridungle / nginx
Created January 12, 2016 17:12 — forked from tejasbubane/nginx
nginx logrotate script for centOS. Location: /etc/logrotate.d/nginx. Later change /etc/logrotate.conf add daily and change or comment "rotate" number (preferably comment to keep all log files -> symlinked to /mnt so no space issue)
/opt/nginx/logs/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
@tridungle
tridungle / twitter.js
Created September 13, 2017 16:45 — forked from cjoudrey/twitter.js
Lazy-rendering in PhantomJS
// This example shows how to render pages that perform AJAX calls
// upon page load.
//
// Instead of waiting a fixed amount of time before doing the render,
// we are keeping track of every resource that is loaded.
//
// Once all resources are loaded, we wait a small amount of time
// (resourceWait) in case these resources load other resources.
//
// The page is rendered after a maximum amount of time (maxRenderTime)
@tridungle
tridungle / rest-api-design.md
Created April 25, 2018 09:43 — forked from dexterbt1/rest-api-design.md
REST API Design Checklist

Inputs:

  • State requirements
  • Number of clients
  • Security classification of data in the API request or response
  • Peak volumes
  • Service level distinctions for clients
  • Availability requirements
  • Latency expectations
  • Business metrics
  • Transactionality
@tridungle
tridungle / intro.md
Created March 27, 2019 18:13 — forked from derhuerst/intro.md
Installing Git on Linux, Mac OS X and Windows
@tridungle
tridungle / storeImgInMongoWithMongoose.js
Created March 30, 2019 15:44 — forked from aheckmann/storeImgInMongoWithMongoose.js
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@tridungle
tridungle / hero.ts
Created June 13, 2019 06:57 — forked from brennanMKE/hero.ts
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
import { Request, Response, NextFunction, Router } from "express";
import * as ErrorHandler from "../utils/ErrorHandler";
const handle404Error = (router: Router) => {
router.use((req: Request, res: Response) => {
ErrorHandler.notFoundError();
});
};
const handleClientError = (router: Router) => {