Skip to content

Instantly share code, notes, and snippets.

View willianbs's full-sized avatar
:shipit:
Working from home

Will Silveira willianbs

:shipit:
Working from home
View GitHub Profile
@willianbs
willianbs / nginx.default.conf
Created April 15, 2016 18:23 — forked from santoshachari/nginx.default.conf
PHP5.6 and NGINX: Install PHP56-FPM, Nginx & MySQL on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and php56-FPM
sudo yum install -y nginx php56-fpm
# Install php56 extensions
sudo yum install -y php56-devel php-mysql php56-pdo php56-pear php56-mbstring php56-cli php56-odbc php56-imap php56-gd php56-xml php56-soap
@willianbs
willianbs / replace-apache.sh
Last active August 2, 2016 16:54 — forked from nzakas/replace-apache.sh
Replace Apache with nginx on Elastic Beanstalk AMI (PHP 64bit)
#!/bin/sh
# IMPORTANT: Run this script as sudo or else it won't work
# Original script: http://my.safaribooksonline.com/book/programming/java/9781449309558/hacking-elastic-beanstalk/hackingelectric#X2ludGVybmFsX0ZsYXNoUmVhZGVyP3htbGlkPTk3ODE0NDkzMDk1NTgvSV9zZWN0MTRfZDFlMjAyNQ==
echo 'Installing nginx...sit tight'
yum -y install nginx
echo 'Fixing nginx configuration'
sed -i 's/ 1;/ 4;/g' /etc/nginx/nginx.conf
rm /etc/nginx/conf.d/default.conf
@willianbs
willianbs / docker-compose.yml
Created August 3, 2016 18:51
Docker Compose for Fast Dev: php7-fpm + nginx + mariaDB [alpine versions]
version: '2'
services :
nginx:
image: nginx:stable-alpine
container_name: nginx
# restart: always
links:
- php
volumes:
@willianbs
willianbs / install-redis.sh
Created August 9, 2016 19:25 — forked from four43/install-redis.sh
Install Redis
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.githubusercontent.com/four43/e00d01ca084c5972f229/raw/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@willianbs
willianbs / simple-docker-apache-php
Created August 26, 2019 17:18
Simple Docker Apache+PHP local dev in the current dir
docker run -d -p 8082:80 --mount type=bind,source="$(pwd)",target=/var/www/html php:apache
// That's it! If you try this, and it works for you, you're done!
// The command does the following:
// If the Docker image php:apache is not present in your machine's local Docker registry, it will be downloaded from Docker hub.
// It creates a new container based on the image php:apache.
// It maps port 80 from the container to port 8082 on your host machine.
// It mounts the current directory from your host machine to /var/www/html in the container.
@willianbs
willianbs / media-query.css
Last active September 20, 2019 14:12 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
#!/usr/bin/env bash
# Caution is a virtue.
set -o nounset
set -o errtrace
set -o errexit
set -o pipefail
# ## Global Variables
@willianbs
willianbs / match.js
Created October 27, 2019 16:41
match() function: Switch Statement alternative...
// Based in:
// https://codeburst.io/alternative-to-javascripts-switch-statement-with-a-functional-twist-3f572787ba1c
const matched = x => ({
on: () => matched(x),
otherwise: () => x,
})
const match = x => ({
on: (pred, fn) => (pred(x) ? matched(fn(x)) : match(x)),
otherwise: fn => fn(x),
@willianbs
willianbs / TraverseArrays.php
Created November 8, 2019 23:22
Some ways to traverse/iterate over a multidimensional array
// Using Foreach/Loop Recursive way
function traverseArray($array)
{
foreach($array as $key => $value)
{
if(is_array($value))
{
traverseArray($value);
}else{
echo '[' . $key . ']' . ' => ' . $value . PHP_EOL;
@willianbs
willianbs / possibleCombinations.js
Created November 14, 2019 16:52
return the number of possible ranges from 1 to N
"use strict";
//recursive
const possibleCombinations = n => {
if (n == 0) {
return 0;
} else {
return n + possibleCombinations(n - 1);
}