Skip to content

Instantly share code, notes, and snippets.

View iximiuz's full-sized avatar
🪲

Ivan Velichko iximiuz

🪲
View GitHub Profile
@iximiuz
iximiuz / python_parse_set_cookie_headers.py
Last active December 10, 2024 17:00
Parse Set-Cookie headers in Python
@iximiuz
iximiuz / flask_static_files_cache_invalidator.py
Last active October 28, 2019 18:56
Flask: add static file's cache invalidator param to URLs generated by url_for(). Blueprints aware.
""" Inspired by http://flask.pocoo.org/snippets/40/ """
app = Flask(__name__)
@app.url_defaults
def hashed_url_for_static_file(endpoint, values):
if 'static' == endpoint or endpoint.endswith('.static'):
filename = values.get('filename')
if filename:
if '.' in endpoint: # has higher priority
@iximiuz
iximiuz / scheme::sum_of_squares.scm
Last active August 29, 2015 14:02
Sum of squares of two biggest numbers (SICP excercise)
; pen test on functional programming
(define (min-2 a b) (if (> a b) b a))
(define (min-3 a b c) (min-2 (min-2 a b) (min-2 b c)))
(define (sq x) (* x x))
(define (foo a b c) (cond ((= a (min-3 a b c)) (+ (sq b) (sq c)))
((= b (min-3 a b c)) (+ (sq a) (sq c)))
(else (+ (sq a) (sq b)))))
@iximiuz
iximiuz / Socket.js
Last active January 19, 2017 09:55
AngularJS namespaced socket.io service concept
'use strict';
/**
* Пример использования socket.io namespaces в сервисе AngularJS.
*
* Цель: получить несколько отдельных каналов связи в рамках одного соединения.
*
* Проблема: так как сервисы в AngularJS являются синглтонами, не возможно
* получить несколько экземпляров сервиса Socket с разными значениями
* namespace. При этом хочется иметь отдельные сервисы, представляющие