Skip to content

Instantly share code, notes, and snippets.

@jpswade
jpswade / json2csv.php
Created March 11, 2020 14:43
convert from a multi-dimensional json object to a flat csv table
<?php
/**
* @param string $jsonFilename
* @param string $csvFilename
* @return bool|int
*/
function json2csv($jsonFilename, $csvFilename)
{
$json = file_get_contents($jsonFilename);
@jpswade
jpswade / sample.py
Created January 29, 2020 10:44
Parse the json
import json
import re
filepath = 'sample.html'
file = open(filepath, 'r')
body = file.read()
matches = re.findall(r'<script>window.jsonModel = (.+?)</script>', body)
blob = json.loads(matches[0])
print(json.dumps(blob, indent=4, sort_keys=True))
@jpswade
jpswade / WorkingDays.php
Last active January 25, 2020 12:43
A class to get working days between two dates...
<?php
namespace App\Services;
use DateInterval;
use DatePeriod;
use DateTime;
use Exception;
use Illuminate\Support\Facades\Cache;
@jpswade
jpswade / php.config.yaml
Last active December 21, 2021 10:18
Elastic Beanstalk Laravel ebextensions PHP YAML
# Set composer folder for this command and update
commands:
01-updateComposer:
command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update
option_settings:
"aws:elasticbeanstalk:container:php:phpini":
document_root: /public
composer_options: --no-dev --no-interaction --prefer-dist --optimize-autoloader
"aws:elasticbeanstalk:sqsd":
@jpswade
jpswade / point-in-polygon.php
Created November 5, 2019 10:01 — forked from vzool/point-in-polygon.php
The point-in-polygon algorithm allows you to check if a point is inside a polygon or outside of it.
<?php
/*
Description: The point-in-polygon algorithm allows you to check if a point is
inside a polygon or outside of it.
Author: Michaël Niessen (2009)
Website: http://AssemblySys.com
If you find this script useful, you can show your
appreciation by getting Michaël a cup of coffee ;)
PayPal: michael.niessen@assemblysys.com
FROM php:7.3-apache
MAINTAINER James Wade <jpswade@gmail.com>
# Install gd, iconv, mbstring, mcrypt, mysql, soap, sockets, zip, and zlib extensions
# see example at https://hub.docker.com/_/php/
RUN apt-get update && apt-get install -y \
libbz2-dev \
libfreetype6-dev \
libgd-dev \
libjpeg62-turbo-dev \
@jpswade
jpswade / ie11-ie8.sh
Created April 9, 2019 09:01
Windows 8.1 with IE11
#!/usr/bin/env bash
vagrant box add ie11-win81 http://aka.ms/ie11.win81.vagrant
vagrant init ie11-win81
vagrant up
@jpswade
jpswade / setup_selenium.sh
Last active November 1, 2020 10:08
Setup Selenium
brew install selenium-server-standalone
brew cask install chromedriver
selenium-server -p 4444
@jpswade
jpswade / Dockerfile-php56
Created July 31, 2018 20:28
PHP56 Build Dockerfile
FROM php:5.6-apache
MAINTAINER James Wade <jpswade@gmail.com>
# Install gd, iconv, mbstring, mcrypt, mysql, soap, sockets, zip, and zlib extensions
# see example at https://hub.docker.com/_/php/
RUN apt-get update && apt-get install -y \
libbz2-dev \
libfreetype6-dev \
libgd-dev \
libjpeg62-turbo-dev \
@jpswade
jpswade / setup_zalenium.sh
Created April 24, 2018 14:53
Setup Zalenium
#!/usr/bin/env bash
# @see https://github.com/zalando/zalenium/tree/master/docs/k8s/helm
# @todo helm install local/zalenium - @see https://github.com/kubernetes/helm/issues/3873
# @see https://zalando.github.io/zalenium/#kubernetes
set -e
docker pull elgalu/selenium
docker pull dosel/zalenium
[[ -d zalenium ]] || git clone git@github.com:zalando/zalenium.git
cd zalenium
kubectl create -f kubernetes/ || kubectl apply -f kubernetes/