Skip to content

Instantly share code, notes, and snippets.

View draganHR's full-sized avatar

Dragan Bošnjak draganHR

View GitHub Profile
from __future__ import unicode_literals
def vigenere_encode(m, k):
"""
>>> vigenere_encode('A', 'A')
'A'
>>> vigenere_encode('SUPER SECRET', 'KEY')
'CYNOV QOGPOX'
>>> vigenere_encode('LOREM IPSUM DOLOR SIT AMET CONSECTETUR ADIPISCING ELIT', 'SECRET')
import fcntl
LOCK_SH = fcntl.LOCK_SH # shared lock
LOCK_NB = fcntl.LOCK_NB # non-blocking
LOCK_EX = fcntl.LOCK_EX
# django helpers
def _fd(f):
%{TIMESTAMP_ISO8601:timestamp;date;yyyy-MM-dd HH:mm:ss,SSS}
/**
* Redux async actions factory
*
* License: MIT
*/
export const asyncActionTypes = (type) => ({
'BASE': `${type}`,
'PENDING': `${type}_PENDING`,
'SUCCESS': `${type}_SUCCESS`,
/**
* axios adapter based on apisauce
*
* License: MIT
*
* https://github.com/axios/axios
* https://github.com/infinitered/apisauce
*
*/
/* eslint-disable no-shadow */
@draganHR
draganHR / Closure_inClass.groovy
Last active May 25, 2017 07:21
Groovy examples
class A {
def call (c) {
c.call()
}
def foobar (c) {
call(c)
}
}
def a = new A()
@draganHR
draganHR / loading_animation.css
Last active January 20, 2017 10:57
Slim loading indicator CSS
@keyframes loading_animation {
0% {
width: 0;
}
20% {
width: 80%;
}
100% {
width: 90%;
}
from __future__ import absolute_import, unicode_literals
import logging
from itertools import count
from time import sleep
from tornado.ioloop import IOLoop
from tornado.web import asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
  • Name: ESLint
  • Link name: ESLint Warnings
  • Trend report name: Trend report name

Regular expression

([^:]+):(\d+):(\d+): ([^\[\]]+)\[([\w-]+)\/([\w-]+)]

Mapping Script

import gc
import sys
import operator
def total_size():
return sum(sys.getsizeof(i) for i in gc.get_objects())
def total_count():