Skip to content

Instantly share code, notes, and snippets.

View zviryatko's full-sized avatar
😶‍🌫️
AI, AI everywhere...

Oleksandr Davyskiba zviryatko

😶‍🌫️
AI, AI everywhere...
View GitHub Profile
@zviryatko
zviryatko / random-wallpaper.sh
Last active December 19, 2016 21:26
Get random wallpaper from http://desktoppr.co/
#!/bin/bash
# Download random wallpaper from desktoppr.co
# Save this file:
# $ curl -s https://gist.githubusercontent.com/zviryatko/055f8f4850bf17323c4f127a4daeccdf/raw/random-wallpaper.sh > $HOME/.local/bin/random-wallpaper
# $ chmod a+x $HOME/.local/bin/random-wallpaper
# $ crontab -e
# and add this line to the end:
# */20 * * * * $HOME/.local/bin/random-wallpaper
IMG_PATH="$HOME/.cache/wallpaper.jpg"
curl -s `curl -s https://api.desktoppr.co/1/wallpapers/random | python -c "import json,sys; obj=json.load(sys.stdin); print obj['response']['image']['url'];"` > $IMG_PATH
@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');