Skip to content

Instantly share code, notes, and snippets.

View sgoley's full-sized avatar

sgoley sgoley

  • Remote
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jthandy
jthandy / vacuum-analyze-sinter.md
Created August 13, 2018 19:51
Running vacuum and analyze on Redshift via Sinter

Running vacuum and analyze in Sinter

dbt and Sinter have the ability to run regular Redshift maintenance jobs. It's great to set these up early on in a project so that things stay clean as the project grows, and implementing these jobs in Sinter allows the same easy transparency and notifications as with your other dbt jobs.

This document will go through the specific steps necessary to configure vacuum and analyze jobs in the current version of dbt and Sinter. In the future, there will likely be a more idiomatically consistent way to express this logic using native dbt operations. Currently, this does work even if it is not elegant.

Step 1: Create the macros

macros/redshift_maintenance.sql

@FilippoBovo
FilippoBovo / python_decorator.md
Last active January 26, 2022 13:49
Decorator Example in Data Science

Decorator Example in Data Science

This example explains Python decorators in the context of data science. The example acts as a quick reminder, rather than a complete guide.

Consider a Pandas DataFrame about posts on a social media. The DataFrame, called posts, contains a column with the number of likes for each post.

post_id ... likes ...
1 ... 43 ...
2 ... 92 ...
@FilippoBovo
FilippoBovo / python_and_general_programming_resources.md
Last active July 26, 2018 13:47
Great Python and General Programming Resources
@jakebrinkmann
jakebrinkmann / connect_psycopg2_to_pandas.py
Created July 3, 2017 14:19
Read SQL query from psycopg2 into pandas dataframe
import pandas as pd
import pandas.io.sql as sqlio
import psycopg2
conn = psycopg2.connect("host='{}' port={} dbname='{}' user={} password={}".format(host, port, dbname, username, pwd))
sql = "select count(*) from table;"
dat = sqlio.read_sql_query(sql, conn)
conn = None
@msubel
msubel / uuid_v4_excel_formula.txt
Created July 14, 2015 12:37
An Excel Fromula to generate a UUID v4
=LOWER(CONCATENATE(DEC2HEX(RANDBETWEEN(0;POWER(16;8));8);"-";DEC2HEX(RANDBETWEEN(0;POWER(16;4));4);"-";"4";DEC2HEX(RANDBETWEEN(0;POWER(16;3));3);"-";DEC2HEX(RANDBETWEEN(8;11));DEC2HEX(RANDBETWEEN(0;POWER(16;3));3);"-";DEC2HEX(RANDBETWEEN(0;POWER(16;8));8);DEC2HEX(RANDBETWEEN(0;POWER(16;4));4)))
@rogiervandenberg
rogiervandenberg / JourneyExtractor.php
Last active June 29, 2024 17:29
Journal (by Journey) extractor. Journey is a great Diary app for Android and Google Chrome. But, your files are only accessible by Journey itself. Do you want to move away from Journey to another diary app? Do you want to have a readable export of your diary? This script converts Journey backup/export files to managable Markdown files. One file …
<?php
/*
Journal (by Journey) extractor
Journey is a great Diary app for Android and Google Chrome. But, your files are
only accessible by Journey itself.
Do you want to move away from Journey to another diary app? Do you want to have
a readable export of your diary? This script converts Journey backup/export
@wadewegner
wadewegner / addBatch.py
Last active June 29, 2020 20:55
Source code for blog post on using the bulk API with Python
def addBatch(instance, sessionId, jobId, objects):
request = u"""<?xml version="1.0" encoding="UTF-8"?>
<sObjects xmlns="http://www.force.com/2009/06/asyncapi/dataload">
""" + objects + """
</sObjects>"""
encoded_request = request.encode('utf-8')
url = "https://" + instance + ".salesforce.com/services/async/30.0/job/" + jobId + "/batch"
@mziwisky
mziwisky / Oauth2.md
Last active February 15, 2024 23:31
Oauth2 Explanation

OAUTH2

The Problem

I’m a web app that wants to allow other web apps access to my users’ information, but I want to ensure that the user says it’s ok.

The Solution

I can’t trust the other web apps, so I must interact with my users directly. I’ll let them know that the other app is trying to get their info, and ask whether they want to grant that permission. Oauth defines a way to initiate that permission verification from the other app’s site so that the user experience is smooth. If the user grants permission, I issue an AuthToken to the other app which it can use to make requests for that user's info.

Note on encryption

Oauth2 has nothing to do with encryption -- it relies upon SSL to keep things (like the client app’s shared_secret) secure.