Skip to content

Instantly share code, notes, and snippets.

@janzikmund
janzikmund / style-html-select-cross-browser.scss
Created September 12, 2018 01:49
Style HTML select element cross-browser
select {
border: 1px solid #979797;
border-radius: 3px;
width: 100%;
font-size: 13px;
color: #9B9B9B;
padding: 10px 25px 10px 15px;
appearance: none;
background: url('../images/select-dropdown-ico.svg') calc(100% - 8px) 50% no-repeat #fff;
@janzikmund
janzikmund / LHShortcodes.php
Created August 19, 2018 22:14
WordPress class for automatically registered shortcode functions
<?php
/**
* Custom shortcodes
*/
class LHShortcodes
{
/**
* Constructor
*/
@janzikmund
janzikmund / Magento2-set-proper-folder-owners-permissions.md
Last active June 27, 2018 14:41
Set proper folder permissions on Magento2 installation

Magento2 set proper folder owners and permissions

1. Set www-data as owner and group for all files

cd /var/www/
sudo chown -R www-data: html

2. Set group-id bit on system regenerated folders

@janzikmund
janzikmund / Redirect Old Indexed Website Content to new URLs.md
Last active September 21, 2022 15:07
Redirect indexed content of old website to new URLs, get list of indexed URLs

Redirect Old Indexed Website Content to new URLs

1. Grab all indexed URLs

  1. Install ginfinity chrome extension to allow infinite scrolling through Google results
  2. Search for all indexed urls using query like site:example.com
  3. Scroll through all the results (hope there is not too much :)
  4. Once all results are shown, open Dev Tools JS console and run this command (document.querySelectorAll('.g .r > a')).forEach(function(el) { console.log(el.href) });

2. Setup redirects in .htaccess

@janzikmund
janzikmund / Eloquent-model-store-create-composite-key.php
Last active June 1, 2018 03:24
Allow composite key for eloquent model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
class ContentBlock extends Model
{
// if set it doesn't allow keyBy() called on collection. And still the key is composite so we have to search by two params manually anyway
@janzikmund
janzikmund / Laravel editable slugs for resource.php
Last active April 22, 2018 00:16
Laravel editable slugs for resources
<?php
// ----------- CONTROLLER -----------
/**
* Store resource
*/
public function store(Request $request)
{
// nothing special, slug generated automatically
@janzikmund
janzikmund / Laravel helper get storage disk path.php
Created April 21, 2018 23:47
Laravel helper get storage disk path
<?php
/**
* Get path for Storage disk
*/
function disk_path($disk = 'local') {
return Storage::disk($disk)->getDriver()->getAdapter()->getPathPrefix();
}
@janzikmund
janzikmund / SCSS mixins for sass.scss
Last active May 28, 2019 07:57
SCSS mixins for sass
// antialiased text
@mixin antialiased() {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
// recount pixels to em
@function em($pixels, $context: $default-font-size) {
@return #{$pixels/$context}em;
}
@janzikmund
janzikmund / WordPress responsive images with SRCSET.php
Created April 21, 2018 14:07
WordPress responsive images with SRCSET
<?php
// from ACF
if($image = get_field('photo')): ?>
<?php ps_responsive_image($image, 'large', '(min-width: 1160px) 173px, (min-width: 1024px) calc(25vw - 117px), (min-width: 768px) calc(25vw - 72px), 150px'); ?>
<?php endif
// featured image as variable
if (has_post_thumbnail( get_the_id() ) ) {
$profile_image_html = ps_get_responsive_image(get_post_thumbnail_id( get_the_id() ), 'team-profile', '(min-width: 768px) 90px, 140px');
}
@janzikmund
janzikmund / WordPress Facebook sharer link.php
Last active April 21, 2018 14:10
WordPress Facebook sharer for current page