Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
for ip in $(seq 1 254); do ping -c 1 192.168.21.$ip -t 2 &>/dev/null; [ $? -eq 0 ] && echo "192.168.21.$ip UP" || : ; done
# https://blog.hypertrack.io/2016/10/08/dealing-with-database-transactions-in-django-celery/
# @shared_task(base=TransactionAwareTask, bind=True, max_retries=settings.EVENT_MAX_RETRIES)
# def push_event(self, event_id):
# event = Event.objects.get(id=event_id)
class TransactionAwareTask(Task):
'''
Task class which is aware of django db transactions and only executes tasks
after transaction has been committed
'''
@MikeVL
MikeVL / track_data.py
Created September 27, 2016 19:56 — forked from dcramer/track_data.py
Tracking changes on properties in Django
from django.db.models.signals import post_init
def track_data(*fields):
"""
Tracks property changes on a model instance.
The changed list of properties is refreshed on model initialization
and save.
>>> @track_data('name')
@MikeVL
MikeVL / DDR.md
Last active November 25, 2016 09:52
  • 5 Mark (Otto Lilienthal) 1973
  • 5 Mark (Philipp Reis) 1974
  • 5 Mark (Thomas Mann) 1975
  • 5 Mark (Friedrich Gottlieb Klopstock) 1978
  • 5 Mark (Albert Einstein) 1979
  • 5 Mark (Adolph von Menzel) 1980
  • 5 Mark (Tilman Riemenschneider) 1981
  • 5 Mark (Friedrich Froebel) 1982
  • 5 Mark (Goethes Weimar Cottage) 1982
  • 5 Mark (Wartburg Castle) 1982-1983
"""
Logical deletion for Django models. Uses is_void flag
to hide discarded items from queries. Overrides delete
methods to set flag and soft-delete instead of removing
rows from the database.
"""
from django.apps import apps
from django.contrib.admin.utils import NestedObjects
from django.db import models
from django.db.models import signals
@MikeVL
MikeVL / sysctl.conf
Last active August 29, 2015 14:25 — forked from ftkro/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.tcp_fastopen = 0x403

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@MikeVL
MikeVL / django.vcl
Created December 11, 2013 14:44 — forked from 10p-freddo/django.vcl
sub vcl_recv {
# unless sessionid/csrftoken is in the request, don't pass ANY cookies (referral_source, utm, etc)
if (req.request == "GET" && (req.url ~ "^/static" || (req.http.cookie !~ "sessionid" && req.http.cookie !~ "csrftoken"))) {
remove req.http.Cookie;
}
# normalize accept-encoding to account for different browsers
# see: https://www.varnish-cache.org/trac/wiki/VCLExampleNormalizeAcceptEncoding
if (req.http.Accept-Encoding) {
if (req.http.Accept-Encoding ~ "gzip") {