Skip to content

Instantly share code, notes, and snippets.

@victor-shelepen
victor-shelepen / eBay Wish List Parser
Created April 28, 2013 12:34
This script scrap pages and returns product info from an user wish list. I know that eBay has got own communication REST API. I've some problems during the registration. eBay REST API will the next step. I share this code to get advise from another programmers how I should write the code right. Thank you.
#!/usr/bin/env python
import logging
import urllib2
from lxml.html import etree
from lxml.html.clean import Cleaner
class EbayParser:
def __init__(self, logger_name='ebay_parser', logger_level=logging.DEBUG):
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']
$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'])) {
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')
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)\
@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');
}
@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 / 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 / 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
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"