Skip to content

Instantly share code, notes, and snippets.

@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
@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 / loadExternalFiles.xml
Last active April 21, 2018 17:25
Spring bean to describe how to load external property file, and Log4j.properties
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
@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 / Createvm.sh
Created June 14, 2014 10:58
Shell script to create a VirtualBox Virtual machine
#!/bin/bash
#
# createvm.sh
#
# ver 1.0
#
# Jose Gomez Castaño jgcasta@gmail.com
#
# Create a Virtual Box Machine in the createPath directory with the name given in name variable.
@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 / getTLE.py
Last active June 10, 2016 19:31
Get TLE orbital elements for a NORAD ID satellite and date
#!/usr/bin/env python
# -*- coding: utf-8
'''
GEt TLE orbital elements for a Satellite
@author Jose Gomez Castaño jgcasta@gmail.com
@version 1.0.0
@precondition username and password to login into www.space-track.org website is needed