Skip to content

Instantly share code, notes, and snippets.

View ivankristianto's full-sized avatar

Ivan Kristianto ivankristianto

View GitHub Profile
@ivankristianto
ivankristianto / functions.php
Created July 14, 2018 07:56
Add Auto ADS AMP Script for WordPress
/**
* Echo AMP Auto Ads Script
*/
function ik_amp_extended_component() {
echo '<script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"></script>';
}
add_action( 'amp_post_template_head', 'ik_amp_extended_component', 25 );
@ivankristianto
ivankristianto / ga.json
Created July 14, 2018 03:45
Google Analytics JSON Template for AMP WordPress
{
"vars": {
"account": "UA-XXXXXXX-Y"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
},
"trackClick": {
@ivankristianto
ivankristianto / Running PHP cli.sh
Created May 21, 2018 12:47
Run PHP cli script with Docker
docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.0-cli php script.php
@ivankristianto
ivankristianto / Check sitespeed.io.sh
Created May 21, 2018 12:47
Check wesite sitespeed with Docker
docker run --shm-size=1g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:6.5.4 <url>
@ivankristianto
ivankristianto / letsencrypt_2017.md
Created May 19, 2018 12:03 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

#disable terminal alt shortcut
#vim tips urls:
http://vim.wikia.com/wiki/
http://bullium.com/support/vim.html
http://www.lagmonster.org/docs/vi.html
#delete lines from top to cursor
dgg
#undo
@ivankristianto
ivankristianto / command
Created January 7, 2018 16:11 — forked from pereirinha/command
Local certificate
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout ssl/domain.com.key \
-new \
-out ssl/domain.com.crt \
-subj /CN=domain.com \
-reqexts SAN \
-extensions SAN \
@ivankristianto
ivankristianto / Process_Manager.php
Created November 29, 2017 16:35 — forked from compwright/Process_Manager.php
Demo code used in my "Multitasking in PHP" presentation at the December 2012 Atlanta PHP user group meetup
<?php
class Process_Manager implements Countable
{
protected $processes = array();
protected $is_child = FALSE;
public function count()
{
return count($this->processes);
@ivankristianto
ivankristianto / spaghetti.php
Created July 22, 2017 16:06
Sample of Spaghetti Code
<?php
function get_something( $username, $password, $date_start, $date_end ) {
header("Content-Type:text/plain");
$dataOutput = array();
// truncated....
$output= trim(preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $output[0]));
$resultnewtotal = array();
if( $newresults[6] && $newresults[8] )
@ivankristianto
ivankristianto / gcloud_ip_range.txt
Created July 17, 2017 10:34
Gcloud Outbound Ip range
8.34.208.0/20
8.35.192.0/21
8.35.200.0/23
108.59.80.0/20
108.170.192.0/20
108.170.208.0/21
108.170.216.0/22
108.170.220.0/23
108.170.222.0/24
162.216.148.0/22