Skip to content

Instantly share code, notes, and snippets.

@telenieko
telenieko / main.dart
Last active March 15, 2022 13:56
Difference between `Uri.path` and `Uri.toFilePath()` on Windows
// Example for <https://github.com/dart-lang/markdown/pull/396>
void main() {
final fileUriUnix =
Uri.file(r'/home/myself/images/image.png', windows: false);
print(fileUriUnix.path); // /home/myself/images/image.png
print(fileUriUnix.toFilePath()); // /home/myself/images/image.png
final fileUriWindows =
@telenieko
telenieko / GoogleCloudFileStorage.java
Created January 18, 2019 08:05
Sample of a CUBA Storage for Google Cloud Storage - very similar to the supplied AWS S3 one
package com.sample;
import com.google.cloud.storage.*;
import com.haulmont.bali.util.Preconditions;
import com.haulmont.cuba.core.app.FileStorageAPI;
import com.haulmont.cuba.core.entity.FileDescriptor;
import com.haulmont.cuba.core.global.Configuration;
import com.haulmont.cuba.core.global.FileStorageException;
import com.metanube.metai4.google.service.GoogleConfig;
import org.apache.commons.lang3.StringUtils;
@telenieko
telenieko / a_enable_wireless.sh
Created March 5, 2018 16:57
Sample files to enable wireless on Debian initramfs
#!/bin/sh
# this goes into /etc/initramfs-tools/scripts/init-premount/a_enable_wireless
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
@telenieko
telenieko / do_migrations.py
Created October 16, 2017 17:27
Quick hack to run django manage.py migrate on your production app engine without direct access to database
""" do_migrations.py run django manage.py migrate on your production app engine without direct access to database
License: This code is release to the Public Domain under "CC0 1.0 Universal" License
Author: Marc Fargas <telenieko@telenieko.com>
Date: 16th October 2017
This simple wsgi app allows you to call "manage.py migrate"
(or any other command if you wish) thus you do not need to
setup direct access to the database from your local machine.
@telenieko
telenieko / gdrive_cleanup.py
Created September 29, 2017 22:55
Script to do maintenance on Google Drive, example of gevent, google drive sdk, rate limiting, automatic retries, ...
# -*- coding: utf-8 -*-
# pylint: disable=missing-docstring,wrong-import-position,invalid-name,len-as-condition
# pylint: disable=superfluous-parens,wrong-import-order,ungrouped-imports,unsubscriptable-object
""" gdrive_cleanup.py <user@domain.com> [start folder_id]
License: This code is release to the Public Domain under "CC0 1.0 Universal" License
Author: Marc Fargas <telenieko@telenieko.com>
This script is one we use to do some maintenance on user's Google Drive folders.
Things it does:
@telenieko
telenieko / google_drive_fix_migration.py
Last active September 26, 2017 07:22
Script to merge two similar Google Drive directory structures
# -*- coding: utf-8 -*-
# pylint: disable=missing-docstring,wrong-import-position,invalid-name,superfluous-parens
""" google_drive_fix_migration.py <user@domain.com>
License: This code is release to the Public Domain under "CC0 1.0 Universal" License
Author: Marc Fargas <telenieko@telenieko.com>
Background:
Our office did a real-life testdrive of Office 365 after 11 years on Google Apps,
after 3 months we decided to rollback the affected users which went smoothly
@telenieko
telenieko / a3sol.py
Created February 9, 2015 22:18
Ejemplo de conversión A3 > ContaSOL usando importasol.
""" Importar un libro diario de A3 a ContaSOL.
A3 permite listar el libro Diario en Excel, lo que permite su conversion
e importacion en otros programas como ContaSOL.
El libro generado es un Excel formato "antiguo" con una hoja por cada mes
del ejercicio.
A parte de importasol, hay que tener los paquetes: click, xlrd, Bunch
"""