Skip to content

Instantly share code, notes, and snippets.

View extralam's full-sized avatar
🎯
Focusing

Alan Lam extralam

🎯
Focusing
View GitHub Profile
@extralam
extralam / first-init-ubuntu-with-docker-and-docker-compose.sh
Last active October 30, 2018 05:56
first-init-ubuntu-with-docker-and-docker-compose.sh
curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh
sudo usermod -aG docker $USER
sudo service docker restart
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
@extralam
extralam / docker-compose.yml
Last active March 11, 2019 06:00
nginx-proxy for docker
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
networks:
- front
- back
ports:
@extralam
extralam / rating.php
Created October 3, 2018 11:26
wordpress woocommerce review count is always 0
<?php
/**
* Single Product Rating
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/rating.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@extralam
extralam / Instructions.sh
Created May 10, 2018 09:48 — forked from GhazanfarMir/Instructions.sh
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
@extralam
extralam / quickfix.js
Created February 2, 2018 10:15
offsetting an html anchor to adjust for fixed header
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 125 //offsets for fixed header
@extralam
extralam / TimeLogger.php
Created August 28, 2017 02:38
TimeLogger , a logger printout. Check running time.
/**
* User: alan
* Date: 22/6/2017
* Time: 6:34 PM
*/
namespace TimeLogger;
class TimeLogger
{
@extralam
extralam / URLImageParser.java
Created April 12, 2017 02:53
URLImageParser - TextView show Image html , use Glide Image Library
import java.util.ArrayList;
import com.bumptech.glide.GenericRequestBuilder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import android.content.Context;
@extralam
extralam / AutoScrollViewPager.java
Last active March 23, 2017 04:32
AutoScroll ViewPager
import android.content.Context;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;
import java.lang.reflect.Field;
@extralam
extralam / Keyboardhelper.java
Last active February 28, 2017 09:01
Android Keyboard Open or Close helper
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import static android.os.Build.VERSION.SDK_INT;
@extralam
extralam / install_docker.sh
Created December 28, 2016 04:21
install docker + docker compose
#! /bin/bash
# install docker & docker-compose on Ubuntu 16.04 xenial
echo "starting install"
apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
#echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" > /etc/apt/sources.list.d/docker.list