Skip to content

Instantly share code, notes, and snippets.

View zviryatko's full-sized avatar
😱
Kill beavers - save tree!

Oleksandr Davyskiba zviryatko

😱
Kill beavers - save tree!
  • Ukraine, Kiev
View GitHub Profile
@zviryatko
zviryatko / dummy.php
Created June 16, 2016 09:31
Wordpress custom fields - checkboxes
<?php
/**
* Added custom metaboxes to post types on admin init action.
*/
function dummy_add_metabox() {
add_meta_box("metabox-id", "Metabox name", "dummy_metabox_function", "page");
}
add_action("admin_init", "dummy_add_metabox");
function dummy_custom_fields() {
return array(
@zviryatko
zviryatko / dummy.php
Created June 16, 2016 09:27
Wordpress custom fields.
<?php
/**
* Added custom metaboxes to post types on admin init action.
*/
function dummy_add_metabox() {
add_meta_box("metabox-id", "Metabox name", "dummy_metabox_function", "page");
}
add_action("admin_init", "dummy_add_metabox");
@zviryatko
zviryatko / .fonts.conf
Created May 27, 2016 19:23
Fix chromium ugly fonts.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Helvetica is a non true type font, and will look bad. This
replaces it with whatever is the default sans-serif font -->
<match target="pattern">
<test name="family" qual="any">
<string>Helvetica</string>
</test>
<edit mode="assign" name="family">
@zviryatko
zviryatko / logout
Created April 7, 2016 06:48
Linux simple logout dialog based on pygtk. Wget, chmod and run.
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import os
class DoTheLogOut:
# Close window
@zviryatko
zviryatko / RouteSubscriber.php
Created March 17, 2016 08:31
Hide forgot password links in Drupal 8.
<?php
/**
* @file
* Contains \Drupal\custom_user\Routing\RouteSubscriber.
*
* Put this file in "src/Routing" module directory.
*/
namespace Drupal\custom_user\Routing;
@zviryatko
zviryatko / custom_user.module.php
Last active March 17, 2016 08:03
Disable user nick name in Drupal 8
<?php
use \Drupal\user\UserInterface;
use \Drupal\Component\Utility\Random;
/**
* Implements hook_ENTITY_TYPE_create().
*/
function custom_user_user_presave(UserInterface $entity) {
$entity->setUsername($entity->getEmail());
}
@zviryatko
zviryatko / autostart.sh
Created January 27, 2016 11:49
Openbox autostart script, put into ~/.config/openbox/autostart.sh
#!/bin/sh
# mandatory
tint2 &
pcmanfm -d &
# optional
# set desktop background
# pcmanfm --desktop &
nitrogen --restore &
@zviryatko
zviryatko / bashrc
Last active December 29, 2015 14:21
Allow drush to run above the drupal root directory
function drush {
DRUSH=$(which drush)
PWD=$(pwd)
if [ -f 'drush/drushrc.php' ];
then
$DRUSH -c ./drush/drushrc.php "$@";
elif [ -d "$PWD/web" ];
then
$DRUSH --root="$PWD/web" "$@";
else
@zviryatko
zviryatko / custom.theme.php
Created December 15, 2015 13:19
Add title to breadcrumbs in Drupal 8
<?php
/**
* Implements hook_process_HOOK().
*/
function custom_preprocess_breadcrumb(&$variables) {
/** @var \Drupal\Core\Controller\TitleResolverInterface $title_resolver */
$title_resolver = \Drupal::service('title_resolver');
/** @var \Drupal\Core\Routing\CurrentRouteMatch $current_route */
$current_route = \Drupal::service('current_route_match');
@zviryatko
zviryatko / README.md
Last active July 22, 2021 10:40
Nginx config to catch all .devel sites

This little gist help you to catch all *.devel domain and open localhost for it.

First you need to set up local DNS server and add it to resolv conf.

sudo apt-get install bind9 dnsutils resolvconf

bind9 - DNS server

resolvconf - help you to manage you /etc/resolv.conf file automatically independs on network configuration