Skip to content

Instantly share code, notes, and snippets.

@unti1x
unti1x / config.rb
Last active September 29, 2015 09:54
Create sprite map for each subdirectory with SASS
require 'sass'
module Sass::Script::Functions
include Sass::Script::Value::Helpers
# returns list of subdirectories to iterate
def subdirs(dir)
assert_type dir, :String
dirs = []
@unti1x
unti1x / desprite.py
Created October 8, 2015 10:58
Split sprite to separate images
#!/usr/bin/env python
import Image
import argparse
import os
def main(filename, width, height, skip_width, skip_height):
cur_x = 0
cur_y = 0
@unti1x
unti1x / icons.scss
Last active October 26, 2015 08:18
Generate sprite-map with custom class names and styles using Compass
// generate sprite from dir, using specified prefix, base class and styles
@mixin spritez($path, $prefix, $base-class) {
$sprite-map: sprite-map($path, $layout: smart);
$sprite-names: sprite-names($sprite-map);
#{$base-class} {
background-image: sprite-url($sprite-map);
background-repeat: no-repeat;
display: inline-block;
@unti1x
unti1x / defaults_recoursive.coffee
Last active May 11, 2016 08:10
Set default values recoursive
_mergeDefaults = (item, defaultValues...)->
for defaultValue in defaultValues
for key, value of defaultValue
if not item[key]
item[key] = value
else if typeof value is 'object' and typeof value.length is 'undefined'
item[key] = _mergeDefaults(item[key], value)
return item
@unti1x
unti1x / AuthFailureHandler.php
Last active May 17, 2021 16:10
Using EWZRecaptchaBundle with login form
<?php
namespace AppBundle\Form\Handler;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
class AuthFailureHandler extends DefaultAuthenticationFailureHandler
{
@unti1x
unti1x / gradient_colours.scss
Last active August 22, 2018 21:15
Get any colour from linear gradient (default red to green with nice internal steps and no dirty brownish values)
// Rate of the most right colour. 10 points for green
$max_rate: 10;
/*
Calculate colour between two values.
$rate - required position
$cmax - maximal value (0-255)
$cmin - minimal value (0-255)
*/
@function _newval($rate, $cmax, $cmin) {
@unti1x
unti1x / convert.sh
Created July 3, 2019 17:10
Burn .ass/.ssa hardsub with ffmpeg (bulk)
#!/bin/sh
shopt -s extglob
mkdir -p resized
for file in *.mkv
do
ffmpeg -i "$file" -vf "ass='${file%.*}.ass'" -c:a copy "resized/$file"
done
@unti1x
unti1x / composer-install.sh
Created August 8, 2019 11:30
Single line composer installer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
[ \
"$(wget -q -O - https://composer.github.io/installer.sig)" \
== "$(php -r "echo hash_file('sha384', 'composer-setup.php');")" \
] && php composer-setup.php --quiet && php composer.phar --version