Skip to content

Instantly share code, notes, and snippets.

View dcangulo's full-sized avatar
💻

David Angulo dcangulo

💻
View GitHub Profile
@dcangulo
dcangulo / column.php
Created April 4, 2018 13:22
A simple WordPress plugin that shows the last modified date of a post. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Custom Column Plugin Example
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: Add a custom column on WordPress posts.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / databasetable.php
Created April 5, 2018 07:02
A simple WordPress plugin the creates custom table on plugin activation. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Create database table
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: A simple WordPress plugin that creates a database table on activation.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / contact.php
Created April 5, 2018 13:45
A simple contact form WordPress plugin. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: Simple Contact Form
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: A very simple contact form.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / crud.php
Created April 8, 2018 11:58
A CRUD Operations WordPress plugin. Visit https://www.davidangulo.xyz/ for more information.
<?php
/*
Plugin Name: CRUD Operations
Plugin URI: https://www.davidangulo.xyz/portfolio/
Description: A simple plugin that allows you to perform Create (INSERT), Read (SELECT), Update and Delete operations.
Version: 1.0.0
Author: David Angulo
Author URI: https://www.davidangulo.xyz/
License: GPL2
*/
@dcangulo
dcangulo / timeago.php
Created April 13, 2018 11:51
A PHP function that converts timestamp/datetime to time ago format. Visit https://www.davidangulo.xyz/ for more information.
<?php
function timeago($datetime, $full = false) {
date_default_timezone_set("Asia/Manila");
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
@dcangulo
dcangulo / resizeimage.php
Created April 14, 2018 06:20
A PHP function that can resize an image. Visit https://www.davidangulo.xyz/ for more information.
<?php
function resize_image($filename,$newwidth,$newheight) {
list($width, $height) = getimagesize($filename);
if(pathinfo($filename,PATHINFO_EXTENSION) == "jpg" || pathinfo($filename,PATHINFO_EXTENSION) == "jpeg") {
$src = imagecreatefromjpeg($filename);
$dst = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($dst, $filename, 100);
}
if(pathinfo($filename,PATHINFO_EXTENSION) == "png") {
@dcangulo
dcangulo / svn-git-cheatsheet.md
Last active August 17, 2018 08:18
Subversion (SVN) and git commands equivalents cheatsheet

Creating a new repository

SVN

$ svnadmin create /path/to/repo
$ svn import /path/to/local/project http://example.com/svn/truck -m "Initial import"

GIT

$ git init
$ git add .
git clone repo
Make changes in git repo
svn copy http://plugins.svn.wordpress.org/repo/trunk/ http://plugins.svn.wordpress.org/repo/tags/X.X.X.X -m "Create X.X.X.X tag"
svn checkout http://plugins.svn.wordpress.org/repo/trunk/
delete content on trunk
copy from git repo to trunk
svn add *
svn commit -m "release X.X.X.X"
git clone repo
Make changes in git repo
svn copy http://plugins.svn.wordpress.org/repo/trunk/ http://plugins.svn.wordpress.org/repo/tags/X.X.X.X -m "Create X.X.X.X tag"
svn checkout http://plugins.svn.wordpress.org/repo/trunk/
delete content on trunk
copy from git repo to trunk
svn add *
svn commit -m "release X.X.X.X"
git clone repo
Make changes in git repo
svn copy http://plugins.svn.wordpress.org/repo/trunk/ http://plugins.svn.wordpress.org/repo/tags/X.X.X.X -m "Create X.X.X.X tag"
svn checkout http://plugins.svn.wordpress.org/repo/trunk/
delete content on trunk
copy from git repo to trunk
svn add *
svn commit -m "release X.X.X.X"