Skip to content

Instantly share code, notes, and snippets.

View zhiephie's full-sized avatar
:octocat:
Focusing

Yudi Purwanto zhiephie

:octocat:
Focusing
View GitHub Profile
@zhiephie
zhiephie / gist:adb6947841444b39f6908e9ca321b3a9
Created March 25, 2019 07:23 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@zhiephie
zhiephie / php_upgrade_to_73.md
Last active March 2, 2019 13:22 — forked from pixeline/php_upgrade_to_71.sh
Update Mac Os X's php version to php 7.3 using homebrew.

Upgrade php

  • brew unlink php71
  • brew unlink php@7.1
  • brew list | grep php | while read x; do brew uninstall --force $x; done
  • rm -rf /usr/local/Cellar/php
  • rm -rf /usr/local/Cellar/php71/
  • sudo rm -rf /usr/local/Cellar/php71/
  • sudo rm -rf /usr/local/Cellar/php71
  • sudo rm -rf ~/Library/LaunchAgents/homebrew.mxcl.php*
  • sudo rm -rf /Library/LaunchDaemons/homebrew.mxcl.php*
@zhiephie
zhiephie / workbox.md
Created November 21, 2018 02:34 — forked from addyosmani/workbox.md
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()
@zhiephie
zhiephie / php-oracle.md
Created November 8, 2018 17:03 — forked from odan/php-oracle.md
XAMPP - Oracle Driver Setup (v12)

XAMPP - Oracle Driver Setup (v12)

Requirements

This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Notice: On a x64 computer the x86 AND the x64 version must be installed.

Visual C++ Redistributable für Visual Studio 2015

Setup

@zhiephie
zhiephie / install_oci8_ubuntu_16.04_php7.1.md
Created September 7, 2018 01:57 — forked from hewerthomn/install_oci8_ubuntu_16.04_php7.1.md
How to install OCI8 on Ubuntu 16.04 and PHP 7.1
@zhiephie
zhiephie / install-go-to-with-bash-script.md
Created August 7, 2018 11:31 — forked from d2s/install-go-to-with-bash-script.md
Installing Go with command line

Install Go language with a Bash script

Another alternative to installing Go is to use a simple Bash script. It will download and install Go language under of your own user account.

Note that a system-wide installation might be better for some things (for example, better protected from accidental modifications etc.), but this was a bit simpler to setup.

For this example, we are using:

@zhiephie
zhiephie / client.go
Created August 3, 2018 02:50 — forked from kenshinx/client.go
golang socket server & client ping-pong demo
package main
import (
"log"
"net"
"strconv"
"strings"
)
const (
@zhiephie
zhiephie / free-space-on-boot-disk.md
Created April 2, 2018 15:40 — forked from jbgo/free-space-on-boot-disk.md
Free up space on /boot disk (ubuntu)

Free disk space when /boot is full (Ubuntu)

TL;DR

dpkg -l linux-image*
uname -r
sudo apt-get remove linux-image-2.6.32-{21,37,38,39,40,41,42,43,44}-server
sudo apt-get autoremove
@zhiephie
zhiephie / ActiveRepository.rb
Created March 29, 2018 10:57 — forked from bokmann/ActiveRepository.rb
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@zhiephie
zhiephie / README.md
Created March 27, 2018 09:56
HTML to PDF conversion in PHP using wkhtmltopdf (and optionally Smarty)

Recently I was asked to generate PDF invoices for an online shop. I looked at various PHP PDF generators, but wasn't particularly impressed with any of them.

Then I found (via Stack Overflow) a command-line HTML-to-PDF convertor called wkhtmltopdf, which uses WebKit (the same layout engine as Safari and Google Chrome) and therefore is very accurate.

There is a class for PHP integration on the Wiki, but I found it overly complicated and it uses temp files which aren't necessary. This is the code I wrote instead.

I used Smarty for generating the HTML for the PDF, but you can use any template engine, or pure PHP if you prefer.

Note: I originally tried to install wkhtmltopdf from source, but it's much easier to use the static binary instead.