Skip to content

Instantly share code, notes, and snippets.

@iBobik
iBobik / h801_flux_light.yml
Created March 15, 2021 21:51
H801 controller (ESP8266), esphome config
esphome:
name: $device_name
platform: ESP8266
board: esp01_1m
light:
- platform: cwww
id: light_1
name: $human_name
cold_white: output_w1
@iBobik
iBobik / .zshrc
Created October 26, 2019 12:09
My ZSH tweeks for Docker and Drupal
# Set env variables for Docker Machine
function dmenv() {
VM=${1}
# docker-machine start $VM
eval $(docker-machine env $VM)
}
# Dockers stats with container names
function dstats() {
docker stats $(docker ps --format '{{.Names}}')
@iBobik
iBobik / commerce-order--pdf.html.twig
Created July 11, 2018 22:39
Drupal 8 Commerce 2 Twig template for rendering order as an CZ/EU invoice. This is rendered to PDF by entity_print then. Also includes "QR Faktura" - Czech standardized QR code format for invoices and bank transfers.
{#
/**
* @file
* Template for orders in the 'user' view mode.
*
* Available variables:
* - attributes: HTML attributes for the wrapper.
* - order: The rendered order fields.
* Use 'order' to print them all, or print a subset such as
* 'order.order_number'. Use the following code to exclude the
@iBobik
iBobik / RegistrationProcessorWebformHandler.php
Created June 18, 2018 12:50
Drupal 8 quick&dirty webform handler what creates Commerce 2 orders and sends user to checkout. Hard coded for event registration.
<?php
namespace Drupal\registrations_processor\Plugin\WebformHandler;
use Drupal;
use Drupal\commerce\PurchasableEntityInterface;
use Drupal\commerce_order\Adjustment;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_price\Price;
use Drupal\Core\Form\FormStateInterface;
@iBobik
iBobik / .bash_profile
Created September 15, 2017 16:01
Useful functions and aliases for Docker
# Open shell to a Docker Compose service container:
# use like: dsh # open shell to 'app' service (container name like project_app_1)
# dsh db # open shell to 'db' service
function dsh() {
DEFAULT_SERVICE=app
docker exec -it $(docker-compose ps -q ${1:-$DEFAULT_SERVICE}) sh
}
@iBobik
iBobik / Vlasy.ino
Created August 29, 2016 22:10
Arduino Uno Wifi sketch for sending HTTP request based on humidity and temperature
#include <Wire.h>
#include <Ciao.h>
#define CONNECTOR "rest"
#define SERVER_ADDR "" // gateway from https://gist.github.com/jnv/27666983e88fb271e1528b5e538b2f2a
#define SMS_LOGIN ""
#define SMS_PASSWORD ""
#define TEL_NUM ""
@iBobik
iBobik / .bash_profile
Last active October 26, 2019 12:10
My Bash tweeks for Docker and Drupal
# Customize bash prompt to print current GIT branch and Docker Machine name.
export PSORIG="\u \W \$ "
function CUSTOMPROMPT() {
BRANCH="$(git branch 2>/dev/null | grep '*' | cut -d" " -f2-)"
if [ -n "$BRANCH" ] ; then
export PS1=$PSORIG$(echo -en "\[\033[01;33m\]$BRANCH > \[\033[00m\]")
else
export PS1="$PSORIG"
fi
@iBobik
iBobik / install-composer.sh
Created March 1, 2015 14:47 — forked from matthewpizza/install-composer.sh
How to install Composer on Webfaction (PHP 5.5)
cd $HOME
ln -s `which php55` ~/bin/php
export PATH=$HOME/bin:$PATH
curl -sS https://getcomposer.org/installer | php55
echo -e "\n# Composer\nalias composer=\"php55 \$HOME/composer.phar\"" >> $HOME/.bash_profile
source $HOME/.bash_profile
@iBobik
iBobik / batch_change_content_author
Created June 19, 2014 14:04
Batch change author on multiple Drupal contents. This is view export code. Requires views_bulk_operations module.
$view = new view();
$view->name = 'batch_change_content_author';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Batch change content author';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@iBobik
iBobik / family_names.txt
Last active June 4, 2019 21:59
Sample of most used Czech first and family names in the UTF-8 encoded TXT file, as form 1 name - 1 line, sorted from least used to most used. Useful for example for random data generators. Source: ČSÚ Vzorek nejpoužívanějších českých jmen a příjmení v TXT souboru kodovaném UTF-8 ve formě 1 jméno - 1 řádek, seřazených od nejméně používaných k nej…
ADAMÍROVÁ
ANTONYOVÁ
BABINSKÁ
BAKOŠOVÁ
BALÁNOVÁ
BARTEL
BEKROVÁ
BIEDERMANN
BLUDSKÝ
BRABLÍKOVÁ