Skip to content

Instantly share code, notes, and snippets.

@jaynzr
jaynzr / NonceCspMiddleware.php
Created May 7, 2020 03:39
Extends Cake\Http\Middleware\CspMiddleware to support nonce.
<?php
namespace App\Middleware;
use Cake\Http\Middleware\CspMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class NonceCspMiddleware extends CspMiddleware
@jaynzr
jaynzr / NonceCspMiddleware.php
Created May 7, 2020 03:39
Extends Cake\Http\Middleware\CspMiddleware to support nonce.
<?php
namespace App\Middleware;
use Cake\Http\Middleware\CspMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class NonceCspMiddleware extends CspMiddleware
@jaynzr
jaynzr / window.service.ts
Created April 14, 2017 07:49
angular service to provide window object http://stackoverflow.com/a/37176929
import { Injectable } from '@angular/core';
function getWindow (): any {
return window;
}
@Injectable()
export class WindowService {
get nativeWindow (): any {
return getWindow();
@jaynzr
jaynzr / disable_defrag.sh
Last active October 11, 2016 11:12
Fix /sys/kernel/mm/transparent_hugepage/defrag is 'always' warning For Bitnami Mongodb on debian 8
#!/bin/sh
thp_path=/sys/kernel/mm/transparent_hugepage
cat > /opt/bitnami/scripts/disable_hugepage << EOL
#!/bin/sh
if test -f ${thp_path}/enabled; then
echo never > ${thp_path}/enabled
fi
if test -f ${thp_path}/defrag; then
@jaynzr
jaynzr / gcsfuse.service
Created September 18, 2016 15:45
GCSFuse systemd service /etc/systemd/system/gcsfuse.service /etc/systemd/system/gcsfuse.service.d/settings.conf
[Unit]
Description=GCS Fuse
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/bin
Type=oneshot
RemainAfterExit=yes
@jaynzr
jaynzr / cloudsql_proxy.service
Last active February 5, 2018 08:10
CloudSQL Proxy systemd /etc/systemd/system/cloudsql_proxy.service /etc/systemd/system/cloudsql_proxy.service.d/settings.conf
[Unit]
Description=CloudSQL Proxy
After=network.target
[Service]
User=nobody
Group=nobody
WorkingDirectory=/usr/local/bin
ExecStart=/usr/local/bin/cloud_sql_proxy -dir=/cloudsql -instances=${INSTANCES}
@jaynzr
jaynzr / oldrm.sh
Created February 17, 2016 15:40
delete old files
find . -mtime +365 -exec rm {} \;
@jaynzr
jaynzr / default.conf
Created February 15, 2016 08:06
nginx case insensitive path rewrite
rewrite (?i)^/path/?$ /path/ last;
rewrite (?i)^/path/(.*)$ /path/$1 last;
@jaynzr
jaynzr / new_gist_file_0
Last active February 12, 2016 13:32
Allow httpd to connect db in CentOS. selinux
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1
chcon -t httpd_sys_rw_content_t <writable_folders> -R
chcon -t httpd_sys_content_t <webroot> -R
@jaynzr
jaynzr / app.yaml
Last active August 29, 2015 14:26 — forked from darktable/app.yaml
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest