Skip to content

Instantly share code, notes, and snippets.

View PanosJee's full-sized avatar

Panos Papadopoulos PanosJee

View GitHub Profile
require 'rubygems'
require 'activesupport'
$KCODE = 'u'
class String
# Converts the Greek Unicode characters contained in the string
# to latin ones (aka greeklish) and returns self.
# For unobstructive conversion call the non-bang method 'greeklish'
#
# example:
development:
enable_star: 1
min_infix_len: 3
morphology: stem_en
html_strip: 1
charset_type: utf-8
charset_table: "0..9, a..z, _, A..Z->a..z, U+37a, U+386..U+389->U+3ac..U+3af, U+38c..U+38e->U+3cc..U+3ce, U+390,U+391..U+3a1->U+3b1..U+3c1, U+3a3..U+3ab->U+3c3..U+3cb, U+3ac..U+3ce,U+3d0..U+3d7, U+3d8..U+3ef/2, U+3f0..U+3f3, U+3f4->U+3b8, U+3f5, U+3f7..U+3f8/2, U+3f9->U+3f2, U+3fa..U+3fb/2, U+3fc..U+3ff"
bin_path: '/usr/local/bin'
sql_sock: '/tmp/mysql.sock'
test:
From 1ca98a37b38a07387fc4344ce9df8db0a2885057 Mon Sep 17 00:00:00 2001
From: Panagiotis Papadopoulos <[email protected]>
Date: Tue, 29 Jun 2010 19:50:20 +0300
Subject: [PATCH] Added support for multiple query parameters with the same name
---
oauth/oauth.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/oauth/oauth.py b/oauth/oauth.py
def connect_to_gmail(CREDENTIALS, email, oauth_token, oauth_token_secret):
"""
Call this function to get an authenticated IMAP connection
"""
consumer = OAuthEntity(CREDENTIALS[0], CREDENTIALS[1])
access_token = OAuthEntity(oauth_token, oauth_token_secret)
xoauth_string = GenerateXOauthString(
consumer, access_token, email, 'imap',
None, str(random.randrange(2**64 - 1)), str(int(time.time())))
def _process_body(pl):
"""find the final payload (body) of an email"""
if type(pl)==StringType:
return pl.replace('\r\n>',' ').replace('\r\n',' ').replace('\n\n',' ')
elif type(pl)==list:
return _process_body(pl[0])
elif type(pl)==InstanceType:
return _process_body(pl._payload)
else:
print type(pl)
from google.appengine.api import xmpp
import logging
import logging.handlers
import os
DEFAULT_FROM_JID = 'logs@%s.appspotchat.com' % os.environ['APPLICATION_ID']
class XmppLogHandler(logging.Handler):
def __init__(self, jid, from_jid):
@PanosJee
PanosJee / refinery_omniauth.rb
Created March 17, 2011 22:58
Login / Register to Refinery with Omniauth (facebook, twitter, openid, etc)
# Create a role user (no perms). Fire up the console rails c
$> Role.create(:title=>'User')
# In your Gemfile add
gem 'oa-oauth', :require => 'omniauth/oauth'
# At the beginning of devise.rb. You can also create a yaml file and instantiate when Rails begin
# For shake of simplicity I added the credentials at devise.rb
Facebook = Rails.env.development? ? {:app_id => 2621xxx, :secret => 'e81f33d042xxxxx'} :
{:app_id => 1749xxx9, :secret => '13c11be6628dc1xxxx'}
@PanosJee
PanosJee / en.rb
Created April 17, 2011 10:16 — forked from jimeh/en.rb
# encoding: utf-8
class FuzzyClock
@@locales ||= {}
@@locales[:en] = {
:about => "Είναι σχεδόν %t",
:hour => {
0 => "δώδεκα",
1 => "μία",
2 => "δύο",
@PanosJee
PanosJee / exceptionwrapper.js
Created June 7, 2011 22:06 — forked from esamattis/exceptionwrapper.js
Try to desperately to capture exceptions and log them to the console.
// http://stackoverflow.com/questions/5931033/how-can-i-know-if-a-javascript-exception-occurred-in-a-phonegap-application-and
(function(){
window.onexception = function(e) {
console.log("Got an exception ", e, e.stack);
};
@PanosJee
PanosJee / underscore.examples.js
Created July 7, 2011 15:33
Some nice examples of Underscore.js
// Collecting all unique affected app version for a given data set
var jsonStats = [
{app_versions: ['1.2','1.2.3']},
{app_versions: null},
{app_versions: ['1.2','1.3']}
];
var app_versions = _.uniq(_.flatten(_.compact(_.map(jsonStats, function(day){return day.app_versions }))));
// ["1.2", "1.2.3", "1.3"]
// Bye bye stupid for loops!