Skip to content

Instantly share code, notes, and snippets.

View isogram's full-sized avatar
🙊

Muhammad Shidiq isogram

🙊
View GitHub Profile
@isogram
isogram / MySQL Query Collection.sql
Last active April 18, 2023 05:15
Get Database Size MySQL
-- Get Database Size
SELECT
table_schema AS 'Database',
SUM(data_length + index_length) / 1024 / 1024 AS 'Size (MB)'
FROM
information_schema.TABLES
GROUP BY table_schema
-- Get Table Size
SELECT
@isogram
isogram / docker-compose.yml
Created December 22, 2022 09:08 — forked from bocharovf/docker-compose.yml
Complete Jaeger docker-compose deployment with ElasticSearch (oss) and Apache Kafka. Jaeger Query and Kibana to search logs and traces. Monitoring with Prometheus and Grafana.
version: "3"
services:
# Using ElasticSearch as a storage for traces and logs
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.7.1
networks:
- elastic-jaeger
ports:
@isogram
isogram / remote_ssh_vscode.md
Created August 26, 2021 05:21
Fix remote ssh visual code studio cannot connect server host

Failed to set up socket for dynamic port forward to remote port 40413: Socket closed. Is the remote port correct?

Follow these steps

  • Update the sshd_config file in the host machine. Follow this command: nano /etc/ssh/sshd_config and then set AllowTcpForwarding to yes
  • Restart ssh on the host machine sudo systemctl restart ssh
  • Delete the .vscode-server in host machine rm -rf /home/<user_name>/.vscode-server

Now connect through VS Code again. Hopefully it will work

@isogram
isogram / loop_threading.py
Created April 7, 2021 06:23
Python Threading Split in For Loop
# https://stackoverflow.com/a/15144090/2212582
import threading
def process(items, start, end):
for item in items[start:end]:
try:
api.my_operation(item)
except Exception:
print('error with item')
@isogram
isogram / create_empty_dataframe_pyspark.py
Created June 2, 2020 07:33
Pyspark Create Empty Dataframe
from pyspark.sql.types import StringType, FloatType, StructField, StructType
from pyspark.sql import SparkSession, SQLContext, Row
import pyspark
# spark initialization
spark_context = pyspark.SparkContext.getOrCreate()
spark_session = SparkSession(spark_context) \
.builder \
.enableHiveSupport() \
.getOrCreate()
@isogram
isogram / editablescript.js
Created May 16, 2019 19:26
Editable Page HTML
document.body.contentEditable='true'; document.designMode='on'; void 0
@isogram
isogram / postgres_duplicate.md
Created September 3, 2018 08:52
PostgreSQL duplicate database with data

Postgres allows the use of any existing database on the server as a template when creating a new database. I'm not sure whether pgAdmin gives you the option on the create database dialog but you should be able to execute the following in a query window if it doesn't:

CREATE DATABASE newdb WITH TEMPLATE originaldb OWNER dbuser;

Still, you may get:

ERROR:  source database "originaldb" is being accessed by other users
@isogram
isogram / jsonapi_rehydrate.py
Created July 30, 2018 10:20
Format JSON API response specification to simple format JSON Format
# -*- coding: utf-8 -*-
__author__ = """Julien Duponchelle"""
__email__ = 'julien@duponchelle.info'
__version__ = '0.2.0'
def parse(content):
"""
:param content: A JSON API document already
:returns: The JSON API document parsed
@isogram
isogram / README-Template.md
Created February 22, 2018 18:37 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@isogram
isogram / install_elixir.md
Created January 14, 2017 19:23 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.