Skip to content

Instantly share code, notes, and snippets.

import re
re.compile(r'(?P<size>X{0,2}(S|L)|M)')
# Local test email server
# python -m smtpd -n -c DebuggingServer localhost:1025
EMAIL_HOST = 'localhost'
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 1025
EMAIL_USE_TLS = False
@bulv1ne
bulv1ne / httpCache.js
Created October 4, 2014 18:41
Angular simple http cache invalidate
angular.module('httpCache')
.factory('httpCache', function($http, $cacheFactory) {
var c = $cacheFactory.get('$http');
return function(url, cache) {
if (!cache) {
c.remove(url);
}
return $http({url:url, cache:true});
}

Keybase proof

I hereby claim:

  • I am bulv1ne on github.
  • I am od1n (https://keybase.io/od1n) on keybase.
  • I have a public key whose fingerprint is A4B7 F144 E24C 71B6 6FD3 F0E5 CE54 2774 1A5A 2362

To claim this, I am signing this object:

@bulv1ne
bulv1ne / flaskfile.py
Created August 25, 2014 00:58
Flask upload handler
#!/usr/bin/env python
import os
from flask import Flask, request
from werkzeug import secure_filename
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = os.environ['STATIC_DIR']
@bulv1ne
bulv1ne / models.py
Last active August 29, 2015 14:05
Last Modified ListView
from django.db import models
from django.utils.timezone import now # for migrations
class MyModel(models.Model):
field1 = models.CharField(max_length=255)
last_modified_by = models.DateTimeField(
auto_now=True, default=now, db_index=True)
@bulv1ne
bulv1ne / django-form.html
Created August 12, 2014 22:28
Django form with bootstrap in separate columns
{% load bootstrap %}
<form enctype="multipart/form-data" method="post" class="form" action="">
{% csrf_token %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
<div class="row">
@bulv1ne
bulv1ne / mac_title.sh
Created June 18, 2014 09:22
Mac Terminal title function
# Put this in ~/.bashrc or ~/.bash_profile
function title() {
echo -n -e "\033]0;$1\007";
}
# Usage:
# title "My title"
# ls should return only 1 file
{ ls -l *DVD*; sleep 1; ls -l *DVD*; } | awk '{ print $5 }' | awk 'NR==2 { now = $1 }; NR==1 { then=$1 }; END { print (now-then)/1024 "kB/s" }'
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CHICKENS 20
char *chicken[] = {
" MM\n"
"<' \\___/|\n"
" \\_ _/\n"