Skip to content

Instantly share code, notes, and snippets.

@simtabi
simtabi / generate-wildcard-certificate.sh
Created November 18, 2021 20:07 — forked from dmadisetti/generate-wildcard-certificate.sh
Generate self-signed wildcard SSL certificate for development environment
#!/usr/bin/env bash
# print usage
DOMAIN=$1
if [ -z "$1" ]; then
echo "USAGE: $0 tld"
echo ""
echo "This will generate a non-secure self-signed wildcard certificate for "
echo "a given development tld."
echo "This should only be used in a development environment."
@simtabi
simtabi / vhost-wildcard-subdomain.conf
Created November 13, 2021 13:01 — forked from ofus/vhost-wildcard-subdomain.conf
Apache Virtual Hosts with wildcard subdomain matching
UseCanonicalName Off
<VirtualHost *:80>
ServerAdmin nobody@example.com
ServerAlias *.example.com
VirtualDocumentRoot /var/www/%1/public
DirectoryIndex index.php index.htm index.html
<Directory /var/www/*/public/>
AllowOverride All
</Directory>
@simtabi
simtabi / StartSSL.md
Created November 3, 2021 17:15 — forked from mgedmin/StartSSL.md
Free StartSSL.com SSL certificate HOWTO

How to get a free StartSSL.com SSL certificate

I'm writing this up from memory, so errors may appear.

This has been updated to use SHA256 certificates.

Start

  1. Go to http://www.startssl.com/
  2. Click on 'Control Panel'
@simtabi
simtabi / how-to-set-up-stress-free-ssl-on-os-x.md
Created November 3, 2021 16:58 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@simtabi
simtabi / UsingSSLwithMAMP.md
Created November 3, 2021 16:12 — forked from malinky/UsingSSLwithMAMP.md
Using SSL with MAMP

Overview

Having read a number of guides on using SSL with MAMP I still couldn't get things working properly. This is my guide which takes ideas from a number of resources. As with the guides I'd previously read this may or may not work for you but either way I hope it helps.

Generate SSL Certificate

  1. I imagine you can generate a wildcard certficate for all local sites but this didn't work for me so I generated a certificate for each local site individually. This method uses the subjectAltName field as this is required since Chrome 58.

  2. Create the following file in your user folder and save as server.csr.cnf. Remember to change your Country (C), State (ST), Location (L), Organisation (O), Oganisational Unit (OU), Email Address( emailAddress) and Common Name (CN). For the common name I matched with my local site name as defined in my hosts file.

@simtabi
simtabi / Laravel-Container.md
Created October 28, 2021 21:22
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

@simtabi
simtabi / AppDatabaseSessionHandler.php
Created October 28, 2021 00:00 — forked from wadtech/AppDatabaseSessionHandler.php
Laravel 5.3 Custom Database Session Handler Example
<?php
namespace App\Extensions;
// we have an Eloquent model that allows using the session table with the querybuilder methods and eloquent fluent interface- read only!
use App\Session;
// use the provided database session handler to avoid too much duplicated effort.
use Illuminate\Session\DatabaseSessionHandler;
class AppDatabaseSessionHandler extends DatabaseSessionHandler
@simtabi
simtabi / php_random_array_element.md
Created February 24, 2021 14:34 — forked from zgulde/php_random_array_element.md
how to get a random array element in php

Getting a random element from an array

tldr: the function at the end of this gist will give you a random array element

Figuring out how to get a random array element will give a better understanding of how PHP works, as well as how arrays work in general.

Lets start with this code:

$numbers = [1, 2, 3, 4, 5];
@simtabi
simtabi / meta-tags.md
Created March 4, 2018 09:16 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@simtabi
simtabi / metatags.html
Created March 4, 2018 09:14 — forked from MicBrain/metatags.html
The list of useful meta tags used in HTML5 documents.
<html>
<head>
<!--Recommended Meta Tags-->
<meta charset="utf-8">
<meta name="language" content="english">
<meta http-equiv="content-type" content="text/html">
<meta name="author" content=”Rafayel Mkrtchyan”>
<meta name="designer" content=”Rafayel Mkrtchyan”>
<meta name="publisher" content=”Rafayel Mkrtchyan”>