Skip to content

Instantly share code, notes, and snippets.

Jakub Chodorowicz chodorowicz

Block or report user

Report or block chodorowicz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chodorowicz
chodorowicz / config.js
Last active Mar 29, 2020
react-storybook samples
View config.js
/**
* dynamically loading all stories with .stories.js extension
*/
import { configure } from '@kadira/storybook';
require('es6-promise').polyfill();
import 'babel-polyfill';
const stories = require.context('../app/js/components', true, /.stories.js$/);
function loadStories() {
@chodorowicz
chodorowicz / analytics-00.js
Last active Feb 17, 2020
TypeScript + Google Analytics = ❤️
View analytics-00.js
function initAnalytics() {
(function(i,s,o,g,r,a,m) {i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function() {
(i[r].q=i[r].q ||[]).push(arguments);},i[r].l= 1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);
})(window, document, "script", "//www.google-analytics.com/analytics.js", "ga");
ga("create", "UA-XXXXXXXX-X", "auto");
ga("send", "pageview");
}
@chodorowicz
chodorowicz / get_term_level.php
Last active Nov 4, 2019
get depth level of current term on taxonomy archive page
View get_term_level.php
<?php
// http://stackoverflow.com/questions/22307013/wordpress-get-current-level-of-taxonomy-in-an-archive-page
function get_tax_level($id, $tax) {
$ancestors = get_ancestors($id, $tax);
return count($ancestors) + 1;
}
$current_term_level = get_tax_level(get_queried_object()->term_id, get_queried_object()->taxonomy);
@chodorowicz
chodorowicz / toggle.js
Last active Oct 31, 2019
lodash toggle array element
View toggle.js
/**
* descructive
* https://github.com/lodash/lodash/issues/1677
*/
function toggle(collection, item) {
var idx = _.indexOf(collection, item);
if(idx !== -1) {
collection.splice(idx, 1);
} else {
collection.push(item);
@chodorowicz
chodorowicz / walker.php
Created Feb 21, 2017
remove li from wp_nav_menu, preserve classes, custom walker
View walker.php
<?php
// based on, fixed warnings http://www.designtoday.info/removing-li-menu-from-wordpress/
class Description_Walker extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
$classes = empty($item->classes) ? array () : (array) $item->classes;
$class_names = join(' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
!empty ( $class_names ) and $class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= "";
$attributes = '';
@chodorowicz
chodorowicz / browsersync.js
Last active Sep 1, 2018
BrowserSync custom host domain + snippet options
View browsersync.js
const browserSync = require('browser-sync').create();
const port = process.env.PORT || 8080;
const customDomain = environment.DEV_DOMAIN ? `${environment.DEV_DOMAIN}` : 'localhost';
browserSync.init('**/*.css', {
logPrefix: 'Showroom:',
proxy: `localhost:${port}`,
open: false,
host: customDomain,
port: 3000,
ghostMode: false, /* don't mirror interactions in other browsers */
@chodorowicz
chodorowicz / hoc.js
Last active Jul 18, 2018
React HOC example
View hoc.js
/** base form */
import React, { Component } from 'react';
export default function(InnerComponent) {
class WrapperComponent extends Component {
render() {
return <InnerComponent {...this.props} />
}
}
}
@chodorowicz
chodorowicz / .zshrc
Last active Feb 27, 2018
zplug .zshrc
View .zshrc
source ~/.zplug/init.zsh
export HISTFILE=~/.zsh_history # Where it gets saved
export HISTSIZE=10000
export SAVEHIST=10000
setopt append_history # Don't overwrite, append!
setopt INC_APPEND_HISTORY # Write after each command
setopt hist_expire_dups_first # Expire duplicate entries first when trimming history.
setopt hist_fcntl_lock # use OS file locking
setopt hist_ignore_all_dups # Delete old recorded entry if new entry is a duplicate.
@chodorowicz
chodorowicz / main.js
Created Jul 15, 2015
photoswipe disable zoom
View main.js
{
zoomEl: false,
maxSpreadZoom: 1,
getDoubleTapZoom: function(isMouseClick, item) {
return item.initialZoomLevel;
}
pinchToClose: false
}
@chodorowicz
chodorowicz / gulpfile.js
Last active Nov 22, 2017
simple gulpfile with stylus, browser sync,
View gulpfile.js
// this method is currently broken
// better use vinyl-source-stream method
// http://fettblog.eu/gulp-browserify-multiple-bundles/
const gulp = require('gulp');
const browserify = require('browserify');
const transform = require('vinyl-transform');
const browserSync = require('browser-sync');
const reload = browserSync.reload;
const gutil = require('gulp-util');
You can’t perform that action at this time.