Skip to content

Instantly share code, notes, and snippets.

CREATE OR REPLACE FUNCTION is_private_ip(p_prefix inet) RETURNS boolean AS
$BODY$
BEGIN
RETURN (
SELECT
CASE
WHEN '10.0.0.0/8'::inet >> p_prefix::inet
OR '192.168.0.0/16'::inet >> p_prefix::inet
OR '172.16.0.0/12'::inet >> p_prefix::inet THEN True
--select deps_save_and_drop_dependencies('public','test_table')
--select deps_restore_dependencies('public','test_table')
--select * from deps_saved_ddl
create table deps_saved_ddl
(
deps_id serial primary key,
deps_view_schema varchar(255),
#result = dict_items(response, 'Body/findResponse/result/Interface')
def dict_items(dict, path, separator='/'):
for item in path.split(separator):
if item in dict:
dict = dict[item]
if type(dict) is str and len(dict)<=0:
return None
else:
WITH weeks AS (
SELECT distinct date_trunc('week', dates)::date AS start,
daterange(date_trunc('week', dates)::date, (date_trunc('week', dates) + interval '7 days')::date) week
FROM generate_series(date '2013-01-01', now(), '1 day')
dates ORDER BY 1
)
SELECT weeks.start,
count(whatever.*) as count
FROM whatever
JOIN weeks
@hbasria
hbasria / graphite.md
Last active August 29, 2015 14:07 — forked from kgadek/graphite.md

Installing Graphite:

Graphite does two things:

  1. Store numeric time-series data
  2. Render graphs of this data on demand

What Graphite does not do is collect data for you, however there are some tools out there that know

{
"template": "logstash-*",
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0,
"index" : {
"query" : { "default_field" : "@message" },
"store" : { "compress" : { "stored" : true, "tv": true } }
}
},
#!/bin/sh
### BEGIN INIT INFO
# Provides: gunicorn
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the gunicorn server
# Description: starts gunicorn using start-stop-daemon
# /etc/elasticsearch/elasticsearch.yml
#
# Remember the cluster name if you ever add extra nodes
cluster.name: logstash
# If you leave node.name blank, it'll autogenerate a node name each time you start ES, picking from 3000 marvel comicbook heroes.
node.name: "log-indexer"
node.master: true
node.data: true
# Set the bind address specifically (IPv4 or IPv6)

installing postgresql 9.3.2 on ubuntu 12.04

$ echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-9.3 postgresql-contrib-9.3

you should succesfully installing postgresql 9.3.2 on your machine.

## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static