Skip to content

Instantly share code, notes, and snippets.

View Kiryous's full-sized avatar
🗺️
On a sabbatical

Kirill Chernakov Kiryous

🗺️
On a sabbatical
View GitHub Profile
@walkermatt
walkermatt / debounce.py
Created June 4, 2012 21:44
A debounce function decorator in Python similar to the one in underscore.js, tested with 2.7
from threading import Timer
def debounce(wait):
""" Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. """
def decorator(fn):
def debounced(*args, **kwargs):
def call_it():
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@cure53
cure53 / scriptlet.md
Last active February 1, 2024 19:33
The Scriptless Scriptlet - Or how to execute JavaScript from CSS in MSIE11 without using Scripts

The Scriptless Scriptlet

Or how to execute JavaScript from CSS in MSIE11 without using Scripts

Stop! This text is only interesting for you if you...

  • Like popping alerts in weird situations
  • Miss CSS expressions as much as we do
  • Have an unhealthy obsession for markup porn

Introduction

@pardo
pardo / debounced_celery_task.py
Last active September 8, 2023 08:04
Debounced celery task in python
def debounced_wrap(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
key = kwargs.pop("key") # it's required
call_count = kwargs.pop("call_count", 1)
count = cache.get(key, 1)
if count > call_count:
# someone called the function again before the this was executed
return None
# I'm the last call
# Put it to .github/workflows/stale.yml
name: Close stale issues and pull requests
on:
workflow_dispatch:
schedule:
- cron: '30 1 * * *'
jobs:
stale:
@wolever
wolever / task_debouncer.py
Created November 4, 2016 22:38
A task debouncer for Celery.
import time
import redis
def get_redis_connection():
return redis.connect()
class TaskDebouncer(object):
""" A simple Celery task debouncer.
@typpo
typpo / async analytics.js
Created August 5, 2017 20:05
MIT License
// Create a queue to push events and stub all methods
window.analytics || (window.analytics = {});
window.analytics_queue || (window.analytics_queue = []);
(function() {
var methods = ['identify', 'track', 'trackLink', 'trackForm', 'trackClick', 'trackSubmit', 'page', 'pageview', 'ab', 'alias', 'ready', 'group', 'on', 'once', 'off'];
var factory = function(method) {
return function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(method);
@StarpTech
StarpTech / redis-cache-service.js
Last active April 15, 2021 16:26
Simple Redis Cache Client for Node.js
'use strict';
const assert = require('assert');
/**
* The redis client is https://github.com/luin/ioredis
*/
/*
const redisClient = new Redis({