Skip to content

Instantly share code, notes, and snippets.

View dmarcelino's full-sized avatar

Dário dmarcelino

  • AppsCot
  • Lisbon, Portugal
View GitHub Profile
@neara
neara / forms.py
Last active April 17, 2024 19:54
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@shawndumas
shawndumas / .gitconfig
Created August 5, 2013 19:08
Using WinMerge as the git Diff/Merge Tool on Windows 64bit
[mergetool]
prompt = false
keepBackup = false
keepTemporaries = false
[merge]
tool = winmerge
[mergetool "winmerge"]
name = WinMerge
@dustinfarris
dustinfarris / Sharing Django Users and Sessions Across Projects
Created July 26, 2013 00:38
This is a dated document and may be improved on.
# Sharing Django Users and Sessions Across Projects
By Dustin Farris on 22 Feb 2012
This document describes how to share users created using Django's auth system with other
Django projects. It is not a hack; it simply makes use of the database router and
middleware system that Django comes with out of the box.
## Introduction
@allybee
allybee / target_blank.js
Last active November 7, 2023 22:40
Add target="_blank" to external links with pure JavaScript.
function targetBlank() {
// remove subdomain of current site's url and setup regex
var internal = location.host.replace("www.", "");
internal = new RegExp(internal, "i");
var a = document.getElementsByTagName('a'); // then, grab every link on the page
for (var i = 0; i < a.length; i++) {
var href = a[i].host; // set the host of each link
if( !internal.test(href) ) { // make sure the href doesn't contain current site's host
a[i].setAttribute('target', '_blank'); // if it doesn't, set attributes
@lancejpollard
lancejpollard / cursor-position.js
Created September 22, 2012 07:24
Get Cursor Position in Terminal with Node.js
module.exports = function(callback) {
require('child_process').exec('./cursor-position.sh', function(error, stdout, stderr) {
callback(error, JSON.parse(stdout));
});
}
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@Zodiac1978
Zodiac1978 / .htaccess
Last active March 15, 2024 08:29
Make your Website faster - a safe htaccess way
#
# Sources:
# http://stackoverflow.com/questions/7704624/how-can-i-use-gzip-compression-for-css-and-js-files-on-my-websites
# http://codex.wordpress.org/Output_Compression
# http://www.perun.net/2009/06/06/wordpress-websites-beschleuinigen-4-ein-zwischenergebnis/#comment-61086
# http://www.smashingmagazine.com/smashing-book-1/performance-optimization-for-websites-part-2-of-2/
# http://gtmetrix.com/configure-entity-tags-etags.html
# http://de.slideshare.net/walterebert/die-htaccessrichtignutzenwchh2014
# http://de.slideshare.net/walterebert/mehr-performance-fr-wordpress
# https://andreashecht-blog.de/4183/
@stephenfeather
stephenfeather / analytics.js
Created June 2, 2012 18:09
commonJS version of Roger Chapman's Google Analytics Library for Appcelerator's Titanium Mobile SDK
/*
The MIT License
Copyright (c) 2010 Roger Chapman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@gregplaysguitar
gregplaysguitar / folding_whoosh_backend.py
Last active May 14, 2022 15:09
Django-haystack Whoosh backend with character folding
# -*- coding: utf-8 -*-
"""
Whoosh backend for haystack that implements character folding, as per
http://packages.python.org/Whoosh/stemming.html#character-folding .
Tested with Haystack 2.4.0 and Whooch 2.7.0
To use, put this file on your path and add it to your haystack settings, eg.
@skyl
skyl / kwacros.py
Created February 1, 2012 05:03
Django Template macros with args and kwargs
#
# templatetags/kwacros.py - Support for macros in Django templates
#
# Based on snippet by
# Author: Michal Ludvig <michal@logix.cz>
# http://www.logix.cz/michal
#
# modified for args and kwargs by Skylar Saveland http://skyl.org
#