Skip to content

Instantly share code, notes, and snippets.

View artofhuman's full-sized avatar
💭
I use vim, btw

Semyon Pupkov artofhuman

💭
I use vim, btw
View GitHub Profile
@artofhuman
artofhuman / gist:3737042
Created September 17, 2012 12:35 — forked from armonge/gist:2830057
django youtube field
import urlparse
import re
from django.db import models
from django import forms
def validate_youtube_url(value):
'''El patron lo saque de http://stackoverflow.com/questions/2964678/jquery-youtube-url-validation-with-regex'''
pattern = r'^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=\w+)(?:\S+)?$'
@artofhuman
artofhuman / fields.py
Created October 3, 2012 11:24
Django HorizRadioSelect
from django.utils.html import mark_safe
from django.forms.widgets import RadioSelect
class HorizRadioRenderer(RadioSelect.renderer):
""" this overrides widget method to put radio buttons horizontally
instead of vertically.
"""
def render(self):
"""Outputs radios"""
@artofhuman
artofhuman / vim.rb
Created October 13, 2012 18:38 — forked from mgrouchy/vim.rb
Vim formula for Homebrew
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'https://vim.googlecode.com/hg/', :revision => '6c318419e331'
version '7.3.515'
def features; %w(tiny small normal big huge) end
def interp; %w(lua mzscheme perl python python3 tcl ruby) end
@artofhuman
artofhuman / gist:4007265
Created November 3, 2012 12:48 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
block goods {
tag: 'ul'
content: {
var content = [];
this.ctx.goods.forEach(function(item){
var mods = {};
@artofhuman
artofhuman / isntall-redis
Created December 5, 2012 04:39
isntall-redis
#!/bin/bash
# Install Redis
echo 'Install Redis'
cd /tmp
mkdir redis && cd redis
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make && make install
@artofhuman
artofhuman / vim.rb
Created December 27, 2012 18:36 — forked from voldmar/vim.rb
# To use this recipe you have to:
# $ brew install python --framework
# $ mkdir ~/Frameworks
# $ ln -s "/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework" ~/Frameworks
# $ brew install ./vim.rb
require 'formula'
require 'open-uri'
class Vim < Formula
@artofhuman
artofhuman / scroll_to_element.js
Created January 27, 2013 07:49
Javascript: ScrollToElement
/**
* Scrol to elem
* @param {String} selector [description]
* @param {Function} callback [description]
*/
function scrollToElement(selector, callback){
var animation = {scrollTop: $(selector).offset().top};
console.log(selector);
$('html,body').animate(animation, 'slow', 'swing', function() {
if (typeof callback == 'function') {
@artofhuman
artofhuman / fabfile.py
Created January 28, 2013 18:18
example fabfile.py
# -*- coding: utf-8 -*-
from fabric.api import task
from fabric.api import run
from fabric.api import local
from fabric.api import env
from fabric.api import cd
from fabric.api import prefix
from fabric.api import hide
# Расположение зависимостей для проекта
@artofhuman
artofhuman / nocachemiddleware.py
Created February 5, 2013 11:18
nocachemidleware
class NoCacheMiddleware(object):
def process_response(self, request, response):
response['Pragma'] = 'no-cache'
response['Cache-Control'] = 'private, max-age=0, proxy-revalidate, no-store, no-cache, must-revalidate'
return response