Skip to content

Instantly share code, notes, and snippets.

@iBobik
iBobik / h801_flux_light.yml
Created Mar 15, 2021
H801 controller (ESP8266), esphome config
View h801_flux_light.yml
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 Oct 26, 2019
My ZSH tweeks for Docker and Drupal
View .zshrc
# 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 Jul 11, 2018
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.
View commerce-order--pdf.html.twig
{#
/**
* @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 Jun 18, 2018
Drupal 8 quick&dirty webform handler what creates Commerce 2 orders and sends user to checkout. Hard coded for event registration.
View RegistrationProcessorWebformHandler.php
<?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 Sep 15, 2017
Useful functions and aliases for Docker
View .bash_profile
# 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 Aug 29, 2016
Arduino Uno Wifi sketch for sending HTTP request based on humidity and temperature
View Vlasy.ino
#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 Oct 26, 2019
My Bash tweeks for Docker and Drupal
View .bash_profile
# 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 Mar 1, 2015 — forked from matthewspencer/install-composer.sh
How to install Composer on Webfaction (PHP 5.5)
View install-composer.sh
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 Jun 19, 2014
Batch change author on multiple Drupal contents. This is view export code. Requires views_bulk_operations module.
View batch_change_content_author
$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 Jun 4, 2019
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…
View family_names.txt
ADAMÍROVÁ
ANTONYOVÁ
BABINSKÁ
BAKOŠOVÁ
BALÁNOVÁ
BARTEL
BEKROVÁ
BIEDERMANN
BLUDSKÝ
BRABLÍKOVÁ