Skip to content

Instantly share code, notes, and snippets.

💻
Work work

Wojtek Siudzinski suda

💻
Work work
Block or report user

Report or block suda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@suda
suda / nginx_memcache_set_simplehttpserver.py
Created Nov 16, 2010
[Python] Simple backend for nginx memcached module
View nginx_memcache_set_simplehttpserver.py
"""
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 / gunicorn
Created Dec 20, 2010
Gunicorn init.d script (gentoo)
View gunicorn
#!/sbin/runscript
# Gunicorn init.d script for gentoo
# Written by Wojtek 'suda' Siudzinski <admin@suda.pl>
# Gist: https://gist.github.com/748335
#
# Sample config (/etc/conf.d/gunicorn):
#
# SERVERS=(
# 'server_name port project_path number_of_workers'
@suda
suda / gunicorn
Created Dec 20, 2010
Gunicorn init.d script (debian/ubuntu)
View gunicorn
#!/bin/sh
### BEGIN INIT INFO
# Provides: gunicorn
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the gunicorn server
# Description: starts gunicorn using start-stop-daemon
@suda
suda / googl.py
Created Feb 4, 2011
[Python/Django] Goo.gl URL shortener (using official API)
View googl.py
"""
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 Nov 12, 2011 — forked from blackrobot/settings.py
Sample Django settings
View settings.py
"""
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 Dec 2, 2011
Simple Django view that returns list of user (identified by username and password POST parameters) basecamps from 37 Signals Launchpad
View views.py
# -*- 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 Mar 14, 2012
Issue Stand Authorization
View gist:2037819

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 Dec 6, 2012
Check how much space Retina files (@2x) use up on your Mac's HDD
View retina.sh
#!/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)}'
@suda
suda / multipleRows.mm
Last active Jun 14, 2019
Multiple Row Selection in UIPickerView
View multipleRows.mm
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UITableViewCell *cell = (UITableViewCell *)view;
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
[cell setBackgroundColor:[UIColor clearColor]];
[cell setBounds:CGRectMake(0, 0, cell.frame.size.width - 20, 44)];
cell.tab = row UITapGestureRecognizer * singleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleSelection:)];
singleTapGestureRecognizer.numberOfTapsRequired = 1;
[cell addGestureRecognizer:singleTapGestureRecognizer];
}
View bootstrap_chef.sh
#!/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)
You can’t perform that action at this time.