Skip to content

Instantly share code, notes, and snippets.

@voscausa
voscausa / App.svelte
Last active September 27, 2019 23:23
Batch upload a CSV file in a Firestore collection
<script>
// other imports
import Upload from "./upload/Upload.svelte";
// auth stuff
export let uid;
// use a dynamic component to be able to stop the component
let upload_component = Upload;
// we restart the component after the upload to clear the filename of the <input type="file" ..../>
@voscausa
voscausa / _ Euro.svelte
Last active August 8, 2020 20:33
Euro currency formatting in Svelte 3 using various options
<script>
import { toEur, setFormat } from './use_format.js';
let num = -5;
setFormat('currency', {style: 'currency', zero:false});
function handleClick() {
num <= 0 ? num +=1 : num-=4;
}
@voscausa
voscausa / Row.svelte
Last active September 25, 2019 20:05
Search a text in a table column in Svelte 3 and mark te results
<script>
export let row;
export let search = '';
let result = row.text;
let found = false;
function searchNow(s) {
let re = new RegExp(s, 'gi');
result = row.text.replace(re, `<mark>${s}</mark>`);
@voscausa
voscausa / GAE sdk service accounts.md
Created February 7, 2016 14:40
Using service accounts in the appengine development server / SDK

Using service accounts in the appengine development server / SDK

Service accounts make it very easy to authorize appengine requests to other Google APIs and services.

To use a service account in the appengine SDK, you have to add two undocumented options when you run the development server:

  1. --appidentity_email_address=<SERVICE_ACCOUNT_EMAIL_ADDRESS>
  2. --appidentity_private_key_path=<PEM_KEY_PATH>

More info in this request for documentation issue

@voscausa
voscausa / App engine cloudstorage update.md
Last active October 15, 2021 14:07
Use GCS (Google cloudstoarge) to replace the app engine blobstore. You can use the Blobstore service to access GCS.

App Engine update blob

Writing to the blostore using the Files API is deprecated. But we can upload a blob to update the blob

This way we do not need GCS (Google Cloud Storage) To use GCS you have to pay for the application

UPDATE: GCS, using a default bucket is now FREE (1.9.0)

@voscausa
voscausa / Jinja module loader.md
Last active August 10, 2020 14:37
Jinja2 compiled templates module loader for App Engine Pyhton 2.7.

Jinja compiled templates module loader

This code is part of a Jinja CMS for Google App Engine Python 2.7 and NDB datastore

A Jinja enviroment is created for every CMS site: site_key_id = 'example

The modules are created using compiler.py The resulting code objects are stored in the dadastore using Kind Runtimes and a BlobProperty

The modules can also be saved / downloaded as .pyc in a zip archive: -compiled-templates.zip

@voscausa
voscausa / gist:1397784
Created November 27, 2011 16:39
Google App engine Python 2.5 version of pankratiev / python-amazon-ses-api, using method override
#!/usr/bin/python
# -*- coding: utf-8 -*-
from ek_settings import AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY
from amazon_ses import AmazonSES, EmailMessage
from google.appengine.api import urlfetch
from google.appengine.runtime import DeadlineExceededError
import urllib, logging
#===============================================================================================================================