Skip to content

Instantly share code, notes, and snippets.

//labels: change the names accordingly to your needs.
//those labels have to be in the gmail.
var l_morning = GmailApp.getUserLabelByName("Delay/Morning");
var l_midday = GmailApp.getUserLabelByName("Delay/Midday");
var l_tonight = GmailApp.getUserLabelByName("Delay/Tonight");
var l_tomorrow = GmailApp.getUserLabelByName("Delay/Tomorrow");
var l_nextweek = GmailApp.getUserLabelByName("Delay/Nextweek");
var me = "YOUR EMAIL GOES HERE";
//array of all the labels: DO IT
@esseti
esseti / BetterGmail
Created October 10, 2013 11:34
BetterGmail experience
//This function archives all the read mail that are not in the inbox
function markArchivedAsRead() {
//i add "has:nouserlabels" beacuse i have filter that skip the emails form the inbox and place them in lables. for that case i want to keep the emails as unread.
var threads = GmailApp.search('label:unread has:nouserlabels -label:inbox');
GmailApp.markThreadsRead(threads);
};
//this funciton cleans the inbox
function cleanInbox() {
// for all the inbox mail that are not starred and are read, it archives them
@esseti
esseti / JoinObjects.py
Last active December 19, 2015 07:39
Function that i created to manage some data.
def joinObjects(objects, field):
'''
takes a list of objects and merge them.
objects are dicts
if objects have same keys, values are joined into a list.
[{'id':1,'tag':'ciao1'},
{'id':2,'tag':['ciao1',ciao3]},
{'id':1,'smt':'else2'},
{'id':2,'tag':'ciao2'}]
becomes
@esseti
esseti / models.py
Last active December 13, 2015 22:48
Pipe for django-social-auth for having a user profile populated with facebook data
class Language(models.Model):
name = models.CharField(max_length=100, default='')
fb_id = models.CharField(max_length=100, default='0')
def __unicode__(self):
return str(self.fb_id)
class UserProfile(models.Model):
user = models.OneToOneField(User)
name = models.CharField(max_length=100, default='')
@esseti
esseti / curl-trick
Created January 31, 2013 14:56
Avoid "The document has moved" in GDocs requests from curl (and similar)
curl -L -d headers YOUR_URL
@esseti
esseti / setting.py
Created January 29, 2013 12:07
This is an example of how to write your setting.py (Django) for running the app on AppFog and localhost without the need of changing settings every time. Plus at the bottom i added a trick on how to init the db, since AppFog does not let to do that (you have to use the tunnelling)
# Django settings for DjangoProjects project.
import os
#if this value exsist you are on appfog.
if 'VCAP_SERVICES' in os.environ:
DEBUG = False
#othewhise it's localhost
else:
DEBUG = True