Skip to content

Instantly share code, notes, and snippets.

View evenicoulddoit's full-sized avatar

Ian Clark evenicoulddoit

View GitHub Profile
@evenicoulddoit
evenicoulddoit / _bem.scss
Created November 26, 2015 13:50
BEM and Sass
/**
* BEM Helper methods. Inspired by http://bit.ly/1QqAOhR.
* Provides mixins @block, @element and @modifier.
* Requires SassyLists and SassyStrings.
*/
$bem-element-separator: '__';
$bem-modifier-separator: '--';
/**
* Return a list of all of the rules within the selector
import sublime_plugin
class ShowZeroWidthSpace(sublime_plugin.EventListener):
def on_modified_async(self, view):
spaces = []
p = 0
while True:
s = view.find('\u200b', p + 1)
if not s:
@evenicoulddoit
evenicoulddoit / luxon-date-adapter.spec.ts
Created October 8, 2018 12:05 — forked from Zyzle/luxon-date-adapter.spec.ts
Luxon date adaptor for angular material
import { LOCALE_ID } from '@angular/core';
import { async, inject, TestBed } from '@angular/core/testing';
import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS } from '@angular/material/core';
import { DateTime, Settings } from 'luxon';
import { LuxonDateAdapter, LUXON_DATE_FORMATS } from './luxon-date-adapter';
// avoid confusion when working with months
# Connect to Redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
# Rate limiter configuration
MAX_REQUESTS = 5 # Maximum number of allowed requests
TIME_WINDOW = 60 # Sliding window size in seconds (e.g., 1 minute)
def is_allowed(client_id):
current_time = int(time.time() * 1000) # Current time in milliseconds
window_start = current_time - (TIME_WINDOW * 1000) # Start of sliding window