Skip to content

Instantly share code, notes, and snippets.

View mathcass's full-sized avatar
👋

Cass mathcass

👋
View GitHub Profile
@abulka
abulka / fncache.py
Last active February 13, 2024 17:40 — forked from kwarrick/fncache.py
Redis-backed LRU cache decorator in Python.
#!/usr/bin/env python
__author__ = 'Kevin Warrick'
__email__ = 'kwarrick@uga.edu, abulka@gmail.com'
__version__ = '2.0.0'
import pickle
from collections import namedtuple
from functools import wraps
import inspect
from icecream import ic
select *, REGEXP_REPLACE(REGEXP_REPLACE(word, r'^[^:]*:', ''), r':[^:]*$', '') as emoticon from (
SELECT type, repo.name, actor.login, org.login,JSON_EXTRACT(payload, '$.comment.id') as comment_id, JSON_EXTRACT(payload, '$.comment.url') as url, SPLIT(JSON_EXTRACT(payload, '$.comment.body'), ' ') as word, MONTH(TIMESTAMP(REGEXP_REPLACE(JSON_EXTRACT(JSON_EXTRACT(payload, '$.comment'), '$.created_at'), r'"|T.*', ''))) as m
FROM (TABLE_DATE_RANGE([githubarchive:day.events_],
TIMESTAMP('2015-03-01'),
TIMESTAMP('2015-03-10')
))
WHERE (type = 'IssueCommentEvent' OR type = 'PullRequestReviewCommentEvent' OR type = 'CommitCommentEvent') AND org.login = 'dimagi' AND actor.login <> 'dimagimon'
)
@karpathy
karpathy / min-char-rnn.py
Last active April 23, 2024 17:55
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@rcmachado
rcmachado / Makefile
Last active February 7, 2024 06:04
Add a help target to a Makefile that will allow all targets to be self documenting
.SILENT:
.PHONY: help
# Based on https://gist.github.com/prwhite/8168133#comment-1313022
## This help screen
help:
printf "Available targets\n\n"
awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
@kwarrick
kwarrick / fncache.py
Last active March 25, 2023 01:28
Redis-backed LRU cache decorator in Python.
#!/usr/bin/env python
__author__ = 'Kevin Warrick'
__email__ = 'kwarrick@uga.edu'
import cPickle
from functools import wraps
def redis_lru(capacity=5000, slice=slice(None)):
"""
Simple Redis-based LRU cache decorator *.
@gbarrancos
gbarrancos / gist:3277138
Created August 6, 2012 17:57
7 Tips for Successful Self Learning

7 Tips for Successful Self Learning - by Bradford Cross

No matter what, you're going to have to learn most everything on your own anyway. Self-learning is hard. Regardless of where, when or how you learn - being a good self-learner will maximize your potential.

In this post, Hamilton Ulmer (an almost-done Stanford stats masters student) and I, will explore seven ways to become a great self-learner.

The longest path is the shortest and the shortest path is the longest

@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@asenchi
asenchi / python.pp
Created February 20, 2010 14:56
Puppet manifest for installing Python and modules using pip
# Copyright (c) 2010 Curt Micol <asenchi@asenchi.com>
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN