Skip to content

Instantly share code, notes, and snippets.

View zkan's full-sized avatar
🐻
Stay Hungry. Stay Foolish.

Kan Ouivirach zkan

🐻
Stay Hungry. Stay Foolish.
View GitHub Profile
{{ range $host, $containers := groupBy $ "Env.VIRTUAL_HOST" }}
upstream {{ $host }} {
{{ range $index, $value := $containers }}
{{ $network := index $value.Networks 0 }}
{{ with $address := index $value.Addresses 0 }}
server {{ $network.IP }}:80;
server {{ $network.IP }}:443;
{{ end }}
{{ end }}
@mahasak
mahasak / GitHub-Forking.md
Created August 20, 2017 14:14 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@marwei
marwei / how_to_reset_kafka_consumer_group_offset.md
Created November 9, 2017 23:39
How to Reset Kafka Consumer Group Offset

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
# ---- Base python ----
FROM python:3.6 AS base
# Create app directory
WORKDIR /app
# ---- Dependencies ----
FROM base AS dependencies
COPY gunicorn_app/requirements.txt ./
# install app dependencies
RUN pip install -r requirements.txt
@michaeltreat
michaeltreat / mongodb_shell_commands.md
Last active December 29, 2024 08:19
Quick Cheat Sheet for Mongo DB Shell commands.

MongoDB Shell Commands Cheat Sheet.

This is a Cheat Sheet for interacting with the Mongo Shell ( mongo on your command line). This is for MongoDB Community Edition.

Preface:

Mongo Manual can help you with getting started using the Shell.

FAQ for MongoDB Fundamentals and other FAQs can be found in the side-bar after visiting that link.

import uuid
from django.db import models
from django.contrib.auth import get_user_model
class Badge(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
label = models.CharField(max_length=255)
description = models.TextField()
@turbaszek
turbaszek / big_dag_example.py
Created November 18, 2020 17:24
Sample big dag
import random
from airflow.operators.dummy_operator import DummyOperator
from airflow.models import DAG
from airflow.utils.dates import days_ago
with DAG(
"big_dag",
start_date=days_ago(1),
schedule_interval=None,
@gatukgl
gatukgl / PyConUS2021TicketChallenge.py
Last active May 12, 2021 03:09
PyCon US 2021 Free Ticket Challenge
# Instructions
# 1. Write down Python code in say() method
# - This method might have one parameter `number` which possibly 1-99
# - This method need to return an English word for provided number e.g. If the number is 3, should return "three"
# 2. More examples on test data (numbers and words) are in the "Test Data Example" section
# 3. How to run this file through unit tests
# - Open the terminal
# - Run this command "python <path/to/file.py>" e.g. python PyConUS2021Challenge.py
# - If the tests are failed, it will display "FAILED (failures=16)" for example, on the terminal
# - If the tests are pass, it will display "Ran 16 tests in 0.001s OK"
@ML-engineer
ML-engineer / duckdb_bq_storage_api.py
Created July 4, 2022 22:08
Read BQ table to DuckDB directly from storage read api
import duckdb
from google.cloud import bigquery
bqclient = bigquery.Client()
table = bigquery.TableReference.from_string(
"bigquery-public-data.utility_us.country_code_iso"
)
rows = bqclient.list_rows(table)
country_code_iso = rows.to_arrow(create_bqstorage_client=True)
cursor = duckdb.connect()
@dhh
dhh / linux-setup.sh
Last active April 28, 2025 16:30
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \