Skip to content

Instantly share code, notes, and snippets.

from jinja2.environment import create_cache
# blah blah blah
app.jinja_env.cache = create_cache(1000)
# blah blah blah
app.run()
@sleekslush
sleekslush / gist:57f198bdaa6561fe55c3
Created August 27, 2014 20:12
Change jinja cache size in flask
from flask import Flask as DefaultFlask
class Flask(DefaultFlask):
def create_jinja_environment(self):
self.jinja_options = dict(self.jinja_options)
if 'JINJA_CACHE_SIZE' in self.config:
self.jinja_options['cache_size'] = self.config['JINJA_CACHE_SIZE']
return super(Flask, self).create_jinja_environment()
@staltz
staltz / introrx.md
Last active December 31, 2025 13:31
The introduction to Reactive Programming you've been missing
@willurd
willurd / web-servers.md
Last active December 28, 2025 13:59
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ggl
ggl / htpasswd.pl
Last active July 29, 2024 13:22
htpasswd in perl, no need to install apache tools
#!/usr/bin/env perl
#
# htpasswd.pl
#
# Copyright (c) 2013, Gelu Lupas <[email protected]>
#
# Permission to use, copy, modify, and/or 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.
#
@jberger
jberger / upload.pl
Last active May 4, 2020 09:09
mojolicious file uploads via websocket
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojo::JSON 'j';
use Mojo::Asset::Memory;
use File::Spec;
helper send_ready_signal => sub {
my $self = shift;
my $payload = { ready => \1 };
@zach-klippenstein
zach-klippenstein / ChangePassword.java
Last active June 23, 2024 19:01
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall ([email protected]), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
@waylan
waylan / subprocess_pipe.md
Created April 10, 2012 19:12
Writing to a python subprocess pipe

Here's a few things I tried to write output to a python subprocess pipe.

from subprocess import Popen, PIPE

p = Popen('less', stdin=PIPE)
for x in xrange(100):
    p.communicate('Line number %d.\n' % x)