Skip to content

Instantly share code, notes, and snippets.

View kaisermann's full-sized avatar
🌏
travelling

Christian Kaisermann kaisermann

🌏
travelling
View GitHub Profile
function writeCSS(css) {
var head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
if(style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
add_action('init', 'custom_image_sizes');
function custom_image_sizes()
{
add_image_size('medium', get_option( 'medium_size_w' ), get_option( 'medium_size_h' ), 'center' );
add_image_size('large', get_option( 'large_size_w' ), get_option( 'large_size_h' ), 'center' );
}
add_filter('wp_update_attachment_metadata', 'filter__wp_update_attachment_metadata', 90, 2);
function filter__wp_update_attachment_metadata($data, $post_id)
{
return $data;
$time = current_time( 'mysql' );
$y = substr( $time, 0, 4 );
$m = substr( $time, 5, 2 );
$type = get_post_mime_type($post_id);
$type = explode('/', $type);
@kaisermann
kaisermann / onWindowLoad.js
Last active March 7, 2017 13:24
Collection of small javascript utility methods that I made and/or use
export default callback => {
if (document.readyState === 'complete' ||
(document.readyState !== 'loading' && !document.documentElement.doScroll)) {
callback()
} else {
document.addEventListener('DOMContentLoaded', callback, false)
}
}
@kaisermann
kaisermann / createAction.js
Last active July 6, 2017 15:15
Redux routine creator utility - async action types and action creators
/* Generates an action creator FSA compliant
* Based on 'redux-actions' createAction method
* https://github.com/acdlite/redux-actions/blob/master/src/createAction.js
*/
export default function createAction (type, payloadTransform, metaTransform) {
return (...args) => {
const action = { type }
const payload =
args[0] instanceof Error || typeof payloadTransform !== 'function'
? args[0]
@kaisermann
kaisermann / Header.blade.php
Last active February 7, 2018 16:31
hamburguer-menu.styl
<header class="header js-header" role="banner">
<a class="brand" href="{{ home_url('/') }}">{{ $site_name }}</a>
<button class="burger js-burger" aria-label="Toggle Main Menu" aria-expanded="false" aria-haspopup="true">
<span class="burger__slices"><span>Toggle Main Menu</span></span>
</button>
<div class="header__overlay js-header-overlay">
{!! $primary_menu !!}
</div>
@kaisermann
kaisermann / fluid-property.styl
Last active December 8, 2017 14:12
Stylus Mixins
fluid($prop, $fluidVal, $min, $max = false, $fallback = false)
$responsive-unit = unit($fluidVal)
$responsive-unitless = remove-unit($fluidVal)
$min-bp = $min / $responsive-unitless * 100
$max-bp = ($max != false) ? $max / $responsive-unitless * 100 : 0
$minQueries = ()
$maxQueries = ()
$dimensions = (width height)
@kaisermann
kaisermann / optimize.sh
Last active August 14, 2017 14:17
[cli] video optimization
#!/usr/bin/env bash
# Needs ffmpeg and handbrakeCLI
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
IN_DIR=${1:-"$DOTFILES_DIR/in"}
OUT_DIR=${2:-"$DOTFILES_DIR/out"}
CUR_TIMESTAMP=`date +'%d/%m/%Y %H:%M:%S'`
echo "### INIT: $CUR_TIMESTAMP" >> log.txt
find "$IN_DIR" -type f \( -iname \*.mp4 -o -iname \*.mov -o -iname \*.avi \) -print0 | while IFS= read -r -d '' ORIGIN_PATH;
@kaisermann
kaisermann / macOS.md
Last active January 1, 2024 06:09
Useful CLI

MacOS exclusive

  • Open and bring to front a specific app
osascript -e "tell application \"APP\" -e "activate" -e "end tell"
osascript -e 'tell app "Terminal" to activate'
osascript -e 'tell app "Terminal" to do script "cmatrix"'
@kaisermann
kaisermann / dependency-mess.md
Created July 3, 2020 19:34
How to check what direct dependency of your project has a specific package in its dependency tree

The modern web package ecosssystem is overloaded with packages and it's very easy to forget that each dependency of our project can have tons of other dependencies.

Sometimes you get an error in a file of a dependency that you've never heard of and it's not listed in your package.json. How can we find the direct dependency of our project that has, down its tree, this elusive dependency?