Skip to content

Instantly share code, notes, and snippets.

@des1roer
des1roer / gist:12f93997d73024ffae5a
Last active August 29, 2015 14:23
Создание триггера для партицирования по месяцам
CREATE OR replace FUNCTION "SC_Tag".server_partition_function ( )
RETURNS TRIGGER AS $body$ DECLARE _new_time timestamp;
_id INTEGER;
_tablename text;
_startdate text;
_month text;
_enddate text;
_result record;
BEGIN
--Takes the CURRENT inbound "time" VALUE AND determines WHEN midnight IS FOR the given date
@des1roer
des1roer / gist:637f7cea1b4b0efbf375
Created June 18, 2015 03:41
Pyhton script для дампа и удаления партиции
#!/usr/bin/python
# -*- coding: utf-8 -*-
# python 2
# https://wiki.postgresql.org/wiki/Psycopg
import os
from datetime import datetime, time, timedelta, date
import psycopg2
import sys
conn = None
#!/usr/bin/python
import os
from datetime import datetime, time, timedelta, date
import syslog
DB_HOST = 'localhost'
DB_USER = 'DB_USER'
DB_NAME = 'DB_NAME'
BACKUP_PATH = '/backups/'
F:\OpenServer\domains\localhost\composer>cd F:\OpenServer\domains\localhost\composer\advanced
F:\OpenServer\domains\localhost\composer\advanced>php init
Yii Application Initialization Tool v1.0
Which environment do you want the application to be initialized in?
[0] Development
[1] Production
Microsoft Windows [Version 6.1.7601]
(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.
f:\openserver>cd F:\OpenServer\domains\localhost\composer
F:\OpenServer\domains\localhost\composer>composer create-project laravel/laravel {directory} 4.2 --prefer-dist
Installing laravel/laravel (v4.2.0)
- Installing laravel/laravel (v4.2.0)
Downloading: 100%
@des1roer
des1roer / gist:c5ec8c7a9534b5760479
Last active August 29, 2015 14:26
D:\open\OpenServer\domains\yii2-start\frontend\modules\main\views\mytree\index.php
<?php
///D:\open\OpenServer\domains\yii2-start\frontend\modules\main\views\mytree\index.php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\modules\main\models\MytreeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
@des1roer
des1roer / ajax upd
Last active September 8, 2015 10:15
$(document).ready(function () {
//console.log(array);
var path = '<?php echo $path; ?>'; //путь к контролеру
for (var i = 0; i < array.length; i++) {
var elem = array[i];
var url = path + "ajaxAll?val=" + encodeURIComponent(elem);
//console.log(elem, url);
(function (elem) {
$.ajax({
type: "POST",
(function (elem, datename, date, j, deferreds) {
deferreds.push( $.ajax({
type: "POST",
url: url,
dataType: "json",
success: function (data) {
date[datename][j] = data;
}
}) );
public void XMLReader()
{
try
{
xml.Load("server_info.xml");
foreach (XmlNode n in xml.SelectNodes("/server_info"))
{
string Server = n.SelectSingleNode("server").InnerText;
string Port = n.SelectSingleNode("port").InnerText;
}
if ($authUser)
{
if ($this->getUser()) /*проверяем есть ли*/
/*вносите узнанного пользователя в базу*/
$connection->createCommand()->insert('user', [
'login' => $this->username,
'role' => 1,
])->execute();
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);