Skip to content

Instantly share code, notes, and snippets.

View dcangulo's full-sized avatar
💻

David Angulo dcangulo

💻
View GitHub Profile
@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 / 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 .
@dcangulo
dcangulo / seo-friendly-url.php
Last active April 14, 2019 07:08
A PHP function that converts string to an SEO friendly string. Visit https://www.davidangulo.xyz/ for more information.
<?php
function seoFriendlyUrl($string) {
$string = strtolower($string);
$string = preg_replace('/[^a-z0-9_\s-]/', '', $string);
$string = preg_replace('/[\s_]/', '-', $string);
return $string;
}
//Visit the tutorial for more information
//https://www.davidangulo.xyz/how-to-create-seo-friendly-url-in-php/
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"
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 add --force .
svn commit -m "release X.X.X.X"