Skip to content

Instantly share code, notes, and snippets.

View czue's full-sized avatar

Cory Zue czue

View GitHub Profile
@czue
czue / gist:6082293
Created July 25, 2013 18:12
hq log config
# MIN_LOG_LEVEL = 'DEBUG'
MIN_LOG_LEVEL = 'INFO'
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
INFO 2015-07-21 10:33:33,855 xformserver 31567 159 Received action answer
INFO 2015-07-21 10:33:34,095 xformserver 31567 161 Received action submit-all
INFO 2015-07-21 10:33:34,250 xformserver 31567 162 Received action answer
INFO 2015-07-21 10:33:34,313 xformserver 31567 163 Received action answer
INFO 2015-07-21 10:33:35,819 xformserver 31567 164 Received action answer
INFO 2015-07-21 10:33:37,506 xformserver 31567 165 Received action answer
INFO 2015-07-21 10:33:40,344 xformserver 31567 166 Received action answer
INFO 2015-07-21 10:33:46,963 xformserver 31567 167 Received action answer
INFO 2015-07-21 10:33:46,996 xformserver 31567 168 Received action answer
INFO 2015-07-21 10:33:47,713 xformserver 31567 169 Received action answer

Kafka Migration

Problem statement

We need to migrate Kafka from one machine to the other, ideally with 0 downtime.

Planned solution

  1. Spin up the new kafka environment
  2. Publish changes from production to both environment in parallel
  3. Confirm new environment is working
  4. Flip a pointer for the feeds that run off kafka
@czue
czue / json_tags.py
Last active December 15, 2023 21:41
A simple django template tag that lets you automatically render json from a python object
"""
Usage:
{% load json_tags %}
var = myJsObject = {{ template_var|to_json }};
Features:
- Built in support for dates, datetimes, lazy translations.
@czue
czue / git_grep_blame.sh
Created November 14, 2017 07:06
A little bash script for git blaming things matching git grep
#!/bin/bash
# usage: ./git_grep_blame.sh todo
# HT: https://stackoverflow.com/a/43664756/8207
if [ "$1" = "" ] ; then
echo "usage: $0 <term>" 1>&2
exit 1
fi
@czue
czue / hq-todos.txt
Created November 14, 2017 07:18
HQ TODOs (with blame)
corehq/apps/accounting/bootstrap/utils.py ::
corehq/apps/accounting/forms.py ::
corehq/apps/accounting/models.py ::
corehq/apps/accounting/payment_handlers.py ::
corehq/apps/accounting/static/accounting/js/invoices.js ::
15a3bebbd8c (Daniel Roberts 2016-06-29 17:51:44 -0400 12) // todo: use a more specific identifier to make less brittle
corehq/apps/accounting/subscription_changes.py ::
corehq/apps/accounting/tests/test_invoicing.py ::
corehq/apps/analytics/ab_tests.py ::
f35a49c480f (Biyeun Buczyk 2016-07-06 18:12:26 -0400 29) version = random.sample(self.options, 1)[0] # todo weighted options
@czue
czue / ratatat-el-pico.rb
Created January 3, 2020 10:57
SonicPi code for the first few bars of Ratatat's El Pico
use_bpm 95
# main guitar riff
mini_riff_1 = [:b4, :e4, :g4, :b4]
mini_riff_2 = [:g4, :b3, :e4, :g4]
mini_riff_3 = [:a4, :c4, :gb4, :a4]
mini_riff_4 = [:gb4, :b3, :d4, :gb4]
mini_riff_5 = [:c5, :gb4, :a4, :c5]
@czue
czue / subscription.py
Created December 17, 2020 06:42
subscriptions
{% extends "portal_base.html" %}
{% load staticfiles %}
{% block title %} Payment {% endblock %}
{% block content %}
<div class="dashboard-interactions">
<div class="interactions-wrap full-width">
<div class="interactions-panel">
@czue
czue / langchain_qa_chatgpt_bot.py
Last active November 5, 2024 15:32
sample code for chatgpt / gpt4 langchain Q&A
# see https://www.youtube.com/watch?v=CsFpVdgEXCU for details of what this does
from typing import List
from langchain import ConversationChain
from langchain.chat_models import ChatOpenAI
from langchain.indexes.vectorstore import VectorStoreIndexWrapper
from langchain.memory import ConversationBufferMemory
from langchain.prompts import (
ChatPromptTemplate,
@czue
czue / function.js
Created August 25, 2023 16:45
OpenAI function for Source Citations in a RAG architecture
{
"name": "answer_and_sources",
"description": "Gets an answer and cites the relevant sources used to provide the answer.",
"parameters": {
"type": "object",
"properties": {
"answer": {
"type": "string",
"description": "The answer to the user's question.",
},