Skip to content

Instantly share code, notes, and snippets.

View pawelztef's full-sized avatar

Paweł Stefaniak pawelztef

View GitHub Profile
@pawelztef
pawelztef / masonry-jumping-bricks.js
Last active March 20, 2018 09:44
Masonry - How do I avoid showing "jumping" bricks on page load
$(window).load(function(){
var grid = $('#masonry-container').masonry({
itemSelector: '.box',
columnWidth: 300,
gutterWidth: 10,
isFitWidth: true
});
function onLayout() {
$('#masonry-container').css('visibility', 'visible');
}
@pawelztef
pawelztef / list_of_refinery_overrides.txt
Created March 27, 2018 06:15
list of possible overrides - refinery
$ rake refinery:override view=refinery/pages/*
$ rake refinery:override view=layouts/*
$ rake refinery:override view=refinery/blog/shared/*
$ rake refinery:override view=refinery/blog/posts/*
$ rake refinery:override view=refinery/*
$ rake refinery:override controller=refinery/blog/*
$ rake refinery:override controller=refinery/*
trim '.html.erb', '.rb'.
@pawelztef
pawelztef / _header.html.erb
Created April 13, 2018 04:40
Rails and refineryCMS with Bootstrap Navbar
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example_1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@pawelztef
pawelztef / init.vim
Created February 24, 2019 17:24
neovim config
call plug#begin('~/.local/share/nvim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'jeffkreeftmeijer/vim-numbertoggle'
Plug 'mattn/emmet-vim'
Plug '907th/vim-auto-save'
Plug 'vim-scripts/restore_view.vim'
Plug 'fxn/vim-monochrome'
Plug 'gosukiwi/vim-atom-dark'
@pawelztef
pawelztef / .bashrc
Created February 24, 2019 20:06
bashrc config inspiron
# set show-mode-in-prompt off
# set vi-ins-mode-string \1\2  \1\2
# set vi-cmd-mode-string \1\2  \1\2
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=1000
export HISTFILESIZE=20000
# append to the history file, don't overwrite it
shopt -s histappend
@pawelztef
pawelztef / vgaoff
Created May 24, 2019 06:44
Simple Bash script to handle connections my monitor through VGA
#!/bin/bash
xrandr --output VGA1 --off
@pawelztef
pawelztef / Slugify
Created July 21, 2019 07:04
Slugify
let slugify = function(text) {
return text.toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@pawelztef
pawelztef / rails 5 ajax
Created August 4, 2019 20:54
Rails 5 ajax
fetch("/admin/media/" + mediaId + "/update_image", {
method: 'post',
body: JSON.stringify(myData),
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': Rails.csrfToken()
},
credentials: 'same-origin'
}).then(function(response) {
return response.json();
@pawelztef
pawelztef / docReady.js
Created March 9, 2020 12:29
Pure JavaScript equivalent of jQuery's $.ready()
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete" || document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
module Croppeable
include ActiveSupport::Concern
include Rails.application.routes.url_helpers
def crop_and_save(fileName=nil, caption=nil, image_options = {})
redraw_params = create_redraw_params(image_options)
processed_attachment_path = create_variant(redraw_params)
save_new_file(fileName, caption, processed_attachment_path)
end