Skip to content

Instantly share code, notes, and snippets.

@victorono
victorono / views.py
Created May 26, 2014 17:12
Page erro 404, 500 django
from django.shortcuts import render_to_response
def error_404(request):
response = render_to_response("web/error_404.html")
response.status_code = 404
return response
def error_500(request):
response = render_to_response("web/error_500.html")
response.status_code = 500
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from django.conf import settings
from django.http import HttpResponse, HttpResponseBadRequest
from django.contrib import messages
jQuery.preloadImagesCSS = function() {
var allImgs = [],
k = 0,
sheets = document.styleSheets;
for (var i = 0; i<sheets .length; i++) {
var cssPile = '',
csshref = (sheets[i].href) ? sheets[i].href : 'window.location.href';
@victorono
victorono / es.sh
Created May 17, 2014 22:40 — forked from rajraj/es.sh
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk.i686 -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@victorono
victorono / customtags.py
Created May 8, 2014 18:00
replace all newlines in a string with <br />.
from django import template
register = template.Library()
from django.utils.safestring import mark_safe
@register.filter()
def breakline(text):
return mark_safe("<br />".join(text.split("\n")))
@victorono
victorono / gist:11353437
Last active August 29, 2015 14:00
If you still get "Your tmp directory is NOT writable." warning , do this
chmod -R 777 tmp/
chcon -R -t httpd_sys_content_rw_t 'tmp'
## views.py
import tempfile
import os
import commands
import cgi
from django import http
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render
@victorono
victorono / rel_external.js
Created April 21, 2014 16:00
Open in new tab external links
$('a[rel="external"]').on({
click: function() {
window.open($(this).attr('href'));
return false;
}
});
jQuery(document).ready(function(e) {
"use strict";
});
@victorono
victorono / cdatajs.sublime-snippet
Last active August 29, 2015 13:58
Inserting CDATA Into a Sublime Text Snippet
<snippet>
<description>cdata js</description>
<content><![CDATA[
<script type="text/javascript">
//<![CDATA[
$0
//]]/>
</script>
]]></content>
<tabTrigger>cdatajs</tabTrigger>