Skip to content

Instantly share code, notes, and snippets.

@artisonian
artisonian / simple_gridfs_server.py
Created July 27, 2010 19:24
A simple GridFS server built with Flask
from flask import Flask, request, redirect, url_for, make_response, abort
from werkzeug import secure_filename
from pymongo import Connection
from pymongo.objectid import ObjectId
from gridfs import GridFS
from gridfs.errors import NoFile
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
DB = Connection().gridfs_server_test
FS = GridFS(DB)
@navilan
navilan / fuctions.py
Created February 6, 2012 15:59
A hyde plugin to add a context function to jinja and related
#<site_root>/functions.py
from hyde.plugin import Plugin
def quoted(var):
return '"%s"' % var
class MyJinjaLoader(Plugin):
def template_loaded(self, template):
@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 16, 2024 19:37
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tavisrudd
tavisrudd / kinesis.txt
Created March 2, 2013 18:10
A partial list of the Kinesis Advantage / Controllermate / Emacs keybinding tweaks I've done.
Remapped on kinesis itself
--------------------------------------------------------------------------------
caps lock -> backspace (freq use)
backspace -> right gui/windows (freq use)
left alt -> return/enter (very infreq use)
right ctrl -> return/enter (freq use)
right gui/windows -> left gui
enter -> right gui (infreq use)
@cuppster
cuppster / flask_gridfs_images.py
Created March 12, 2013 18:24
Recipe for downloading images into a mongoDB gridfs collection, then serving the images with a Flask application. No temp files created.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
SYNOPSIS
flask_gridfs_images.py --start
flask_gridfs_images.py --add <IMAGE_URL>
DESCRIPTION
@agarciadom
agarciadom / find-color-pages
Last active January 21, 2024 18:56
Small Python 2.7+ script that lists the color pages in a PDF along with their CMYK ink mixes, as computed by the 'inkcov' device in Ghostcript 9.05+. "find-color-pages file.pdf" lists the color pages and their CMYK ink mixes, "find-color-pages -c file.pdf" prints the number of color pages in the PDF and "find-color-pages -C 0.39 -B 0.04 file.pdf…
#!/usr/bin/env python
# Simple script for finding and counting the color pages in a PDF
# Copyright (C) 2013-2019 Antonio Garcia-Dominguez
# Licensed under the GPLv3
#
# This script is based on the following thread (thanks for the tip!):
#
# http://tex.stackexchange.com/questions/53493
#
@tcooper
tcooper / building_lustre_client_rpms.md
Created April 18, 2014 21:53
Lustre Client RPM Build Process

Lustre 2.4.2 Client Build

Basic sequence to download/build Lustre client rpms...

  1. clone
  2. checkout
  3. autogen
  4. configure
  5. make
  6. make rpms
@elainenaomi
elainenaomi / Ruby_Rails_Naming_Conventions.md
Created December 28, 2017 01:53 — forked from alexpchin/Ruby_Rails_Naming_Conventions.md
Ruby & Rails Naming Conventions

Alex's Rails Cheat Sheet

I think the most confusing thing that I have found about Ruby on Rails so far has been the transition from (trying to) write code myself to the use of the fabled "Rails Magic". So, to help my own understanding of a few core Ruby on Rails concepts, I have decided to write something on what I think is a CRITICAL topic... the idea of Convention over Configuration and why (in my mind) it is the most important thing that helps Rails become magic!

(This may be a topic that we cover in more detail in class but as I said, I'm writing this for my own understanding... I hope it helps someone else understand things too... Perhaps you can give me a hand when I'm crying next week!)

##Convention over configuration ###What does this "actually" mean...

@mivade
mivade / zmq_auth.py
Last active December 30, 2023 12:57
ZeroMQ Curve authentication demo
"""Simple demonstration of using ZMQ's Curve authentication.
This demo is adapted from the examples given in the `PyZMQ repository`__. Key
differences include:
* Using ``setsockopt`` to set Curve parameters instead of setting attributes
directly (help out your IDE!)
* Integration with ``asyncio``
__ https://github.com/zeromq/pyzmq/tree/master/examples