Skip to content

Instantly share code, notes, and snippets.

View alexmccabe's full-sized avatar

Alex McCabe alexmccabe

View GitHub Profile
export default function (element, threshold) {
threshold = threshold || 0;
var elementTop = element.offsetTop;
var elementBottom = elementTop + element.clientHeight;
var viewportTop = window.scrollY;
var viewportBottom = viewportTop + window.innerHeight;
return elementBottom > viewportTop && elementTop < viewportBottom;
},
function scrollIntoView($element) {
var scrollTop = 0;
if ($element.length) {
scrollTop = $element.offset().top -
$('#headerwrap')[0].clientHeight - 40;
window.scrollTo(0, scrollTop);
}
}
const temp = cityData.list.map(item => item.main.temp);
const humidity = cityData.list.map(item => item.main.humidity);
const pressure = cityData.list.map(item => item.main.pressure);
const { temp, pressure, humidity } = cityData.list.reduce(
(current, item) => {
current.temp.push(item.main.temp);
current.pressure.push(item.main.pressure);
current.humidity.push(item.main.humidity);
return current;
},
{ temp: [], pressure: [], humidity: [] }
);
var animate, camera, clock, composer, elapsedTime, frameCount, init, light, loadModel, maskScene, mesh1, mesh2, mesh3, onWindowResize, outScene, render, renderTarget, renderer, scene, screenHeight, screenWidth, setModel, shader, updateFps;
screenWidth = window.innerWidth;
screenHeight = window.innerHeight;
clock = new THREE.Clock();
elapsedTime = 0;
frameCount = 0;
init = function() {
/*global $*/
class ScrollClass {
constructor () {
this.$body = $('body');
this.styles = {
disabled: {
'height': '100%',
'overflow': 'hidden',
},
for file in ./*
do
filename=$(basename "$file")
ffmpeg -f gif -i "$file" "${filename%.*}".mp4
mv "${filename%.*}".mp4 ../social_vid
done
@alexmccabe
alexmccabe / SSLChainCertificate.js
Last active February 7, 2017 11:49
How to get SSL Chain Certificates in NodeJS. This took me a very long time to figure out.
// How to get SSL Chain certificate in NodeJS
/**
* You will receive multiple files from the SSL Certificate provider, one is
* the certificate, one is the bundle. Node requires this to be in a single
* .cert file.
*
* To do this from the terminal, concatonate the files together.
* cat website.com.crt bundle_name.crt > output-bundle.crt
*/
@alexmccabe
alexmccabe / textReplacement.js
Last active January 27, 2017 15:14
Converts a string containing Moustache style curly braces into a proper string.
(function () {
'use strict';
var textReplacement = {
/**
* Converts a string containing Moustache style curly-brace variables,
* into a coherent string.
* @param {string} string Input string containing
* {{ curlyBrace }} variables
* @param {object} replacements key / value pair object where the key
<?php
ini_set('max_execution_time', 600); // 10 minutes
class OptimiseImage
{
private $baseDir = '/';
private $inputDir = 'input';
private $outputDir = 'output/large';
private $tmpDir = 'tmp';