Skip to content

Instantly share code, notes, and snippets.

View 0x46616c6b's full-sized avatar

0x46616c6b 0x46616c6b

  • Dresden
  • 19:59 (UTC +02:00)
View GitHub Profile
if request.method == 'GET':
# new callback functions
if 'format' in request.GET:
if request.GET['format'] == 'json':
json_serializer = serializers.get_serializer("json")()
if 'function' in request.GET:
if request.GET['function'] == 'get_all_entries':
allEntries = Entry.objects.all().order_by('-published')
return HttpResponse(json_serializer.serialize(allEntries, ensure_ascii=False))
elif request.GET['function'] == 'get_latest_entry':
def manage(request):
if request.method == 'POST':
if ('submit' in request.POST) and ('format' in request.POST):
if request.POST['format'] == 'json':
if 'new_entry' in request.POST:
# gives us a json: { "text" : "Dies ist eine Meldung", "isPublic" : 1 }
# entry_text =
# entry_isPublic =
# entry_published = datetime.now()
# -> save
@0x46616c6b
0x46616c6b / urls.py
Created January 13, 2011 21:56 — forked from enko/urls.py
def new_entry(request):
format = "json"
if ('format' in request.POST):
format = request.POST['format']
if ('submit' in request.POST):
# gives us a json: { "text" : "Dies ist eine Meldung", "isPublic" : 1 }
# entry_text =
# entry_isPublic =
# entry_published = datetime.now()
# -> save
@0x46616c6b
0x46616c6b / view.py
Created January 14, 2011 10:36
pragmatical layout of the manage view. for external application or other output formats (xml, ...) we should use an api.
@login_required(redirect_field_name='redirect')
def manage(request):
if (request.method == 'POST'):
format = 'json'
if ('format' in request.POST):
format = request.POST['format']
if ('submit' in request.POST) and (format == 'json'):
if ('new_entry' in request.POST):
# format: { "text" : "text body", "isPublic" : 0|1 }
function submitNewEntry() {
var text = $('.new-entry').val();
if (text == 'Neuen Eintrag schreiben...')
return false;
if ( $('.is-public:checkbox:checked').val() == 'on' )
var isPublic = parseInt(1);
else
var isPublic = parseInt(0);
import re
class BrowserDetectionMiddleware(object):
"""
Middleware to detect a wap, mobile html or full compatible browser
"""
def process_request(self, request):
browser_type = None
<?php
header('content-type: text/html; charset=utf-8');
$path = '';
require_once($path . '/app/Mage.php');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$websiteId = 1;
@0x46616c6b
0x46616c6b / checkdns.sh
Created February 15, 2011 17:08
Checks ServerNames from apaches vhost and checks the dns a record
#!/bin/sh
HOSTNAMES=`mktemp -p /tmp/`
grep -h "ServerName" /etc/apache2/sites-enabled/*|uniq|cut -d " " -f3 > $HOSTNAMES
dig -f $HOSTNAMES A +noall +answer
rm $HOSTNAMES
<?php
ini_set('default_charset', 'UTF-8');
$debug = 1;
$mode = NULL;
function fetchsite($url = NULL, $matrikel = NULL, $password = NULL) {
global $debug, $mode;
<?php
ini_set('default_charset', 'UTF-8');
$debug = 1;
$mode = NULL;
function fetchsite($url = NULL, $matrikel = NULL, $password = NULL) {
global $debug, $mode;