Skip to content

Instantly share code, notes, and snippets.

View victor-shelepen's full-sized avatar

Victor Shelepen victor-shelepen

View GitHub Profile
@victor-shelepen
victor-shelepen / seed_derivatives.drush.inc
Created April 14, 2016 08:08 — forked from typhonius/seed_derivatives.drush.inc
This script can generate image derivatives for Drupal for warming up the filesystem prior to going live. Image derivative generation puts an amount of load on the servers so it images have been migrated from another server with no derivatives, it may be useful to pre-generate using this script.
<?php
/**
* Implements hook_drush_command().
*/
function seed_derivatives_drush_command() {
$items = array();
$items['seed_derivatives'] = array(
'description' => "Create image derivatives",
crontab -e
* * * * * /usr/bin/php /speroteck/WSM/ultradeluxxe_original/shell/doba.php >> /home/viktor/tmp/root_cron.log 2>&1
sudo tail -f /var/log/syslog | grep CRON
sudo tail -f /home/viktor/tmp/root_cron.log
sudo tail -f /speroteck/WSM/ultradeluxxe_original/var/log/dobalog.log
sudo htop
add filter "doba"
@victor-shelepen
victor-shelepen / install_python27_virtualenv.sh
Created October 11, 2015 20:47 — forked from ellmetha/install_python27_virtualenv.sh
Python 2.7 & virtualenv installation on Alwaysdata
#!/bin/bash
# Python 2.7 installation
mkdir -p $HOME/.python/src
cd $HOME/.python/src
wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz --no-check-certificate
tar xvfz Python-2.7.6.tgz
cd Python-2.7.6
mkdir $HOME/.python/python2.7
./configure --prefix=$HOME/.python/python2.7
@victor-shelepen
victor-shelepen / d8-snippets-1.php
Created June 24, 2015 07:02
There are D8 snippets.
// It creates an entety instance, etity_type=taxonomy_term .
$term = entity_create('taxonomy_term', array(
'name' => 'test',
'vid' => 'client',
))->save();
// urlInfo return an entity route.
$this->drupalGet($entity->urlInfo());
$this->drupalGet($entity->urlInfo('drupal:content-translation-overview'));
@victor-shelepen
victor-shelepen / LanguagePageCacheTest.php
Last active August 29, 2015 14:23
This is a test for Drupal 8. It tests page caching with language negotiation.
<?php
/**
* @file
* Contains \Drupal\language\Tests\LanguagePageCacheTest.
*/
// d8runtest --class "Drupal\language\Tests\LanguagePageCacheTest"
@victor-shelepen
victor-shelepen / 1.php
Created February 22, 2015 19:23
Developex test
$variableA = 0;
$variableB = 1;
$variableC = 2;
if ($variableB >= $variableA) {
watchdog('greater_than','B great than A');
}
if ($variableC <= $variableB) {
watchdog('greater_than','C less than B');
}
query_1 = db\
.Query(UserModel, func.count(FriendModel.friend_id).label('friends'))\
.select_from(UserModel)\
.outerjoin(FriendModel, and_(UserModel.id==FriendModel.user_id))\
.group_by(FriendModel.user_id)
s_1 = query_1.subquery('s_1')
query_2 = db\
.session.query(s_1, FriendModel.status)\
.select_from(s_1)\
class UserTable(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True)
email = db.Column(db.String(120), unique=True)
password = db.Column(db.String)
user_friend = relationship('FriendTable', backref='user', foreign_keys='FriendTable.user_id')
friend_user = relationship('FriendTable', backref='friend', foreign_keys='FriendTable.friend_id')
$language_list = array ('ru', 'uk');
foreach($article_list as $article) {
//$output .= print_r($article, 1);
$node = entity_create('node', array('type' => 'article', 'title' => $article['en']['title'], 'language' => 'en'));
$output .= $article['en']['title'] . '|<br>';
$node->get('body')->setValue($article['en']['body']);
foreach ($language_list as $language) {
$translation = $node->getTranslation('ru');
$output .= $article[$language]['title'] . '|<br>';
if (empty($article[$language]['title'])) {
services:
locale_config_subscriber:
class: Drupal\locale\LocaleConfigSubscriber
tags:
- { name: event_subscriber }
arguments: ['@language_manager', '@config.context']
locale.config.typed:
class: Drupal\locale\LocaleConfigManager
arguments: ['@config.storage', '@config.storage.schema', '@config.storage.installer']