Skip to content

Instantly share code, notes, and snippets.

View aqlx86's full-sized avatar
🦊
Focusing

Arnel Labarda aqlx86

🦊
Focusing
View GitHub Profile
@aqlx86
aqlx86 / gist:5029165
Last active December 14, 2015 04:38
create date range
<?php
function date_range($start, $end, $format = 'Y-m-d')
{
$start = DateTime::createFromFormat($format, $start);
// add 1 day to include last date
$end = DateTime::createFromFormat($format, $end)->modify('+1 day');
$dates = new DatePeriod($start, new DateInterval("P1D"), $end);
$range = array();
@aqlx86
aqlx86 / number-to-words.php
Created March 6, 2013 09:15
convert number to words.
<?php
function convert($n)
{
$d = array(
0 =>'zero', 1 => 'one', 2 => 'two', 3=> 'three', 4=> 'four', 5 => 'five', 6=> 'six', 7=> 'seven', 8=> 'eight', 9=> 'nine', 10=> 'ten',
11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14=>'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen',
20 => 'twenty', 30 => 'thirty', 40 => 'fourty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety',
100 => 'hundred', 1000 => 'thousand', 1000000 => 'million', 1000000000 => 'billion'
);
@aqlx86
aqlx86 / convert-word-to-upper-without-function.php
Last active December 14, 2015 16:19
convert word to upper case without using built-in functions
<?php
$small = range('a', 'z');
$caps = range('A', 'Z');
$s = str_split('abcdef');
foreach($s as $o){
$c.= $caps[array_search($o, $small)];
}
@aqlx86
aqlx86 / cp
Created May 2, 2013 10:00
recursive copy all files excluding directory
find Music/ -iname '*.mp3' -exec cp {} ~/Music/
@aqlx86
aqlx86 / post-receive.sh
Created June 20, 2013 13:12
git post-receive hook
#!/bin/bash
#
livepath="/path/to/your/live"
devpath="/path/to/your/dev"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [[ "master" == "$branch" ]]; then
git --work-tree=$livepath checkout -f $branch
echo 'Changes pushed live.'
<?php
function test($string)
{
$alpha = range('A', 'Z');
$years = range(2013, 2012 + count($alpha));
$array = array_combine($years, $alpha);
@aqlx86
aqlx86 / days-option.php
Created August 29, 2013 17:50
days option
<?php
$timestamp = strtotime('next Sunday');
?>
<?php for ($i = 0; $i < 7; $i++) : ?>
<?php $timestamp = strtotime('+1 day', $timestamp); ?>
<option value="<?php echo strftime('%A', $timestamp); ?>"><?php echo strftime('%A', $timestamp); ?></option>
<?php endfor; ?>
@aqlx86
aqlx86 / add-file-rec
Created November 7, 2013 04:27
add file to all subdirectories
find -mindepth 1 -maxdepth 1 -type d -exec touch {}/file \;
@aqlx86
aqlx86 / build.xml
Created February 4, 2014 17:19 — forked from daveWid/build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="" default="setup" basedir=".">
<!-- Application setup -->
<target name="setup">
<!-- Initialize git repo -->
<exec executable="git" passthru="true" checkreturn="true" escape="false">
<arg value="init" />
</exec>
<!-- Make the needed directories for the application -->
@aqlx86
aqlx86 / uri.js
Created February 19, 2014 02:21 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"