Skip to content

Instantly share code, notes, and snippets.

View Ciantic's full-sized avatar

Jari Pennanen Ciantic

View GitHub Profile
@Ciantic
Ciantic / multisettings.py
Created January 29, 2011 17:31
Django settings.py that can handle
"""Multisite - individual site for request"""
from django.conf import settings
from threading import local
def make_tls_property(default=None):
"""Creates a class-wide instance property with a thread-specific value."""
class TLSProperty(object):
def __init__(self):
self.local = local()
@Ciantic
Ciantic / forbiddenmixintests.py
Created February 2, 2011 21:44
ForbiddenMixin can't be Mixin for security's sake
from django.conf.urls.defaults import * #@UnusedWildImport
from django.contrib.auth.models import Permission, User
from django.http import HttpResponse
from django.test import TestCase
from django.test.client import Client
from django.views.generic.base import View
class ForbiddenMixin(object):
"""ForbiddenMixin"""
@Ciantic
Ciantic / forbiddenviewtests.py
Created February 3, 2011 08:31
First working test.
# REPLACE urls parameter of the TestCase and create test.html in order to test
# this
from django.conf.urls.defaults import * #@UnusedWildImport
from django.contrib.auth.models import Permission, User
from django.http import HttpResponse
from django.test import TestCase
from django.test.client import Client
from django.views.generic.base import View, TemplateView
@Ciantic
Ciantic / load.php
Created June 10, 2011 16:03
Non quoted api for WP: load.php (patch)
<?PHP
$WP_NONQUOTED_POST = array();
/**
* Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
*
* Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
* or $_ENV are needed, use those superglobals directly.
*
@Ciantic
Ciantic / parseuri_absuri.js
Created September 30, 2011 15:08 — forked from Yaffle/URLUtils.js
Parse URI and Convert Relative URI to Absolute
var parseURIMatcher = /^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/;
/**
* Parses the URI
*
* @param url
* @returns object
*/
function parseURI(url) {
var m = parseURIMatcher.exec(url);
@Ciantic
Ciantic / default_sorting.php
Created December 5, 2011 18:21
default sorting order of all list views in admin
<?PHP
function post_order_type_default_sorting(&$query) {
if (!isset($query->query['orderby'])) {
$query->set('orderby', 'menu_order');
}
}
function post_order_type_list_view() {
add_action('pre_get_posts', 'post_order_type_default_sorting', 1, 1);
@Ciantic
Ciantic / filter.php
Created December 9, 2011 12:29
Filter in admin list
<?PHP
abstract class My_AdminList {
public static $taxonomies = array("menu_category");
public static $post_types = array("owns_restaurant_item");
/**
* Admin init hook
*/
@Ciantic
Ciantic / listboks.html
Created September 24, 2012 07:09
Testi
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Select test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
function Hae(kohde_id, porras_id, kerros_id, fill_name) {
$.getJSON("hae_data2.php",{kohde_id: kohde_id, porras_id: porras_id, kerros_id: kerros_id}, function(j){
console.log(j);
@Ciantic
Ciantic / custom.css
Created October 10, 2012 19:17
Web.Tweetdeck.com hack: smaller and inline avatars
/*
Edit User StyleSheet of Chrome:
Windows:
C:\Users\YOURUSERNAME\AppData\Local\Google\Chrome\User Data\Default\User StyleSheets\Custom.css
Create the file if it does not exist. Similar file is in Firefox too.
*/
@Ciantic
Ciantic / jquery.query.js
Created November 26, 2012 12:46 — forked from bdimcheff/jquery.query.js
jquery-query
/**
* http://plugins.jquery.com/project/query-object
* jQuery.query - Query String Modification and Creation for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/8/13
*
* @author Blair Mitchelmore
* @version 2.1.8 (fork)
*