Skip to content

Instantly share code, notes, and snippets.

View Lewiscowles1986's full-sized avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
@Lewiscowles1986
Lewiscowles1986 / provision-hospitalrun.sh
Created November 11, 2015 22:27
HospitalRun.io vagrant test env
#!/bin/bash
# Install NodeJS via NVM
sudo apt-get install -y git-core curl
curl https://raw.githubusercontent.com/creationix/nvm/v0.3.0/install.sh | bash
echo "source /home/vagrant/.nvm/nvm.sh" >> /home/vagrant/.profile
source /home/vagrant/.profile
nvm install 0.12
nvm alias default 0.12
@Lewiscowles1986
Lewiscowles1986 / Vagrantfile
Last active July 21, 2016 19:16
Debian / Ubuntu get ruby on rails
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.31.17"
config.vm.hostname = "rails.demo"
config.vm.provider "virtualbox" do |vb|
@Lewiscowles1986
Lewiscowles1986 / Vagrantfile
Last active November 22, 2015 20:38
Drupal 8 Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "debian/jessie64"
config.vm.network "private_network", ip: "10.0.0.48"
config.vm.hostname = "drupal8.local"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
@Lewiscowles1986
Lewiscowles1986 / countries-without-postcodes.inc.php
Created December 16, 2015 08:52
Countries without postcodes (PHP) (conversion of https://gist.github.com/kennwilson/3902548 to PHP)
<?php
return [
[ "Angola", "AO" ],
[ "Antigua and Barbuda", "AG" ],
[ "Aruba", "AW" ],
[ "Bahamas", "BS" ],
[ "Belize", "BZ" ],
[ "Benin", "BJ" ],
[ "Botswana", "BW" ],
@Lewiscowles1986
Lewiscowles1986 / magic.js
Created December 17, 2015 17:44
better sorting for imgur galleries
// Drop this directly into the console
jQuery('.sortable-image img, .sortable-image').css({width:'auto',height:'auto'})
jQuery('.sortable-image img').each( function(e,elem) {
var fixedImg = jQuery(this).attr('src').replace('s.png','.png');
jQuery(this).attr( 'src', fixedImg );
});
@Lewiscowles1986
Lewiscowles1986 / weird.js
Created December 28, 2015 17:56
Weird Palindrome
/*
* so I decided to check out freecodecamp today, just to see how it was
*
* It's okay, but I have to question the value of learning to write a palindrome checker, that to my mind is not much use...
* Here was my punt at it (it passed, I just don't love the look of it)
*/
function palindrome(str) {
// Good luck!
str = str.toLowerCase().replace(/[^a-z0-9]/g, '');
@Lewiscowles1986
Lewiscowles1986 / utils.offsets.in.func.php
Created January 5, 2016 15:39
find all offsets in a string
<?php
function offsetsIn(string $haystack, string $needle, $cs=true) : array {
$offset = false;
$pos = 0;
$out = [];
$func = $cs ? '\strpos' : '\stripos';
while (strlen($haystack) > 0 && ($pos === 0 || $offset !== false)) {
if($offset !== false) {
$out[] = $offset;
@Lewiscowles1986
Lewiscowles1986 / rPi3-ap-setup.sh
Last active July 16, 2023 15:33
Raspberry Pi 3 access-point-setup
#!/bin/bash
#
# This version uses September 2017 august stretch image, please use this image
#
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
@Lewiscowles1986
Lewiscowles1986 / Dockerfile
Last active July 19, 2021 11:35
PhalconPHP 2.1 Vagrant & Docker for PHP7 build...
FROM ubuntu:16.04
RUN apt-get -y update && apt-get install -y php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-intl php7.0-zip php7.0-pgsql build-essential git gcc make re2c libpcre3-dev php7.0-dev curl
RUN curl -sS http://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN composer global require "phalcon/zephir:dev-master"
RUN mkdir -p /opt/www
@Lewiscowles1986
Lewiscowles1986 / rPi3-php7-setup.sh
Last active November 8, 2019 00:17
Raspberry Pi PHP7, Nginx 1.9 Installer
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y