Skip to content

Instantly share code, notes, and snippets.

@vancouverwill
vancouverwill / gist:5646661
Created May 24, 2013 21:32
javascript limited time interval using timeout
function setTimedOutInterval(totalTime, intervalTime, callBackFunction) {
intervalId = setInterval(function () {
console.log('check B');
if (finished === true) {
console.log('B finished = true');
clearInterval(intervalId);
callBackFunction();
}
}, intervalTime);
@vancouverwill
vancouverwill / gist:5646673
Last active December 17, 2015 17:29
javascript limited time interval using loop
function setTimedOutInterval(totalTime, intervalTime, callBackFunction) {
var noOfLoops = totalTime / intervalTime,
counter = 0;
intervalId = setInterval(function () {
console.log('check');
console.log(counter);
if (counter <= noOfLoops) {
counter++;
} else {
clearInterval(intervalId);
@vancouverwill
vancouverwill / gist:5647118
Last active December 17, 2015 17:39
multi level interval boolean check with timeout
function successFunction() {
console.log('begin nike button');
}
function failFunction() {
console.log('shit hit the fan');
}
@vancouverwill
vancouverwill / gist:6513983
Created September 10, 2013 18:58
resizable content area to fit to screen size when scrolling down page or page being resized
function setContainerHeightToPage(container, heightFromTop)
{
var gridHeight = jQuery(window).height() + jQuery(document).scrollTop() - heightFromTop;
$(container).css('height', gridHeight + 'px');
}
function intializeSetContainerHeightToPage( container, heightFromTop)
{
setContainerHeightToPage( container, heightFromTop);
@vancouverwill
vancouverwill / gist:6517187
Created September 10, 2013 23:28
blend two colours in PHP
/**
*
* $color1 - hexdecimal color 1 without the hash at the beginning e.g. ffffff
* $color2 - hexdecimal color 1 without the hash at the beginning e.g. 000000
* $ratio - ration between the two colors as a fraction of 1 e.g. for 65% use 0.65
*
**/
function mix_colors_blend($color1, $color2, $ratio = 0.5) {
$color1_red = hexdec(substr($color1, 0, 2));
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # &lt;-- wordpress owner
WP_GROUP=changeme # &lt;-- wordpress group
WP_ROOT=/home/changeme # &lt;-- wordpress root directory
@vancouverwill
vancouverwill / gist:e412b2b2bd0069c950c0
Last active August 29, 2015 14:23
determine how far from the centre an index is given that the array has been rotated an unknown amount and we know the middleIndex
displacementFromMiddle = function(index, arraySize, middleIndex) {
if (index == middleIndex) return 0;
var imagesRadius = Math.floor(arraySize / 2)
var x = index - middleIndex;
var y;
if (x > imagesRadius) {
y = x - arraySize;
@vancouverwill
vancouverwill / nginx.conf
Last active July 11, 2016 14:52
Sample NGINX configuration for redirect proxy server
user nginx;
worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
@vancouverwill
vancouverwill / nginx.conf
Created July 11, 2016 15:18
Sample SSL only NGINX config file
user nginx;
worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
@vancouverwill
vancouverwill / tmux-cheatsheet.markdown
Created March 27, 2017 12:35 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname