Skip to content

Instantly share code, notes, and snippets.

// If you're looking at this, you probably know more about code than I do.
// I apologize for the messy code. I'm a journalist, not a developer. And this is an experiment, not a polished piece of software.
// If you'd like to make me aware of problems with the code, you can write me to hello@davidbauer.ch.
// countries missing in OWID dataset (dec 29): KIR, PRK, FSM, NRU, PLW, TON, TKM, TUV
var datafound = [];
var datamissing = [];
var matched = [];
@davidbauer
davidbauer / autoarchive-mails
Created September 30, 2018 14:07
Automatically archive emails in Gmail after x days
// how to use this
// 1. create a new script on https://script.google.com/home and paste over this code
// 2. define which emails you want to archive and after which delay (lines 7,8)
// 3. add a «project trigger» to define how often this script should be executed (e.g. every day at midnight)
function auto_archive_mails() {
var label = GmailApp.getUserLabelByName("News Briefings"); // Emails with which label do you want auto-archived?
var delayDays = 3 // After how many days do you want your emails auto-archived?
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays);
@davidbauer
davidbauer / gist:11055010
Created April 18, 2014 17:22
Python script to download images from a CSV of image urls
#!/usr/bin/env python
# assuming a csv file with a name in column 0 and the image url in column 1
import urllib
filename = "images"
# open file to read
with open("{0}.csv".format(filename), 'r') as csvfile:
@davidbauer
davidbauer / README.md
Created March 18, 2014 16:53
fussballer geburtstage über 20 mio

README is empty

@davidbauer
davidbauer / get authenticating user's name
Created February 3, 2013 13:17
get authenticating user's name for further usage
// test to get logged in user's name for further use
$.getJSON("http://tlinkstimeline.appspot.com/loggedinuser?callback=?", function(loggedinuser){
if (loggedinuser) {
var thename = loggedinuser;
console.log("hello " + thename);
};
});
@davidbauer
davidbauer / gist:3853898
Created October 8, 2012 17:53
Word counter V2
function countWords() {
var wordcount = 0;
var text = document.wordcounter.allthosewords.value;
var words = text.match(/\w+\W*/g);
if (words) {
wordcount = words.length;
}
}
function tellCount() {
@davidbauer
davidbauer / gist:3849557
Created October 7, 2012 20:52
Word counter
function countIt() {
var wordcount = 0;
var text = document.wordcounter.allthosewords.value;
for (i = 0; i < text.length; i++) {
if (text[i] === " ") {
wordcount++;
}
// special code needed for the smartasses that type in only one word
// special code needed for the smartasses that end their text with one or more spaces