Skip to content

Instantly share code, notes, and snippets.

View bhoung's full-sized avatar

Brendan Houng bhoung

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kissgyorgy
kissgyorgy / listen.py
Created September 4, 2020 16:37
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@friedbrice
friedbrice / monadstate-example.hs
Last active April 4, 2024 16:57
MonadState Example
-- monadstate-example.hs
--
-- Load this program in GHCi:
--
-- stack repl \
-- --resolver nightly \
-- --package transformers \
-- --package mtl \
-- monadstate-example.hs
--
@DmitrySoshnikov
DmitrySoshnikov / GIF-Screencast-OSX.md
Created January 30, 2020 07:37 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@mkowoods
mkowoods / tmp.sql
Created July 9, 2019 11:27
Notes for Will Buy on Return visit
Source Data Set: https://console.cloud.google.com/bigquery?p=data-to-insights&d=ecommerce&t=web_analytics&page=table
## TRAIN
CREATE OR REPLACE MODEL `ecommerce.classification_model_2`
OPTIONS
(model_type='logistic_reg', labels = ['will_buy_on_return_visit']) AS
WITH all_visitor_stats AS (
@dkav6
dkav6 / Transform.py
Last active September 21, 2021 12:26
from chalice import Chalice
import boto3
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import pandas as pd
from datetime import datetime
app = Chalice(app_name='Lambda2')
"""On SNS message from Lambda1, tranform data by dropping duplicates
and get sentiment"""
@CMCDragonkai
CMCDragonkai / creating_a_new_stack_project_in_haskell.md
Last active September 14, 2021 11:49
Creating a new Stack Project in a Nix Shell #haskell

Creating a new Stack Project in a Nix Shell

There are so many different ways of building and maintaining Haskell projects.

I'm going to talk about using nix-shell and stack.

First you want a ~/.stack/config.yaml:

 local-bin-path: /home/USERNAME/.stack/bin
@andrevdm
andrevdm / amazonka_eg.hs
Created September 23, 2017 13:10
Amazonka: example dynamo & s3
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Protolude hiding (to, (&))
import qualified System.IO as IO
import Control.Lens ((<&>), (^.), (.~), (&), set, view)
import qualified Data.Text as Txt
import qualified Data.Conduit as C
@tgirke
tgirke / _Nvim-R-Tmux.md
Last active October 13, 2023 05:29
Nvim-R-Tmux: An Integrated Working Environment for R

Nvim-R-Tmux: Neovim-based IDE for R

!!! This Gist tutorial is deprecated. Its new version is available here !!!

This is some red text.

  • Author: Thomas Girke
  • Last update: 18-Nov-2020

@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!