Skip to content

Instantly share code, notes, and snippets.

View rattfieldnz's full-sized avatar

Rob Attfield rattfieldnz

View GitHub Profile
@phpdave
phpdave / cspheader.php
Last active October 25, 2023 05:23
CSP Header for PHP or Apache or .htaccess - Content Security Protocol
<?
//CSP only works in modern browsers Chrome 25+, Firefox 23+, Safari 7+
$headerCSP = "Content-Security-Policy:".
"connect-src 'self' ;". // XMLHttpRequest (AJAX request), WebSocket or EventSource.
"default-src 'self';". // Default policy for loading html elements
"frame-ancestors 'self' ;". //allow parent framing - this one blocks click jacking and ui redress
"frame-src 'none';". // vaid sources for frames
"media-src 'self' *.example.com;". // vaid sources for media (audio and video html tags src)
"object-src 'none'; ". // valid object embed and applet tags src
"report-uri https://example.com/violationReportForCSP.php;". //A URL that will get raw json data in post that lets you know what was violated and blocked
@dammyammy
dammyammy / DCMA_Notice
Last active August 29, 2015 14:15 — forked from kezadias/gist:4cca9cd424c58d515036
DCMA Notice Template
I am the copyright owner of the content, "{{ $infringing_title }}" being infringed at:
{{ $infringing_link }}
You may find the original content at:
{{ $original_link }}
{{ $original_description }}
@roNn23
roNn23 / laravel.js
Last active July 16, 2019 11:41 — forked from JeffreyWay/laravel.js
Updated delete-script of Jeffrey Way to work with Laravel 5. And optimized the implementation for the CSRF token. #laravel
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
Add this to your view:
<script>
window.csrfToken = '<?php echo csrf_token(); ?>';
@Michael-Brooks
Michael-Brooks / passwordValidation.php
Last active February 16, 2024 09:29
Laravel Password validation Regex (Contain at least one uppercase/lowercase letters and one number)
<?php
/*
* Place this with the rest of your rules.
* Doesn't need to be in an array as there are no pipes.
* Password is required with a minimum of 6 characters
* Should have at least 1 lowercase AND 1 uppercase AND 1 number
*/
$rules = [
'password' => 'required|min:6|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/'
];
@matriphe
matriphe / innodb2myisam.sh
Last active April 19, 2020 23:24
BASH script to convert InnoDB to MyISAM
#!/bin/bash
# MySQL info
DB_USER='your-db-user'
DB_PSWD='your-db-password'
DB_HOST='localhost'
# Backup path, no trailing slash!
BACKUP_PATH='/backup/sql/path'
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active June 7, 2024 01:58
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@henriquemoody
henriquemoody / http-status-codes.php
Last active January 26, 2024 10:29
List of HTTP status codes in PHP
<?php
/**
* Content from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
*
* You may also want a list of unofficial codes:
*
* 103 => 'Checkpoint',
* 218 => 'This is fine', // Apache Web Server
* 419 => 'Page Expired', // Laravel Framework
@maxmanders
maxmanders / Vagrantfile
Last active December 8, 2016 14:12
Vagrant 1.1 with host-only and bridged networking
Vagrant.configure("2") do |config|
ip_address = "192.168.56.1"
config.vm.box = "ubuntu-12.04.2-server-amd64"
config.vm.hostname = "chef-server.local"
config.ssh.timeout = 30
config.vm.provider :virtualbox do |vbox|
vbox.customize [ "modifyvm", :id, "--memory", 1024 ]