Skip to content

Instantly share code, notes, and snippets.

View emre's full-sized avatar
🎯
Focusing

Emre Yılmaz emre

🎯
Focusing
View GitHub Profile
@emre
emre / thumbnail.py
Created March 9, 2010 10:22
thumbnailer class for python
from PIL import Image
class ThumbNail(object):
"""
init function for base Class
Parameters
------------
targetFile:
@emre
emre / django stats
Created March 12, 2010 17:29
code stats for a simple django project
# mirat'in kodu
# <proje>/scripts/stats.py
import glob
import os
SCAN_FOLDER = "../"
stats = {
"python" : 0,
@emre
emre / sort
Created April 27, 2010 15:08
usort()'un guzel bir ozelligi
<?php
$a[] = array(
"name" => "emre",
"price" => 99,
);
$a[] = array(
"name" => "ali",
"price" => 15,
@emre
emre / django svn installer script
Created June 26, 2010 11:17
Django icin SVN installer scripti
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from distutils.sysconfig import get_python_lib
class Installer(object):
def __init__(self):
self.__controlUser()
@emre
emre / thumbnail_tools
Created July 10, 2010 15:40
python thumbnailler icin isimlendirme isleri
class ThumbnailTools(object):
@staticmethod
def get_thumb_info(file):
reply = re.search("(.*?)\.([a-zA-Z]{3,4})$", file)
return (reply.group(1), reply.group(2))
@staticmethod
def get_thumb_name(file, thumb_type):
file_info = ThumbnailTools.get_thumb_info(file)
@emre
emre / facebook_api_session_validator.py
Created July 26, 2010 09:33
facebook'tan GET olarak donen JSON bilgisinin dogrulugunu kontrol eder.
# -*- coding: utf8 -*-
import hashlib
class FacebookApiSessionValidatorException(Exception):
pass
class FacebookApiSessionValidator(object):
def __init__(self, application_secret, session):
@emre
emre / solr_document_remover.py
Created July 29, 2010 09:52
solr'dan tum kayitlari siler.
import solr
# create a connection to a solr server
s = solr.SolrConnection('http://foo/bar/:8180/solr')
# get all documents
response = s.query('*:*')
for hit in response.results:
s.delete(hit['id'])
s.commit()
@emre
emre / google maps adres arama
Created July 31, 2010 09:57
google maps'te arama icin ufak bir python wrapper
# -*- coding: utf8 -*-
import urllib, simplejson
class GoogleMapsWrapper(object):
def __init__(self, apiKey):
self.api_key = apiKey
def search(self, address):
"""
@emre
emre / proxy.php
Created August 16, 2010 12:32 — forked from hmert/proxy.php
just experimantal
<?php
class ProxyRouterException extends Exception {}
class ProxyRouter {
public $url;
public function __construct($url) {
$this->url = $this->_control_url($url);
@emre
emre / media_url_fix.py
Created August 17, 2010 12:57
HTTPS ustunden bir istek yapildigin media url prefix'ini de https yapar.
# [your-project/context_processors.py]
from django.conf import settings
def ssl_fix(request):
media_url = getattr(settings, 'MEDIA_URL')
if request.is_secure() == True:
media_url = media_url.replace("http://", "https://")
return {
"MEDIA_URL": media_url,