Skip to content

Instantly share code, notes, and snippets.

View spout's full-sized avatar

Stéphane Reynders spout

View GitHub Profile
@paulorsbrito
paulorsbrito / search_backends.py
Last active December 25, 2015 07:28 — forked from gregplaysguitar/folding_whoosh_backend.py
This is a fork of Greg's gist, which allows use of character folding with haystack and whoosh. What I've done was to add allow EdgeNGram fields to be folded. This is useful if you're using autocomplete or just indexing text as EdgeNGram field to allow partial keywork search. Thanks, Greg. Have fun.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is a fork of Greg's gist, which allows use of character folding with haystack and whoosh. What
I've done was to add allow EdgeNGram fields to be folded. This is useful if you're using autocomplete
or just indexing text as EdgeNGram field to allow partial keywork search. Thanks, Greg. Have fun.
-+- original comments -+
https://gist.github.com/gregplaysguitar/1727204
@nicolasramy
nicolasramy / .bash_aliases
Last active September 7, 2016 14:21
My personnal dotfiles configuration for Gnu Screen, Vim, Bash for system administration
# Aliases
alias refresh-source='source $HOME/.bashrc'

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@pkmishra
pkmishra / middlewares.py
Last active November 8, 2020 05:26
Scrapy middlewares for random agent list and proxy server usage.
import os
import random
from scrapy.conf import settings
class RandomUserAgentMiddleware(object):
def process_request(self, request, spider):
ua = random.choice(settings.get('USER_AGENT_LIST'))
if ua:
request.headers.setdefault('User-Agent', ua)
class ProxyMiddleware(object):
@andrefsp
andrefsp / gist:5115772
Last active March 1, 2021 22:22
Simple way to inject custom parameters on a Django formset without using django.utils.functional.curry()
"""
Simple example on how to inject a custom user parameters onto a formset
and its forms.
curry(): https://github.com/django/django/blob/1.4.3/django/utils/functional.py#L9
Another answer on:
http://stackoverflow.com/questions/622982/django-passing-custom-form-parameters-to-formset
"""
@nicolasramy
nicolasramy / iptables.md
Last active December 14, 2015 11:59
Tips for Debian System Administration - Installation, Configuration, Useful commands and Tools

IP Tables

Block IP

Block a specific IP

iptables -A INPUT -s 31.2.41.8 -j DROP

Block a range (31.2.41.*)

@pfreixes
pfreixes / gist:3187511
Created July 27, 2012 11:36
Supervisorctl bash autocomplete
# pfreixes, 2012-07-27
# Add to /etc/bash_completion.d/supervisorctl
_supervisor()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
@justinyost
justinyost / paging.ctp
Created March 20, 2012 16:05
Paging Element for Twitter Bootstrap and CakePHP 2.0+
<?php $span = isset($span) ? $span : 8; ?>
<?php $page = isset($this->request->params['named']['page']) ? $this->request->params['named']['page'] : 1; ?>
<div class="pagination">
<ul>
<?php echo $this->Paginator->prev(
'&larr; ' . __('Previous'),
array(
'escape' => false,
'tag' => 'li'
),
@gregplaysguitar
gregplaysguitar / folding_whoosh_backend.py
Last active May 14, 2022 15:09
Django-haystack Whoosh backend with character folding
# -*- coding: utf-8 -*-
"""
Whoosh backend for haystack that implements character folding, as per
http://packages.python.org/Whoosh/stemming.html#character-folding .
Tested with Haystack 2.4.0 and Whooch 2.7.0
To use, put this file on your path and add it to your haystack settings, eg.
@franek
franek / delicious.py
Created December 30, 2011 16:14
Delicious Backup Script
#! /usr/bin/env python
# The Delicious API only returns 1000 bookmarks at a time.
# The web export returns them all in the output file.
#
# To use:
# 1. Install requests: http://python-requests.org
# under ubuntu
# - install pip :
# sudo apt-get install python-pip