Skip to content

Instantly share code, notes, and snippets.

@philipn
philipn / gist:8659192
Created January 27, 2014 23:07
Mixin to allow limiting of fields, per-request, in django-rest-framework
class AllowFieldLimitingMixin(object):
"""
A mixin for a generic APIView that will allow the serialized fields to be
limited to a set of comma-separated values, specified via the `fields`
query parameter. This will only apply to GET requests.
"""
_serializer_class_for_fields = {}
def get_serializer_class_for_fields(self, serializer_class, fields):
fields = fields.strip().split(',')
@DavidBruant
DavidBruant / gist:8519103
Last active June 3, 2018 22:08
Guide pratique à destination des preneurs de décisions pour faire des applications partagées pérennes disponibles sur une majorité de plateformes

Problème

Créer des applications partagées pérennes qui peuvent être déployées à grande échelle.

Partagées signifie que différents utilisateurs vont pouvoir interagir et "travailler" ensemble sur l'application

Grande échelle, en 2013, signifie que des dizaines à des millions de personnes peuvent utiliser l'application. Une majorité de plateforme doit être accessibles (ordis de bureaux, portables, tablettes, téléphones mobiles) de préférence à moindre coût et donc sans avoir à tout refaire pour chaque appareil. Vivant dans un monde régit par certaines lois physiques, il sera raisonnable de supposer que le réseau de communication est au pire ouvert. La sécurité de l'application ne devra pas supposer le contrôle du réseau, même dans si l'environnement de déploiement est considéré contrôlé.

Pérennes signifie que l'arrivée de nouveaux appareils sur le marché ne remet pas en cause plus de 1% du temps de développement. Personne ne peut prévoir le futur ; il conviendra de garder un œil ouvert sur les ten

@tpokorra
tpokorra / lxc-debian-wheezy
Last active October 4, 2018 19:46
lxc template for debian wheezy to install on Ubuntu precise 12.04 host
#!/bin/bash
#
# lxc: linux Container library
# Authors:
# Daniel Lezcano <[email protected]>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

Happy Freelancing

Je m’appelle Thibaut Assus, j’ai 30 ans, je suis freelance en développement web et ma technologie de prédilection est le Ruby on Rails. J’ai maintenant un peu d’expérience dans le domaine du freelancing et ce document a pour but de partager avec vous une partie de cette expérience.

Mon parcours de développeur Ruby

@trek
trek / ember.html
Last active December 21, 2015 13:29
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{input type="text" value=searchText placeholder="Search..."}}
<ul>
{{#each searchResults}}
<li>{{this}}</li>
{{/each}}
</ul>
</script>
@coffeemug
coffeemug / gist:6168031
Last active October 15, 2024 01:08
The fun of implementing date support
After spending the better part of the month implementing date support
in RethinkDB, Mike Lucy sent the team the following e-mail. It would
have been funny, if it didn't cause thousands of programmers so much
pain. Read it, laugh, and weep!
-----
So, it turns out that we're only going to support dates between the
year 1400 and the year 10000 (inclusive), because that's what boost
supports.
@brutasse
brutasse / clean-redis.py
Created July 14, 2013 10:53
Clean stale RQ jobs
import datetime
import redis
import pytz
from dateutil import parser
from itertools import product
r = redis.Redis()
last_month = (
datetime.datetime.utcnow().replace(tzinfo=pytz.utc) -
@depoulo
depoulo / gist:5832073
Last active January 3, 2025 15:23
CSS-only multi-line ellipsis with generated content. License: http://www.wtfpl.net/txt/copying/
@import "compass/css3/images";
// CSS-only multi-line ellipsis with generated content
// yields `position:relative`, so remember to declare an eventual `position:absolute/fixed` *after* including this mixin
@mixin limitLines(
$maxLinesPortrait, // Mandatory: The number of lines after which the clipping should take action.
$maxLinesLandscape: $maxLinesPortrait, // You may provide a different line limit for landscape orientation.
// Note that 'portrait' is our default orientation. However, if you omit $maxLinesLandscape,
// the value of $maxLinesPortrait is used for whatever orientation (that is, without a media query).
@epicserve
epicserve / redis_key_sizes.sh
Last active February 21, 2025 22:37
A simple script to print the size of all your Redis keys.
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013