Skip to content

Instantly share code, notes, and snippets.

import sublime, sublime_plugin
class RemoveNonBreakingCommand(sublime_plugin.TextCommand):
def run(self, edit):
if self.view.settings().get("remove_non_breaking_space") == True:
non_breaking_space = self.view.find_all(u"\u00A0")
non_breaking_space.reverse()
for r in non_breaking_space:
self.view.replace(edit, r, " ")
@evuez
evuez / responsive_triangle_mixin.scss
Last active August 29, 2015 14:10
Responsive triangle mixin (up / down)
// Triangle
@mixin triangle($dir, $size: 50%, $color: currentcolor) {
$base: null;
@if $dir == 'up' {
$base: bottom;
}
@else if $dir == 'down' {
$base: top;
@evuez
evuez / piechart.py
Created December 17, 2014 12:18
Pie Chart Generator
from math import cos, sin, radians
def piechart(data, width=100, height=100):
center_x = width / 2
center_y = height / 2
radius = min([center_x, center_y]) - 5
paths = []
@evuez
evuez / donutchart.py
Created December 17, 2014 12:23
Donut chart generator
from math import cos, sin, radians
def piechart(data, width=100, height=100, stroke=40):
center_x = width / 2
center_y = height / 2
radius = min([center_x, center_y]) - 5
paths = []
@evuez
evuez / en.yml
Last active August 29, 2015 14:17
Mongoid errors
en:
mongoid:
errors:
messages:
blank_in_locale:
"can't be blank in %{location}"
ambiguous_relationship:
message: "Ambiguous relations %{candidates} defined on %{klass}."
summary:
"When Mongoid attempts to set an inverse document of a relation
@evuez
evuez / lighten.py
Created April 17, 2015 06:26
Lighten a color
def lighten(color, scale=1.0):
"""
Lighten a color.
- color must be a tuple (r, g, b, a)
- scale can be any number, if < 1, color will be darkened
"""
return map(
lambda x: int(min(max(x * scale, 0), 255)),
color[:3]
) + list(color[3:])
@evuez
evuez / hex_to_rgb.py
Last active August 29, 2015 14:19
Hex to RGB
# Python 2
def hex_to_rgb(hex_):
return unpack('BBBB', hex_.decode('hex'))
# Python 3
def hex_to_rgb(hex_):
import codecs
return unpack('BBBB', codecs.decode(hex_, 'hex'))
from shutil import move
from glob import glob
from os import path
from collections import Counter
HOME = '/home/evuez/'
RESERVED = ('QUEUED', 'TMP', 'DONE')
'#{:06x}'.format(random.randint(0, 0xffffff))
@evuez
evuez / Preferences.sublime-settings
Last active August 29, 2015 14:22
Sublime Text settings
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by file type specific settings.
{
// Columns in which to display vertical rulers
"rulers": [78],
// Set to true to draw a border around the visible rectangle on the minimap.
// The color of the border will be determined by the "minimapBorder" key in
// the color scheme
"draw_minimap_border": true,