Skip to content

Instantly share code, notes, and snippets.

View quangbahoa's full-sized avatar
🎯
Focusing

Le Duy Quang quangbahoa

🎯
Focusing
View GitHub Profile
# If you meet install errors, see abid-hussain's comment
sudo apt-get --force-yes install build-essential openssl libreadline6 libreadline6-dev curl git-core \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev \
libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
&&
\curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
module Jekyll
class ArchivePage
include Convertible
attr_accessor :site, :pager, :name, :ext, :basename, :dir, :data, :content, :output
# Initialize new ArchivePage
# +site+ is the Site
# +month+ is the month
# +posts+ is the list of posts for the month
module Jekyll
class ArchiveGenerator < Generator
safe true
def generate(site)
collate_by_month(site.posts).each do |month, posts|
page = ArchivePage.new(site, month, posts)
site.pages << page
end
end
@quangbahoa
quangbahoa / fix_ubuntu_old.dev.txt
Created August 6, 2014 10:06
How to fix Ubuntu/Debian apt-get 404 Not Found Package Repository Errors (Saucy, Raring, Quantal, Oneiric, Natty…)
Run this command below on your server and it will replace all of the archive.ubuntu.com and security.ubuntu.com package repository URLs with old-releases.ubuntu.com
sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
You may also want to see if there are other files in /etc/apt/sources.list.d/ that need to be updated, which can be done with a simple grep command:
grep -E 'archive.ubuntu.com|security.ubuntu.com' /etc/apt/sources.list.d/*
<?php
/**
* Plugin Name: Add Blog and User ID on Network
* Plugin URI: http://wpengineer.com/2188/view-blog-id-in-wordpress-multisite/
* Description: View Blog and User ID in WordPress Multisite
* Version: 1.0.0
* Author: Frank Bültge
* Author URI: http://bueltge.de
* License: GPLv3
*/
<?php # -*- coding: utf-8 -*-
// function remove_accents()
/**
* Unaccent the input string string. An example string like `ÀØėÿᾜὨζὅБю`
* will be translated to `AOeyIOzoBY`. More complete than :
* strtr( (string)$str,
* "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
* "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn" );
*
@quangbahoa
quangbahoa / wp-config.php
Created November 19, 2014 03:00
wp debug logging
// Enable WP_DEBUG mode
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
@quangbahoa
quangbahoa / VPS.md
Created December 22, 2014 05:04
Gist log test

Optimizing Apache for a VPS 1GB RAM!

Backup file config của Apache bằng lệnh dưới:

sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.backup.conf

Chỉnh sửa file config bằng lệnh dưới:

@quangbahoa
quangbahoa / .htaccess
Created April 10, 2015 07:16
WordPress Leverage browser caching
## LEVERAGE BROWSER CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
@quangbahoa
quangbahoa / google-scripts.js
Last active August 29, 2015 14:20 — forked from duttajit50/sendsms
Send Google SMS
function sendsms()
{
try
{
var label = GmailApp.getUserLabelByName('sendsms');
var threads = label.getThreads();
var now = new Date().getTime();
var cal=getCalendar();
for(i in threads)