Skip to content

Instantly share code, notes, and snippets.

# i3 config file (v4)
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
# Set mod key (Mod1=<Alt>, Mod4=<Super>)
set $mod Mod1
# set default desktop layout (default is tiling)
# workspace_layout tabbed <stacking|tabbed>
# Configure border style <normal|1pixel|pixel xx|none|pixel>
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@pirey
pirey / notEmpty.js
Last active January 9, 2018 13:29
is this thing not empty?
const is = require('is_js') // require this awesome library
const notEmpty = o =>
is.not.empty(o) && Object.keys(o).map(key => {
return is.array(o[key])
? !is.all.empty(o[key])
: is.not.empty(o[key])
}).reduce((a, b) => a && b, true)
// empty examples
@pirey
pirey / knex-pagination.js
Last active April 6, 2024 14:40 — forked from andremsantos/knex-pagination.js
Adding pagination to knex.js
const config = require('./config')
const knex = require('knex')(config.db)
const QueryBuilder = require('knex/lib/query/builder')
QueryBuilder.prototype.paginate = function ({ limit = 10, page = 1 }) {
const offset = (page - 1) * limit
return Promise.all([
this.clone().count('* as count').first(),
this.offset(offset).limit(limit)
@pirey
pirey / dst-lambda.zsh-theme
Last active January 23, 2018 06:31
simple zsh theme
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!"
ZSH_THEME_GIT_PROMPT_CLEAN=""
function prompt_char {
if [ $UID -eq 0 ]; then echo "%{$fg[red]%}#%{$reset_color%}"; else echo λ; fi
}
#PROMPT='%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info)
@pirey
pirey / alacritty-colors.yaml
Created December 5, 2017 03:09
alacritty theme collection
# Colors (Nord)
# colors:
# # Default colors
# primary:
# background: '0x2E3440'
# foreground: '0xD8DEE9'
#
# # Normal colors
# normal:
# black: '0x3B4252'
const filterWhitelist = ar => key => ar.includes(key)
const sliceState = (state, whitelist) => Object.keys(state)
.filter(filterWhitelist(whitelist))
.reduce((sliced, key) => ({ ...sliced, [key]: state[key] }), {})
// usage
const slicer = paths => state => {
const { ui, auth } = state
@pirey
pirey / mejiku.css
Last active June 9, 2017 04:59
basic color names for quick fiddling
.background {
background-color: #efefef;
}
.me {
background-color: tomato;
}
.ji {
background-color: orange;
@pirey
pirey / closehtmltag.vim
Last active April 18, 2017 12:12
close html tag properly
" NOTE: change 'input' with tag name
" this will insert '/' before closing the tag
" e.g <input type="text">
" will become <input type="text"/>
%s/\(input.*\)\ze>/\1\/
@pirey
pirey / functions.php
Last active January 17, 2017 09:50
Get all categories with additional fields in woocommerce
<?php
function wc_get_categories() {
$all_categories = get_categories(array(
'taxonomy' => 'product_cat'
));
foreach ($all_categories as &$cat) {
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$cat->thumbnail_image = wp_get_attachment_url( $thumbnail_id );
$cat->link = get_term_link( $cat->slug, 'product_cat' );