Skip to content

Instantly share code, notes, and snippets.

View Tomoli75's full-sized avatar

Thomas Tomoli75

View GitHub Profile
@Tomoli75
Tomoli75 / app.js
Created October 11, 2019 15:59 — forked from hugosp/app.js
Minimal express-ws broadcast to all clients
var express = require('express');
var expressWs = require('express-ws');
var expressWs = expressWs(express());
var app = expressWs.app;
app.use(express.static('public'));
var aWss = expressWs.getWss('/');
app.ws('/', function(ws, req) {
@Tomoli75
Tomoli75 / autoscroll-plugin-and-implementation.markdown
Created September 25, 2019 19:57
AutoScroll Plugin and Implementation

AutoScroll Plugin and Implementation

In the ad tech scene, it's common that certain types of companies include legal text in their creative. I got tired of hand-coding it so I made my own plugin for it. It takes in the element as the first parameter and the options in the second parameter. You can see the options in the constructor.

A Pen by Phil Flanagan on CodePen.

License.

@Tomoli75
Tomoli75 / demo.php
Created August 15, 2018 13:55 — forked from freekrai/demo.php
PHP session-based rate limiter for APIs
<?php
date_default_timezone_set('America/Los_Angeles');
session_start();
include("ratelimiter.php");
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you.
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]);
$limit = 100; // number of connections to limit user to per $minutes
$minutes = 1; // number of $minutes to check for.