Skip to content

Instantly share code, notes, and snippets.

View MaciekBaron's full-sized avatar
Recruiters, please DON'T contact me

Maciek Baron MaciekBaron

Recruiters, please DON'T contact me
View GitHub Profile
@MaciekBaron
MaciekBaron / .vimrc
Last active August 29, 2015 14:07
My vim config
" Fixes some issues
set nocompatible
" Required by Vundle (init)
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'bling/vim-airline'
Plugin 'airblade/vim-gitgutter'
Plugin 'mattn/emmet-vim'
@MaciekBaron
MaciekBaron / gist:264c2435a975938c26fc
Created September 4, 2014 12:14
Delete folders older than x days
find /path/to/base/dir -type d -ctime +10 -exec rm -rf {} \;
@MaciekBaron
MaciekBaron / .vimrc
Created July 10, 2014 09:59
vim: You can type w!! in vim to write to a read-only file (will ask for your password)
cmap w!! %!sudo tee > /dev/null %
@MaciekBaron
MaciekBaron / auto_adfly.js
Created April 28, 2014 22:05
Adf.ly automated download script
// Can be used with e.g. Control Freak
if (window.location.pathname === "/ad/locked") {
var time = +$("#countdown").text() || 6;
setTimeout(function () {
window.location.href = window.location.href;
}, time * 1000);
} else {
var myfunc = function () {
if (typeof $("#skip_button").attr("href") == "undefined" || $("#skip_button").attr("href") == null || $("#skip_button").attr("href").length === 0) {
setTimeout(myfunc, 500);
@MaciekBaron
MaciekBaron / gist:9918081
Created April 1, 2014 16:48
Renaming all files in Git to lowercase
for f in *; do git mv -f "$f" "`echo $f | tr "[:upper:]" "[:lower:]"`"; done
@MaciekBaron
MaciekBaron / gist:7263887
Created November 1, 2013 10:59
Plugin for highlighting TODOs
import sublime, sublime_plugin
combinations = (('todo', '(.*)TODO:(.*)', 'variable.parameter'), ('fix','(.*)FIX:(.*)', 'invalid.depricated'), ('notabene', '(.*)NB:(.*)', 'string'))
class HighlightText(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
for combination in combinations:
view.add_regions(combination[0], view.find_all(combination[1],0), combination[2], '')
@MaciekBaron
MaciekBaron / gist:6306136
Created August 22, 2013 11:39
Bath renaming and numbering files in Unix (OSX flavour)
find . -name '*.jpg' | awk 'BEGIN{ a=0 }{ printf "mv %s tile%02d.jpg\n", $0, a++ }' | bash
@MaciekBaron
MaciekBaron / HighlightTODO.py
Last active December 19, 2015 12:59
Simple plugin for highlighting TODOs and similar things
import sublime, sublime_plugin
combinations = (('todo', '(.*)TODO:(.*)', 'string'), ('fix','(.*)FIX:(.*)', 'invalid'))
class HighlightText(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
for combination in combinations:
regions = view.find_all(combination[1],0)
view.add_regions(combination[0], regions, combination[2] , '')
@MaciekBaron
MaciekBaron / ScrollTop.js
Created April 8, 2013 11:32
A cross-browser function to retrieve the window's `scrollTop`
function getScrollTop() {
if (typeof window.pageYOffset !== 'undefined'){
return window.pageYOffset;
} else {
var iequirks = document.body;
var iedoctype = document.documentElement;
var doc = (iedoctype.clientHeight) ? iedoctype : iequirks;
return doc.scrollTop;
}
}
@MaciekBaron
MaciekBaron / PlaceholderFallback.js
Created April 8, 2013 11:24
A simple fallback for HTML5 placeholders (using jQuery)
if (!("placeholder" in document.createElement("input"))) {
$("[placeholder]").each(function () {
var placeholder = $(this).attr("placeholder");
$(this).val(placeholder).focus(function () {
if ($(this).val() === placeholder) {
$(this).val("");
}
}).blur(function () {
if ($(this).val().length === 0) {
$(this).val(placeholder);