Skip to content

Instantly share code, notes, and snippets.

View vitaLee's full-sized avatar

Vitaliy Berov vitaLee

View GitHub Profile
@vitaLee
vitaLee / compact_expand_css_command.py
Created June 3, 2012 13:26
SublimeText command for compacting/expanding CSS rules
import sublime
import sublime_plugin
import re
class CompactExpandCssCommand(sublime_plugin.TextCommand):
def run(self, edit, action='compact'):
rule_starts = self.view.find_all('\{')
rule_ends = self.view.find_all('\}')
@vitaLee
vitaLee / snap_lines_to_indent_level_command.py
Created June 5, 2012 17:02
SublimeText command for snapping displaced text to indentation
# sample shortcuts
{ "keys": ["ctrl+super+]"], "command": "snap_lines_to_indent_level", "args": { "snap_direction": 1 } },
{ "keys": ["ctrl+super+["], "command": "snap_lines_to_indent_level", "args": { "snap_direction": -1 } }
@vitaLee
vitaLee / key bindings
Created June 28, 2012 08:22
Cycle group tabs
{ "keys": ["super+alt+right"], "command": "prev_next_view_in_group", "args":{"dir": 1} },
{ "keys": ["super+alt+left"], "command": "prev_next_view_in_group", "args":{"dir": -1} }
@vitaLee
vitaLee / Default (OSX).sublime-keymap
Created August 26, 2012 12:13
Sublime Text - Extended Add Line command, allowing column selection even on shorter lines.
[
{ "keys": ["ctrl+alt+up"], "command": "smart_select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+alt+down"], "command": "smart_select_lines", "args": {"forward": true} }
]
@vitaLee
vitaLee / Default (OSX).sublime-keymap
Created December 19, 2012 18:14
Reworked version of Sublime Text 2 default Add Line command. Allows expanding selection at the same column even on shorter lines (as if there is virtual space). Works with multi selections and solves problem Sublime has with expanding non-empty selection regions.
[
{"keys":["ctrl+shift+up"], "command":"super_add_line", "args":{ "forward": false } },
{"keys":["ctrl+shift+down"], "command":"super_add_line", "args":{ "forward": true } }
]
@vitaLee
vitaLee / Default (OSX).sublime-keymap
Last active February 4, 2022 05:22
[Sublime Text] Enable resetting font size to a predefined default value.
[
{ "keys": ["super+0"], "command": "reset_font_size_to_user_defaults" }
]
#!/usr/bin/env ruby
def video_rotation(video_path)
`mediainfo #{video_path} | grep -i rotation`.match(/(\d+)/)
$1.to_i
end
def video_dimensions(video_path)
dimensions = `mediainfo #{video_path} | egrep -i 'width|height'`.scan(/([\d\s]+)pixels/)
portrait_video?(video_path) && dimensions.reverse!
@vitaLee
vitaLee / ffmpeg_progress.php
Created February 28, 2013 10:55
FFMPEG encoding progress
<?php
$logFile = 'progress_logs/%s.log';
$cmd = "/usr/local/bin/ffmpeg -i %s -y progress_test.m4v 2> %s";
for ($i=1; $i < count($argv); $i++) {
$video = $argv[$i];
$log = sprintf($logFile, $video);
exec(sprintf($cmd, $video, $log), $processOutput, $processStatus);
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@vitaLee
vitaLee / config.yml
Created December 5, 2013 10:48
Reusing common config blocks in YAML
defaults: &defaults
foo: 1
bar: 2
baz: 3
production:
<<: *defaults
bar: overriden
quz: 4