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 / 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 / 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 / .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 / 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
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 / jsmodule.sublime-snippet
Last active October 11, 2015 15:27
Sublime snippet for creating JavaScript "modules" using anonymous self-executing functions
<!--
Just simply type 'module', press Tab, then enter the name of the "module",
press Tab again and then either press Backspace to remove JQuery "support"
or press Tab once more to finish.
This creates an anonymous self-executing function which is a design pattern
that can be seen in e.g. jQuery's source code.
One of the major benefits of this pattern is that you can limit access to
variables and functions within your closure, essentially making them private
@MaciekBaron
MaciekBaron / SimpleDebug.js
Last active December 15, 2015 03:48
A very simple debug "thing" for JavaScript. You can debug messages by calling SimpleDebug.debug("My message", "some group", "log"), which will appear in the console as: [some group] My message. You can enable/disable debug, only display messages assigned to a certain group (setDebugGroup) etc.. Enjoy.
/*
* Author: Maciej Baron
*/
;(function (SimpleDebug, $, undefined) {
/*
* Simple debugging
*/
var debugEnabled = false;
@MaciekBaron
MaciekBaron / gitcommitmsg.sh
Last active December 15, 2015 04:59
Shell command to get a list of your recent commit messages from GitHub
echo Enter username; read i; echo "curl https://api.github.com/users/$i/events -s" | sh | grep message | sed -e 's/ "message": //g' -e 's/",/"/g'
@MaciekBaron
MaciekBaron / whendidifinish.sh
Last active December 15, 2015 05:09
Shows you when did you finish work (i.e. shutdown your computer) in the past
echo "last | grep shutdown | grep -v $USER" | sh | awk '{print "On "$3", "$4" "$5" finished at "$6}'
@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);