Skip to content

Instantly share code, notes, and snippets.

@martinsam
martinsam / check_dependency.py
Created March 15, 2018 08:40
Check dependency for Python packages
# In Your virtual env
pip install pipdeptree
# get all dependencies
pipdeptree
#copy / paste into SublimeText for example
# cmd + shift + F : httplib to search httplib
# python2.7/site-packages/debug_toolbar/templates/debug_toolbar/panels/templates.html:
# L18
<dd><samp><a href="file://{{ template.template.origin_name|addslashes }}">{{ template.template.origin_name|addslashes }}</a></samp></dd>`
# python2.7/site-packages/debug_toolbar/panels/request_vars.py
#L52
from django.conf import settings
personal_path = ('file:///%s/%s.py') % (
settings.HOME,
self.view_func.__module__.replace('.', '/'))
@martinsam
martinsam / correction.css
Created December 5, 2017 23:26
Je me régale local
#manufacturers{
position:relative;
}
#manufacturers .sub-menu{
width:auto;
min-width:auto;
}
@martinsam
martinsam / remove_duplicate.py
Created September 26, 2017 16:14
Delete duplicate entry - Django
from django.db import models
unique_fields = ['company_id', 'applicant_id']
duplicates = (CertificationApplicantCompany.objects.values(*unique_fields)
.order_by()
.annotate(max_id=models.Max('id'),
count_id=models.Count('id'))
.filter(count_id__gt=1))
for duplicate in duplicates:
@martinsam
martinsam / reverse_delete_dj_object.py
Last active September 21, 2017 08:03 — forked from anonymous/reverse_delete_dj_object.py
Récupérer les données suite à une suppression d'objet
from django.contrib.admin.util import NestedObjects
from django.db import DEFAULT_DB_ALIAS
from django.core import serializers
# flatten function
def flatten(xs):
result = []
if isinstance(xs, (list, tuple)):
@martinsam
martinsam / boostrap.css
Last active June 23, 2017 16:34
Gabarit pour le certificat
/*!
* Bootstrap v3.0.0
*
* Copyright 2013 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world by @mdo and @fat.
*/
@martinsam
martinsam / get_couple_count.py
Created June 16, 2017 13:47
Compter le nombre de doublons présents dans une table (ORM Django)
from django.db.models import Count
ExamConvocation.objects.values('exam_id', 'applicant_id').annotate(Count('id')).order_by().filter(id__count__gt=1)
>> [{'exam_id': 10, 'applicant_id': 80, 'id__count': 2}, {'exam_id': 37, 'applicant_id': 364, 'id__count': 2}]
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Title Here</title>
<meta name="description" content="Description Here">
<meta name="author" content="Author here">
<link rel="stylesheet" href="path_to_css">
<?php
/**
* Super-simple, minimum abstraction MailChimp API v3 wrapper
* MailChimp API v3: http://developer.mailchimp.com
* This wrapper: https://github.com/drewm/mailchimp-api
*
* @author Drew McLellan <[email protected]>
@martinsam
martinsam / nginx.conf
Created September 6, 2016 15:52 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048