Skip to content

Instantly share code, notes, and snippets.

@j-faria
j-faria / read_rdb.py
Last active June 23, 2018 17:58
.rdb file reader
import numpy as np
import cStringIO
filename = 'example.rdb'
def read_rdb(filename):
""" Reads a .rdb file with possible comments '#' and header
col1 col2 col3
---- ---- ----
Returns a numpy record array
@kennwhite
kennwhite / chicken_shrimp_korma_mortal_v1.md
Last active April 17, 2019 17:24
Restaurant style chicken/prawn korma - mere mortal version (v. 1)

Kenn's Chicken/King Prawn Coconut Curry (Korma)

Ingredients

  • 2 cups red or yellow onions, well peeled, loosely chopped
  • 6 cloves peeled garlic, finely grated
  • 2" peeled ginger root, finely grated
  • Optional: 1 medium serrano green pepper, seeded & cored, finely minced (leave out for no heat, use half pepper for medium, full for spicy)
  • 14 oz plain greek yogurt (2% or whole milk, eg FAGE 5%)
  • large can (~14 oz) unsweetened coconut milk (ideally containing no guar gum; well blended if it does)
  • 3 TB cashew butter
@codingjoe
codingjoe / django_docs.md
Last active July 24, 2022 23:16
Build Django docs like a pro!

Build Django docs like a pro!

Sphinx config

docs/conf.py

import importlib
import inspect
import os
import sys
@sktse
sktse / code-reviews.md
Last active August 16, 2022 17:02
How to Keep Pull Requests Manageable

How to Keep Pull Requests Manageable

  • There are a lot different things you can try to keep pull requests manageable.
  • These pointers are not meant to be rules, but merely guidelines when possible. Due to the nature of what you are working on, some of these techniques may not be possible (or incredibly difficult).

More like guidelines

  • Either way, here are some tips to help make people not want to claw their eyes out reviewing a pull request.

The Basics

  • These are the fundamental basics to a pull request and ALL pull requests should have these, regardless of how small or meaningless it is.
@rbw
rbw / part_of_day.py
Last active October 17, 2022 22:44
Get part of day (morning, afternoon, evening, night) in Python3.6+
#!/usr/bin/env python3
def get_part_of_day(h):
return (
"morning"
if 5 <= h <= 11
else "afternoon"
if 12 <= h <= 17
else "evening"
@JamieCressey
JamieCressey / dict_to_dynamodb_item.py
Created April 24, 2016 20:56
Coverts a standard Python dictionary to a Boto3 DynamoDB item
def dict_to_item(raw):
if type(raw) is dict:
resp = {}
for k,v in raw.iteritems():
if type(v) is str:
resp[k] = {
'S': v
}
elif type(v) is int:
resp[k] = {
@daveliepmann
daveliepmann / irises.md
Last active July 21, 2023 12:08
Implementing Sugar & James’ paper, "Finding the number of clusters in a data set: An information theoretic approach" in Clojure — Part 1

Implementing the k-means jump method: Part One

This paper:

Finding the number of clusters in a data set: An information theoretic approach

CATHERINE A. SUGAR AND GARETH M. JAMES

>Marshall School of Business, University of Southern California

.btn {
font-size: 14px;
padding: 6px 12px;
margin-bottom: 0;
display: inline-block;
text-decoration: none;
text-align: center;
white-space: nowrap;
vertical-align: middle;
@nicoleslaw
nicoleslaw / 1_Tiny_Content_Framework.md
Last active January 23, 2024 02:28
Tiny Content Framework

Tiny Content Framework

About the project

This is a tiny content strategy framework focused on goals, messages, and branding. This is not a checklist. Use what you need and scrap the rest. Rewrite it or add to it. These topics should help you get to the bottom of things with clients and other people you work with.

Give me feedback on Twitter (@nicoleslaw) or by email (nicole@nicolefenton.com).

Contents

@smcoll
smcoll / django_migration_pk_to_uuid.py
Last active January 24, 2024 15:55
Django migration converting integer pk table to UUID pk table
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import uuid
from django.db import migrations, models
def fill_mymodel_uuid(apps, schema_editor):
db_alias = schema_editor.connection.alias
MyModel = apps.get_model('myapp', 'MyModel')