2016 m. lapkričio 20 d., sekmadienis

google drive failu nuskaitymas su php


//reikalingas service accont iš https://console.developers.google.com
$client = new Google_Client();

$credentialsFile = __DIR__ . '/googleserviceaccount.json';

if (!file_exists($credentialsFile)) {
    throw new RuntimeException('Service account credentials Not Found!');
}

$client->setAuthConfig($credentialsFile);
$client->setApplicationName("Service Account Example");
$client->setScopes(Google_Service_Drive::DRIVE);

$service = new Google_Service_Drive($client);

//glaime rodyti tik is tam tikro folderio
$files = $service->files->listFiles(array('q' => "'0B6Gt1nOByOdfsdfdsfsdZ3BqOGc' in parents"));
//failu sarasas
var_dump($files);

//failo turinys
$content = $service->files->export('13yrUsfsdfdsfsdfsdf454u_LC1eJA1mNs', 'text/html', array(
  'alt' => 'media' ));

var_dump($content->getBody()->read(1024));

google drive failu nuskaitymas su php


//reikalingas service accont iš https://console.developers.google.com
$client = new Google_Client();

$credentialsFile = __DIR__ . '/googleserviceaccount.json';

if (!file_exists($credentialsFile)) {
    throw new RuntimeException('Service account credentials Not Found!');
}

$client->setAuthConfig($credentialsFile);
$client->setApplicationName("Service Account Example");
$client->setScopes(Google_Service_Drive::DRIVE);

$service = new Google_Service_Drive($client);

//glaime rodyti tik is tam tikro folderio
$files = $service->files->listFiles(array('q' => "'0B6Gt1nOByOdfsdfdsfsdZ3BqOGc' in parents"));
//failu sarasas
var_dump($files);

//failo turinys
$content = $service->files->export('13yrUsfsdfdsfsdfsdf454u_LC1eJA1mNs', 'text/html', array(
  'alt' => 'media' ));

var_dump($content->getBody()->read(1024));

2016 m. lapkričio 13 d., sekmadienis

Eshop

El. parduotuvės privalės skelbti specialios svetainės adresą, kurios pagalba vartotojai ginčus su pardavėjais gali išspręsti be teismo. To nepadariusios parduotuvės bus baudžiamos. https://webgate.ec.europa.eu/odr/main/index.cfm?event=main.home.show&lng=LT

2016 m. spalio 20 d., ketvirtadienis

MySQL partitioning by column

ALTER TABLE `products` DROP PRIMARY KEY , ADD PRIMARY KEY ( `id` , `category` );
ALTER TABLE `products` PARTITION BY KEY(category) PARTITIONS 6;

2016 m. rugsėjo 5 d., pirmadienis

PHP slugify url

static public function slugify($text)
{
  // replace non letter or digits by -
  $text = preg_replace('~[^\pL\d]+~u', '-', $text);

  // transliterate
  $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);

  // remove unwanted characters
  $text = preg_replace('~[^-\w]+~', '', $text);

  // trim
  $text = trim($text, '-');

  // remove duplicate -
  $text = preg_replace('~-+~', '-', $text);

  // lowercase
  $text = strtolower($text);

  if (empty($text)) {
    return 'n-a';
  }

  return $text;
}