Skip to content

Instantly share code, notes, and snippets.

View kottenator's full-sized avatar

Rostyslav Bryzgunov kottenator

  • Facebook
  • Seattle, WA
View GitHub Profile
@kottenator
kottenator / noty_flat_theme.css
Last active August 29, 2015 13:59
Noty theme in CSS (not in JS as it recommends by default)
/**
* Noty 2.2.2 Theme: Flat UI colors
* @author kottenator
*/
.flat .noty_bar {
font: 16px/1.3 Arial, Liberation Sans, sans-serif;
text-align: center;
padding: 12px 15px 13px;
position: relative;
border: 2px solid #eee;
@kottenator
kottenator / gist:960033
Created May 6, 2011 23:58 — forked from paulirish/README.md
imagesLoaded() jquery plugin
/**
* Execute a callback when all images have loaded.
* needed because .load() doesn't work on cached images
*
* Usage:
* $('img.photo').imagesLoaded(myFunction)
* -> myFunction() { this == [jQuery collection of 'img'] }
*
* $('img.photo').imagesLoaded(myFunction, myContext)
* -> myFunction() { this == myContext }
@kottenator
kottenator / compressor_filters.py
Last active July 6, 2016 20:41
django-compressor - abstract static URL
"""
Django 'base' app - compressor filters.
"""
from compressor.filters.css_default import CssAbsoluteFilter
class CssRelativeFilter(CssAbsoluteFilter):
"""
``compressor.filters.css_default.CssAbsoluteFilter`` converts relative URLs to images, fonts, etc
in CSS code to absolute URLs like '/static/base/images/logo.svg'.
@kottenator
kottenator / ajax_setup.js
Last active August 30, 2016 11:23
Setup jQuery AJAX & show errors
/**
* Setup jQuery AJAX
*
* Requires noty.js and 2 its layouts: noty/layouts/top.js, noty/layouts/topRight.js
*/
$.ajaxSetup({
error: function(xhr, status, error) {
// we ignore aborted XHR or when user press F5 while XHR is in progress
if (status == 'abort' || xhr.readyState == 0)
return;
@kottenator
kottenator / history.js
Created October 26, 2016 18:56
Document title & History API
var button = document.createElement('button');
button.textContent = 'Push';
document.body.appendChild(button);
var x, title;
if (!history.state) {
x = 0;
title = document.title;
// Without this we can loose the initial page's title on browser navigation
@kottenator
kottenator / temperature.min.py
Created November 11, 2016 04:21
Simple temperature calculator (°C / °F)
c = lambda f: (f - 32) * 5 / 9.; f = lambda c: c * 9 / 5. + 32; print('\n'.join(u'{2:>6} °C ← °F {0:>4} °C → °F {1:6}'.format(i * 10, f(i * 10), round(c(i * 10), 1)) for i in range(-10, 11)))
@kottenator
kottenator / .inputrc
Created January 15, 2017 01:58
Bash completion and navigation
set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
# Tab completion
TAB: menu-complete
# Shift + Tab - backward completion
"\e[Z": "\e-1\C-i"
@kottenator
kottenator / kott.theme.bash
Last active January 15, 2017 01:58
Custom theme for bash-it
# Custom theme for https://github.com/bash-it/bash-it
# Place it into ~/.bash_it/custom/themes/kott/kott.theme.bash
# Enable it in your ~/.bashrc: export BASH_IT_THEME='kott'
SCM_THEME_PROMPT_DIRTY="✗ "
SCM_THEME_PROMPT_CLEAN="✓ "
SCM_THEME_PROMPT_PREFIX=" ("
SCM_THEME_PROMPT_SUFFIX=")"
function scm_prompt_info {
javascript:void(function(){var el=document.getElementById('my-grid');if(el){el.style.display=el.style.display=='block'?'none':'block';}else{el=document.createElement('div');document.body.appendChild(el);el.id='my-grid';el.style.cssText='background-image:url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' width=\'1\' height=\'25.5\'><rect style=\'fill: rgb(255,0,0);\' width=\'1\' height=\'0.25px\' x=\'0\' y=\'0\'/></svg>");position:absolute;left:0;right:0;top:0;z-index:9999;pointer-events:none;background-position:0 3px;display:block;';function resize(){el.style.height=document.body.scrollHeight+'px';}resize();document.body.addEventListener('resize', resize);}}())
@kottenator
kottenator / in-order traversal no recursion.js
Created March 1, 2018 13:54
In-order traverse without recursion
/**
* Binary tree in-order traversal.
*
* How would look this simple, straightforward algorithm without recursion?
* I don't like recursion, that's one of my attempts to avoid it.
*/
function traverseInOrderNoRecursion(t) {
if (!t) {
return [];
}