Skip to content

Instantly share code, notes, and snippets.

View suda's full-sized avatar
🍃

Wojtek Siudzinski suda

🍃
View GitHub Profile
@suda
suda / nginx_memcache_set_simplehttpserver.py
Created November 16, 2010 15:08
[Python] Simple backend for nginx memcached module
"""
Simple backend for nginx memcached module
Written by Wojtek 'suda' Siudzinski <admin@suda.pl>
Gist: https://gist.github.com/701904
Nginx config:
location /static {
add_header X-Origin Memcached;
expires modified +48h;
@suda
suda / googl.py
Created February 4, 2011 12:17
[Python/Django] Goo.gl URL shortener (using official API)
"""
Add GOOGL_KEY to your settings.py
"""
import urllib2, simplejson
from django.conf import settings
def googl(url):
params = simplejson.dumps({'longUrl': url})
headers = { 'Content-Type' : 'application/json' }
req = urllib2.Request('https://www.googleapis.com/urlshortener/v1/url?key='+settings.GOOGL_KEY, params, headers)
@suda
suda / settings.py
Created November 12, 2011 13:22 — forked from blackrobot/settings.py
Sample Django settings
"""
Here's my sample Django settings for a project I recently did. Visit http://damonjablons.wordpress.com to see the explanation.
Updated to Django 1.3 by Wojtek 'suda' Siudzinski
"""
import os
import socket
# Set DEBUG = True if on the production server
@suda
suda / views.py
Created December 2, 2011 13:45
Simple Django view that returns list of user (identified by username and password POST parameters) basecamps from 37 Signals Launchpad
# -*- encoding: utf-8 -*-
from lxml import etree
from BeautifulSoup import BeautifulSoup
import simplejson
import urllib, urllib2
import cookielib
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
@suda
suda / gist:2037819
Created March 14, 2012 16:51
Issue Stand Authorization

User authorization in Issue Stand magazines is done by sending username and password to a dedicated page on publisher's server (preferably HTTPS) and checking the result.

###POST Parameters Parameters are sent just like any HTML form.

  • username - username entered by the user
  • password - password entered by the user

###Server response Response is encoded in JSON format

@suda
suda / retina.sh
Created December 6, 2012 03:15
Check how much space Retina files (@2x) use up on your Mac's HDD
#!/bin/bash
find /Applications/ -name "*@2x*" -exec ls -l {} \; | awk '{ total += $5 } END { total = total / 1024 / 1024; printf(" TOTAL SIZE OF RETINA FILES (MB): %4.2f\n", total)}'
#!/bin/bash
# Modified install.sh file from http://www.opinionatedprogrammer.com/2011/06/chef-solo-tutorial-managing-a-single-server-with-chef/
# This runs as root on the server
chef_binary=/usr/local/bin/chef-solo
# Are we on a vanilla system?
if ! test -f "$chef_binary"; then
export DEBIAN_FRONTEND=noninteractive
# Upgrade headlessly (this is only safe-ish on vanilla systems)
@suda
suda / bytesex.h
Created October 3, 2013 14:47
bytesex.h with AMD64 and x86_64 architectures
/* Original code from the Linux C library */
/* Copyright (C) 2000,2001 Salvatore Sanfilippo <antirez@invece.org>
* This code is under the original GNU C library license (GPL) */
/* $Id: bytesex.h,v 1.1.1.1 2003/08/31 17:23:48 antirez Exp $ */
#ifndef ARS_BYTESEX_H
#define ARS_BYTESEX_H
#if defined(__i386__) \
/**
* Module allowing to use Azure Mobile Services database on server side
* in a synchronous manner.
*
* Singleton based on http://simplapi.wordpress.com/2012/05/14/node-js-singleton-structure/
*
* @example
* var synchronizer = require('query-synchronizer');
* synchronizer.read(table, function(results) {
* // Do something with the results
"""
Simple Gist for debugging Django requests using RequestBin (http://requestb.in/)
Usage:
from request_bin import request_bin
def index_view(request):
request_bin('http://requestb.in/1fpixiy1', request)