Skip to content

Instantly share code, notes, and snippets.

David Talagrand harmo

Block or report user

Report or block harmo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import subprocess
import time
import os
from watchdog.observers import Observer
from import FileSystemEventHandler
class WatchMeDo(FileSystemEventHandler):
View Rectangle into

The drawing below gives an idea of how to cut a given "true" rectangle into squares ("true" rectangle meaning that the two dimensions are different).

Can you translate this drawing into an algorithm?

You will be given two dimensions

a positive integer length (parameter named lng) a positive integer width (parameter named wdth)

harmo /
Created Feb 7, 2017
SublimeText3 - Goto definition

Create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User

        "button": "button1", 
        "count": 1, 
        "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "command": "goto_definition"

Consider having a cow that gives a child every year from her fourth year of life on and all her subsequent children do the same.

After n years how many cows will you have?

count_cows(0)  # should equal 1
count_cows(1)  # should equal 1
count_cows(3)  # should equal 2
count_cows(4)  # should equal 3
count_cows(10)  # should equal 28
View biggest_tables.sql
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC
View best movies
  • Jeunet/caro (delicatessen, TS spivet, etc)
  • Pulp fiction
  • Cornetto's (Hot fuzz, shaun of the dead, etc)
  • Zombieland
  • District 9
  • Kill bill (1 & 2)
  • Grand budapest hotel
  • Reservoir dogs
  • Inglourious Basterds
  • ExistenZ
# -*- coding: utf-8 -*-
from django.db import models
from django.core.cache import cache
from django.db.models.query import QuerySet
from utils import key_for_instance
class CachedQuerySet(QuerySet):
def get_pk(self, kwargs):
View href_replace.js
if('paginate_by') > 0){
regExp = /paginate_by=(\d+)/;
location.href = location.href.replace(regExp, 'paginate_by='+val);
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.db import models
from django.forms import SelectMultiple
from gpdis.intranet.apps.commerce.models import Promotions, StoreAdmin
class PromotionsAdmin(admin.ModelAdmin):
list_display = ('network', 'platform', 'start', 'end', 'source_code', 'attached_file')
list_filter = ('platform', 'network', 'start', 'end')
from django.forms import SelectMultiple
from django.db import models
from django.contrib import admin
class EmailOperationAdmin(admin.ModelAdmin):
list_display = ('store', 'date', 'mail_object')
formfield_overrides = {
models.ManyToManyField: {
'widget': SelectMultiple(attrs={'size': '15', 'style': 'width:600px;'})
You can’t perform that action at this time.