Skip to content

Instantly share code, notes, and snippets.

@munificent
munificent / generate.c
Last active May 7, 2024 06:19
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@ionelmc
ionelmc / .gitignore
Last active February 12, 2020 09:26
A JSON parser benchmark. See README.rst for instructions.
*.cbor
*.log
*.xml
*.yaml
*.json
*.msgpack
*.html
*.marshal
*.pickle
.tox
@typehorror
typehorror / Flask-SQLAlchemy Caching.md
Last active February 15, 2024 14:44
Flask SQLAlchemy Caching

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)

@xudifsd
xudifsd / t.c
Created August 25, 2013 08:24
compile C and execute "python t.py", press CTRL+C or CTRL+\ when executing python. will print "^Cgot signal" in my laptop
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
int signaled = 0;
void handler(int ignored) {
signaled = 1;
}
@hongqn
hongqn / main.py
Created December 17, 2012 06:01
Template for main.py If you use vim, you can use https://github.com/aperezdc/vim-template or https://github.com/mattn/zencoding-vim to create it whenever you need a main script in python.
import sys
import logging
import argparse
def main(args):
pass
if __name__ == '__main__':
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
@Nurdok
Nurdok / python_conversion.md
Last active December 16, 2022 03:45
Python Conversion

Python Number Conversion Chart

From To Expression

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@dbarnett
dbarnett / jsonalchemy.py
Created February 3, 2012 15:10
JSONAlchemy: Proper JSON marshalling and mutation tracking in SQLAlchemy
import simplejson
import sqlalchemy
from sqlalchemy import String
from sqlalchemy.ext.mutable import Mutable
class JSONEncodedObj(sqlalchemy.types.TypeDecorator):
"""Represents an immutable structure as a json-encoded string."""
impl = String
@zacharyvoase
zacharyvoase / pythonrc.py
Created May 4, 2011 13:31 — forked from benhodgson/pythonrc.py
Python startup file with completion, history and colored source browsing.
import inspect
import sys
def src(obj):
"""Read the source of an object in the interpreter."""
def highlight(source):
try:
import pygments
@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