Skip to content

Instantly share code, notes, and snippets.

@ovdojoey
ovdojoey / Passing optional argument Object to a function construtor
Created June 3, 2016 11:35
A way to pass in options to a function to override default options
function MyCoolThing(options) {
// default options
this.options = {
feature: false,
timeOut: 4000,
title: 'Feature title'
};
// override default options
@ovdojoey
ovdojoey / ThrottleClass.php
Created April 6, 2016 16:12
This class uses a memcached caching DB to find malicious users
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Cache\Repository;
class ThrottleMiddleware
{
public $cache;
<?php
class FlatDB {
public $storageFileLocation = __DIR__ . "/../storage/flatdb";
public $storageFolderLocation = __DIR__ . "/../storage";
public $errors;
public $cacheFile;
public $cacheChanged = false;
(function() {
var start = null;
var scrollPosition = window.scrollY;
var halfWindowHeight = window.innerHeight / 2;
var rAFstarted = false;
var scrollnimates = [].slice.call(document.getElementsByClassName('scrollnimate'));
// get their offset from top of screen and their scroll speed
scrollnimates.forEach( function ( sn ) {
@ovdojoey
ovdojoey / img-preloader.js
Created November 6, 2015 21:22
Image Caching / Preloading
function imgPreloader () {
this.images = new Array();
this.addImages = function(images) {
var self = this;
if(!images) return;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Flex</title>
<link rel="stylesheet" href="https://gist.githubusercontent.com/ovdojoey/08d310ee8c07ac36330a/raw/ef31781517bc73f052977de26145a52996b9f8e0/juiced_v0.1.css">
<style>
#container-test{
color: #fff;
.container,.container.dir-row{-webkit-box-direction:normal;-webkit-box-orient:horizontal}.container,.container.dir-row,.container.dir-row-reverse{-webkit-box-orient:horizontal}body,html{margin:0;padding:0}.container{width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:stretch;-webkit-align-items:stretch;-ms-flex-align:stretch;align-items:stretch;max-width:1275px;margin:auto;box-sizing:border-box}.container.inline-flex{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex}.container.dir-row{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row}.container.dir-row-reverse{-webkit-box-direction:reverse;-webkit-flex-direction:row-reverse;-ms-flex-direction:row-reverse;flex-dir
@ovdojoey
ovdojoey / index.html
Created May 22, 2015 21:54
HTML for linkjax
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LinkJax Test</title>
</head>
<body>
<a href="test.html" class="linkjax" data-target="#id">test</a>
@ovdojoey
ovdojoey / linkjax.js
Last active August 29, 2015 14:21
LinkJax - Hijacks links in browser and allows for ajax loaded content
/**
* linkjax.js v1.0.0
* http://www.joeylea.com
*
* hijack links on page and turns them into AJAX loaded content
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
*/