Skip to content

Instantly share code, notes, and snippets.

@csarcom
csarcom / gist:20ded1d158b7dcb4f2cb
Last active August 29, 2015 14:08
Presto empty rows
select from_unixtime(86400 + floor(to_unixtime(time) / 86400) * 86400), sum(sum) from metrics_rollup60 where name= 'bytes_sent.0044b.ha' and to_unixtime(time) > to_unixtime(TIMESTAMP '2014-09-29 00:00:00.000') and to_unixtime(time) < to_unixtime(TIMESTAMP '2014-11-30 00:00:00.000') GROUP BY floor(to_unixtime(time) / 86400);
Result:
_col0 | _col1
-------------------------+---------
2014-10-02 00:00:00.000 | 1083855
2014-10-03 00:00:00.000 | 1080823
2014-10-04 00:00:00.000 | 1076970
2014-10-05 00:00:00.000 | 1080710
select time, sum(sum) from metrics_rollup60
where name = 'bytes_sent.tcp_miss1.0044b.ha.300' and
to_unixtime(time) > to_unixtime(TIMESTAMP '2013-01-01 00:00:00.000') and
to_unixtime(time) < to_unixtime(TIMESTAMP '2013-01-31 00:00:00.000')
GROUP BY time;
time | _col1
-------------------------+------------
2013-01-01 00:01:00.000 | 432498985
2013-01-01 00:02:00.000 | 155681891
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
echo I am provisioning...
echo Installing EPEL packages...
su -c 'rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'
class Account(models.Model):
pass
class CustomUser(AbstractBaseUser, PermissionsMixin):
accounts = models.ManyToManyField(Account,
through='CustomUserAccount')
changed_by = models.ForeignKey(CustomUser, null=True, blank=True)
@property
class History(models.Model):
changed_by = models.ForeignKey('user.CustomUser', null=True, blank=True)
history = HistoricalRecords()
@property
def _history_user(self):
return self.changed_by
@_history_user.setter
class Account(PolymorphicMPTTModel):
parent = PolymorphicTreeForeignKey('self',
null=True,
blank=True,
related_name='children',
verbose_name=_('parent'))
name = models.CharField(max_length=150, unique=True)
company_name = models.CharField(max_length=150, unique=True,
help_text=_('Corportate Name'))
class Account(models.Model):
pass
class Brand(Account):
name = models.CharField()
class Company(Brand):
parent = models.ForeignKey(Brand)
class Reseller(Company):
def save(self, domain_override=None,
subject_template_name='registration/password_reset_subject.txt',
email_template_name='registration/password_reset_email.html',
use_https=False, token_generator=default_token_generator,
from_email=None, request=None):
"""
Generates a one-use only link for resetting password and sends to the
user.
"""
from django.core.mail import send_mail
# Django settings for azionmanager project.
# -*- encoding: utf-8 -*-
import sys
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'azionmanager', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
# Django settings for azionmanager project.
# -*- encoding: utf-8 -*-
import os
import sys
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.