Skip to content

Instantly share code, notes, and snippets.

View andrewscaya's full-sized avatar
🏠
Working from home

Andrew Caya andrewscaya

🏠
Working from home
View GitHub Profile
@andrewscaya
andrewscaya / Dockerfile.Laravel
Last active February 25, 2020 01:24
Build a Laravel app with Linux for PHP (https://linuxforphp.net)
FROM asclinux/linuxforphp-8.2-ultimate:7.1-nts
MAINTAINER Andrew Caya
RUN cd /srv && composer create-project laravel/laravel:~5.4 app && mv www www.OLD && ln -s app/public www
RUN chmod -R 777 /srv/app/storage
ENTRYPOINT ["/bin/lfphp"]
@andrewscaya
andrewscaya / Dockerfile-PHP8.0.0dev-Lfphp
Created February 15, 2020 22:49
Basic Dockerfile example to compile PHP 8.0.0dev on Linux for PHP (https://linuxforphp.net)
FROM asclinux/linuxforphp-8.2-ultimate:src
MAINTAINER Andrew Caya <andrewscaya@yahoo.ca>
EXPOSE 80
# Compile PHP 8.0.0dev
RUN /bin/lfphp-compile "" nts
# Change root password
@andrewscaya
andrewscaya / DateRange.php
Created November 29, 2018 13:29 — forked from sasin91/DateRange.php
Easily create a collection of dates within range of two dates.
<?php
namespace App\Support;
use ArrayIterator;
use Countable;
use DatePeriod;
use DateTime;
use DateInterval;
use IteratorAggregate;
@andrewscaya
andrewscaya / Dockerfile
Created November 2, 2018 00:36 — forked from weierophinney/Dockerfile
Getting ext-tidy to work on alpine-based PHP images
# DOCKER-VERSION 1.3.2
FROM php:7.2-cli-alpine3.8
# Compile-time dependencies
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.6/community' >> /etc/apk/repositories
RUN apk update && \
apk add --no-cache 'tidyhtml-dev==5.2.0-r1'
# Install the extension
@andrewscaya
andrewscaya / installing-openwhisk-on-ubuntu.md
Last active February 20, 2018 04:16 — forked from epiphone/installing-openwhisk-on-ubuntu.md
Installing OpenWhisk on Ubuntu Server 14.04

Installing the OpenWhisk Server

This guide contains instructions on manually setting up Openwhisk and CouchDB on a fresh Ubuntu 14.04 server.

The guide is based on the OpenWhisk Ansible README, which at the time of writing is missing some key steps and gotchas - hence this guide.

1. Installation

sudo su -
@andrewscaya
andrewscaya / latency.txt
Created November 2, 2017 17:01 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@andrewscaya
andrewscaya / iteration.php
Created October 12, 2017 16:12 — forked from mgdm/iteration.php
Mandelbrot code demonstrating Recki-CT
<?php
/**
* @param double $cReal
* @param double $cImag
* @param int $maxIterations
* @return int
*/
function mandelbrotIteration($cReal, $cImag, $maxIterations)
{
WITH RECURSIVE tree_list AS (
SELECT
id, item, parent_id, CAST(item AS varchar(1000)) AS path
FROM
tree
WHERE parent_id IS NULL
UNION ALL
SELECT
child.id, child.item, child.parent_id, CAST(parent.path || '->' || child.item As varchar(1000)) AS path
FROM
SELECT
d.id,
d.name,
e_info.avg_salary,
e_info.num_employees
FROM department d,
LATERAL (SELECT
AVG(e.salary) AS avg_salary,
COUNT(*) AS num_employees
FROM employees e
SELECT
day,
month,
year,
sum(total)
FROM
revenue
GROUP BY GROUPING SETS (
(day, month, year),
(month, year),