Skip to content

Instantly share code, notes, and snippets.

@denilsonsa
denilsonsa / timezone_and_django.py
Last active August 29, 2015 14:03 — forked from anonymous/dpaste.de_snippet.py
datetime object, when rendered to Django template, was always 6 minutes off.
class LocalDateTimeField(with_metaclass(models.SubfieldBase, models.DateTimeField)):
'''A hack/workaround version of DateTimeField that considers the datetime
from the database as local time.
'''
def to_python(self, value):
from django.utils.dateformat import format
value = models.DateTimeField.to_python(self, value)
if isinstance(value, datetime):
print('-' + repr(value))
print(strftime('%Y-%m-%d %H:%M:%S.%f', value.timetuple()))
@denilsonsa
denilsonsa / careers-2.0-stackoverflow.svg
Created February 5, 2014 21:18
Careers 2.0 (by Stack Overflow) logo in SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@denilsonsa
denilsonsa / url_to_drive.js
Last active December 18, 2022 18:32
Google Apps Script to upload a file from an URL directly to Google Drive.
// url_to_drive.gs
// Google Apps Script
// Allows uploading a URL directly to Google Drive.
//
// Live link:
// https://script.google.com/macros/s/AKfycbzvhbHS4hnWPVBDHjQzZHA0qWq0GR-6hY7TbYsNto6hZ0MeAFZt/exec
//
// Source-code:
// https://gist.github.com/denilsonsa/8134679
// https://script.google.com/d/1Ye-OEn1bDPcmeKSe4gb0YSK83RPMc4sZJt79SRt-GRY653gm2qVUptoE/edit
@denilsonsa
denilsonsa / digit9brazil.js
Last active August 26, 2024 13:33
Google Apps Script to find mobile phone numbers meeting certain criteria (look inside "updateNumber()" and "fixNumbersFromGoogleContacts()" for details) and add a ninth digit to them. Scans all phone numbers in your Google Contacts, using official Google APIs. Also includes a simple and ugly UI for the most basic usage.
// digit9brazil.gs
// Google Apps Script
//
// Objective:
// Find mobile phone numbers meeting certain criteria (look inside "updateNumber()" and
// "fixNumbersFromGoogleContacts()" for details) and add a ninth digit to them.
//
// Live link:
// https://script.google.com/macros/s/AKfycbzWlGLgZmA0lygkwMLp3p6RrRFIbBfVdKGXaUAcJCJo59R492E/exec
//
@denilsonsa
denilsonsa / cell-color-based-on-value.js
Last active December 26, 2015 10:49
Sets the cell background color to red-yellow-green based on its value. Used on this Google Spreadsheet: https://docs.google.com/spreadsheet/ccc?key=0AvfBqhRA8IzYdEJfNl83R2w0OGRVZUNFaWxlRFlEVGc
// cell-color-based-on-value.gs
//
// For more information on using the Spreadsheet API, see
// https://developers.google.com/apps-script/service_spreadsheet
// Returns a linear interpolation of y1,y2 based on x value between x1,x2.
function linearInterp(x, x1, x2, y1, y2) {
if (x <= x1) return y1;
if (x >= x2) return y2;
return y1 + (y2 - y1) * (x - x1) / (x2 - x1);
@denilsonsa
denilsonsa / pppt-BR1.txt
Last active November 22, 2016 19:50
This file should be placed at `/sdcard/svox/classic/pt-bR/pppt-BR1.txt` on your Android device. It contains many Portuguese pronunciation corrections for use with [SVOX Br. Portug. Luciana Voice][1]. This file should use unix-style newlines (the default style for Linux and Mac OS X editors), and should be encoded in UTF-8. This file is also avai…
NETWORK USER_EXTENSION_NETWORK
NETWORKCOST = -10001
PRODUCTIONS
USER_STRINGS =
L<'Apple',ci> Out<'épou'>
| L<'aquele',ci> Out<'aquêle'>
| L<'back',ci> Out<'bék'>
| L<'backspace',ci> Out<'békspeice'>
| L<'Bluetooth',ci> Out<'Blutuf'>
| L<'byte',ci> Out<'baite'>
@denilsonsa
denilsonsa / watch_site.py
Last active May 23, 2023 22:01
watch_site.py - Easily watch a site for changes...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4 sw=4 et
####################################################################################
# The most up-to-date version is available at: #
# https://github.com/denilsonsa/small_scripts/blob/master/watch_website_tkinter.py #
# #
# The code in this Gist is old and obsolete. #
####################################################################################