Skip to content

Instantly share code, notes, and snippets.

@jgcasta
jgcasta / postgres_queries_and_commands.sql
Created December 8, 2019 16:23 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@jgcasta
jgcasta / git-tags.md
Created June 10, 2019 10:32
Tag releases in git
git add .
git commit -m "commit messge"
git push origin master


git tag -a 0.1.0 -m "tag message"
git push --tags

# delete local tag
@jgcasta
jgcasta / systemd_config.md
Last active April 23, 2019 06:19
Systemd configuration

Configuration

sudo nano /etc/systemd/system/app.service

Edit file content

[Unit]
Description=APP name service
@jgcasta
jgcasta / postgres-cheatsheet.md
Last active January 28, 2018 19:08 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@jgcasta
jgcasta / sec_tutorial.md
Created March 17, 2017 20:34 — forked from tgrall/sec_tutorial.md
MongoDB Security Tutorial

#Simple MongoDB Security Tutorial

###1 - Start mongod without any "security option"

$ mongod --port 27017

@jgcasta
jgcasta / install_python_3.6.sh
Created December 26, 2016 15:12
Python 3.6 install
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
tar xvf Python-3.6.0.tgz
cd Python-3.6.0
./configure --enable-optimizations
make -j8
sudo make altinstall
python3.6
@jgcasta
jgcasta / license-badges.md
Created June 1, 2016 07:26 — forked from lukas-h/license-badges.md
License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file. Easily copy and paste the code under the badges into your Markdown files.

Apache

Apache 2.0 License

License
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

BSD

@jgcasta
jgcasta / listenerStomppyModified.py
Last active August 29, 2015 14:08
Read message variable from class listener when using Stomp interface to ActiveMQ
#!/usr/bin/env python
# ------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@jgcasta
jgcasta / mergeSHP.sh
Created August 27, 2014 15:51
Shell script to merge a list of SHP files from a set of directories
#!/bin/bash
ogr2ogr -a_srs EPSG:4326 out.shp
directories=$(find . -type d)
for directory in $directories
do
files=$(find $directory -name '*.shp')
@jgcasta
jgcasta / BinaryServerSocket.py
Last active July 31, 2021 19:46
Python socket server to receive binary data and parse the content as integer and string values
#!/usr/bin/python
#-*- coding: utf-8 -*-
'''
Jose Gomez Castano
jgcasta@gmail.com
Socket server to receive binary data and parse the content as integer and string values
Sample packet 030b94 received is decoded as decimal string values