Skip to content

Instantly share code, notes, and snippets.

View evenicoulddoit's full-sized avatar

Ian Clark evenicoulddoit

View GitHub Profile
# 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
@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
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 / _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
@evenicoulddoit
evenicoulddoit / SassMeister-input.scss
Created November 16, 2015 14:47
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
$bem-element-separator: '__';
$bem-modifier-separator: '--';
@function selectorToString($selector) {
$selector: inspect($selector); //cast to string
@evenicoulddoit
evenicoulddoit / SassMeister-input.scss
Created November 16, 2015 14:46
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$bem-element-separator: '__';
$bem-modifier-separator: '--';
@function selectorToString($selector) {
$selector: inspect($selector); //cast to string
$selector: str-slice($selector, 2, -2); //remove brackets
@evenicoulddoit
evenicoulddoit / SassMeister-input.scss
Created November 16, 2015 14:46
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$bem-element-separator: '__';
$bem-modifier-separator: '--';
@function selectorToString($selector) {
$selector: inspect($selector); //cast to string
$selector: str-slice($selector, 2, -2); //remove brackets
@evenicoulddoit
evenicoulddoit / SassMeister-input-HTML.html
Created November 16, 2015 14:21
Generated by SassMeister.com.
<div class="class">asd</div>
@evenicoulddoit
evenicoulddoit / SassMeister-input.scss
Last active November 16, 2015 14:45
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$bem-element-separator: '__';
$bem-modifier-separator: '--';
@function selectorToString($selector) {
$selector: inspect($selector); //cast to string
$selector: str-slice($selector, 2, -2); //remove brackets
@evenicoulddoit
evenicoulddoit / widgets.py
Last active August 29, 2015 14:19
IterableSelectDateWidget
import datetime
import re
from django.conf import settings
from django.forms.extras import SelectDateWidget
from django.forms.widgets import Widget, Select
from django.utils import datetime_safe, six
from django.utils.dates import MONTHS
from django.utils.formats import get_format
from django.utils.safestring import mark_safe