Skip to content

Instantly share code, notes, and snippets.

View whaleinvasion's full-sized avatar
💭
I may be slow to respond.

WhaleInvasion whaleinvasion

💭
I may be slow to respond.
View GitHub Profile
<?php
/** XHProf configuration */
if ( isset( $_REQUEST['pressjitsu-profile'] ) && $_REQUEST['pressjitsu-profile'] == 'enable' ) {
xhprof_enable( XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU );
ob_start();
register_shutdown_function( function() {
ob_end_clean();
header( 'Content-type: application/octet-stream' );
header( sprintf( 'Content-Disposition: attachment; filename="%d.perf.xhprof"', time() ) );
@whaleinvasion
whaleinvasion / nginx-plus-install.sh
Created April 28, 2017 08:00 — forked from rahul286/nginx-plus-install.sh
nginx-plus installation
mkdir /etc/ssl/nginx
wget -P /etc/ssl/nginx/ https://cs.nginx.com/static/files/CA.crt
## move nginx-repo.crt to /etc/ssl/nginx/nginx-repo.crt
## move nginx-repo.key to /etc/ssl/nginx/nginx-repo.key
wget http://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
apt-get install apt-transport-https libgnutls26 libcurl3-gnutls
printf "deb https://plus-pkgs.nginx.com/ubuntu `lsb_release -cs` nginx-plus\n" >/etc/apt/sources.list.d/nginx-plus.list
@whaleinvasion
whaleinvasion / is-private-mode.js
Created May 10, 2017 11:18 — forked from jherax/is-private-mode.js
Detect if a browser is in Private Browsing mode
/**
* Detect if the browser is running in Private Browsing mode
*
* @export
* @returns {Promise}
*/
export default function isPrivateMode() {
return new Promise((resolve) => {
const on = () => resolve(true); // is in private mode
const off = () => resolve(false); // not private mode
@whaleinvasion
whaleinvasion / chat.html
Created August 3, 2017 23:31 — forked from orkaplan/chat.html
simple node.js socket.io client/server example
<html>
<head>
<title>Node.js IL Chat</title>
<script type="text/javascript" src="/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script language="javascript">
var socket;
$(document).ready(function()
{
#!/bin/bash
# variables
LOGFILE="/var/log/nginx/access.log"
LOGFILE_GZ="/var/log/nginx/access.log.*"
RESPONSE_CODE="200"
# functions
filters(){
grep $RESPONSE_CODE \
@whaleinvasion
whaleinvasion / gist:0069867a238bda21e66c988477a6eb54
Created April 12, 2018 05:40 — forked from jessedearing/gist:2351836
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@whaleinvasion
whaleinvasion / image-proxy.conf
Created June 5, 2018 14:13 — forked from tmaiaroto/image-proxy.conf
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
@whaleinvasion
whaleinvasion / install-docker.sh
Created September 14, 2018 14:17 — forked from frgomes/install-docker.sh
Debian - install docker in Debian Jessie
#!/bin/bash
# compiled from https://docs.docker.com/engine/installation/linux/debian/#/debian-jessie-80-64-bit
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get install apt-transport-https ca-certificates -y
sudo sh -c "echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list"
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
@whaleinvasion
whaleinvasion / index.html
Created September 17, 2018 10:33 — forked from fcingolani/index.html
How to render a full PDF using Mozilla's pdf.js
<html>
<body>
<!-- really dirty! this is just a test drive ;) -->
<script type="text/javascript" src="https://raw.github.com/mozilla/pdf.js/gh-pages/build/pdf.js"></script>
<script type="text/javascript">
function renderPDF(url, canvasContainer, options) {
var options = options || { scale: 1 };
@whaleinvasion
whaleinvasion / touch-detect.js
Created October 2, 2018 11:51 — forked from seafoox/touch-detect.js
Detecting the ‘Tap’ event on a Mobile touch device using javascript --- JSFiddle: http://jsfiddle.net/gianlucaguarini/56Szw/light/
var $touchArea = $('#touchArea'),
touchStarted = false, // detect if a touch event is sarted
currX = 0,
currY = 0,
cachedX = 0,
cachedY = 0;
//setting the events listeners
$touchArea.on('touchstart mousedown',function (e){
e.preventDefault();