Skip to content

Instantly share code, notes, and snippets.

View hmphu's full-sized avatar
🎯
Focusing

Hoang Manh Phu hmphu

🎯
Focusing
View GitHub Profile
@hmphu
hmphu / README.md
Created April 6, 2018 12:00 — forked from adieuadieu/README.md
A simple command line script to grab screenshots of a URL in multiple screen widths (desktop, tablet, mobile, or Twitter Bootstrap breakpoints) using PhantomJS.

Speelycaptor-lite

What is it

A simple command line script to grab screenshots of a URL in multiple screen widths (desktop, tablet, mobile, or Twitter Bootstrap breakpoints) using PhantomJS. Useful for quickly generating images of websites or in-the-browser design processes to share with team members of a client.

Prerequisites

  • OS with bash
  • You'll need to install PhantomJS. On OS X, the easiest way to do this is with Brew. $ brew install phantomjs should do it.

Try it

@hmphu
hmphu / myservice
Created March 20, 2018 05:10 — forked from bramus/myservice
Running a PHP script as a service/daemon using `start-stop-daemon`
#! /bin/sh
# Installation
# - Move this to /etc/init.d/myservice
# - chmod +x this
#
# Starting and stopping
# - Start: `service myservice start` or `/etc/init.d/myservice start`
# - Stop: `service myservice stop` or `/etc/init.d/myservice stop`
@hmphu
hmphu / turn off spindumps
Created February 23, 2018 13:08 — forked from ssp/turn off spindumps
Turn off spindump in MacOS X. This can improve the performance of the whole system in some situations.
launchctl unload -w /System/Library/LaunchDaemons/com.apple.spindump.plist
@hmphu
hmphu / opcache.ini
Created December 21, 2017 10:03 — forked from tegansnyder/opcache.ini
OpCache settings for Magento on PHP 5.5.14. Store this file as /etc/php.d/opcache.ini
; Enable Zend OPcache extension module
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
; The OPcache shared memory storage size.
@hmphu
hmphu / .tmux.conf
Created December 16, 2017 05:47
Tmux Configuration
# ~/.tmux.conf
###########################################################################
# General options
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# Ring the bell if any background window rang a bell
set -g bell-action any
@hmphu
hmphu / magentoSmartIndexCacheRefresh.sh
Created July 11, 2017 04:31 — forked from steverobbins/magentoSmartIndexCacheRefresh.sh
A Magento 1 script that will only reindex and refresh caches that have been invalidated.
#!/bin/bash
# Smart Magento reindexing and cache clearing. Only indexes and caches that are
# invalidate are cleared. Place this file in your shell/ directory and make it
# executable: chmod +x magentoSmartIndexCacheRefresh.sh
#
# Before use it is recommended to consider your failures as a developer due to
# lack of ability to correctly update individual indexes and caches as records
# modified processed.
#
@hmphu
hmphu / youtube_id_regex.php
Created July 6, 2017 10:05 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@hmphu
hmphu / install.sh
Created May 29, 2017 11:35 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
import asyncio
from concurrent.futures import ProcessPoolExecutor
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import aiohttp
import bs4
import uvloop
import mailer
@hmphu
hmphu / gist:b5f6f0cd25c23670a4094ead6e83d9b1
Created December 18, 2016 18:28 — forked from wrburgess/gist:5528649
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production