Skip to content

Instantly share code, notes, and snippets.

@jenikm
jenikm / vba_russian_transliterate.vb
Created June 29, 2012 19:44
VBA Russian transliterate function
'http://www.utf8-chartable.de/unicode-utf8-table.pl?start=1024&utf8=-&unicodeinhtml=dec
'use numerical HTML column
Function Transliterate(Russian As String)
letters = Array("A", "B", "V", "G", "D", "E", "YO", "ZH", "Z", "I", "Y", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "F", "H", "TZ", "CH", "SH", "SCH", "", "Y", "", "E", "YU", "YA", "a", "b", "v", "g", "d", "e", "yo", "zh", "z", "i", "y", "k", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "h", "tz", "ch", "sh", "sch", "", "y", "", "e", "yu", "ya", "#")
i = 1040
For Each letter In letters
Dim val As String
Select Case letter
Case "YO"
val = ChrW(1025)
@shazow
shazow / meta.py
Created March 6, 2013 23:20
My latest SQLAlchemy model base class.
"""SQLAlchemy Metadata and Session object"""
import datetime
import json
import time
from sqlalchemy import MetaData
from sqlalchemy.orm import scoped_session, sessionmaker
__all__ = ['Session', 'metadata', 'Model', 'SchemaEncoder']
@dlo
dlo / export_foursquare_checkins.py
Last active February 27, 2020 12:27
Download all your Foursquare checkins with Python.
# pip install requests
import requests
import json
url_template = 'https://api.foursquare.com/v2/users/self/checkins?limit=250&oauth_token={}&v=20131026&offset={}'
# If you navigate to https://developer.foursquare.com/docs/explore, Foursquare
# will generate an OAuth token for you automatically. Cut and paste that token
# below.
token = ""
@arusahni
arusahni / nocache.py
Last active December 28, 2022 13:12
Flask nocache decorator
from flask import make_response
from functools import wraps, update_wrapper
from datetime import datetime
def nocache(view):
@wraps(view)
def no_cache(*args, **kwargs):
response = make_response(view(*args, **kwargs))
response.headers['Last-Modified'] = datetime.now()
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
@letmaik
letmaik / models_committed.py
Created May 22, 2014 14:54
delete, insert, update events after a commit for SQLAlchemy
from sqlalchemy import create_engine, event, orm
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.session import Session as SessionBase, object_session
from sqlalchemy.event.api import listen
# The following adds delete, insert, and update events after successful commits.
# SQLAlchemy provides only events after flushes, but not after commits.
# The classes are adapted from Flask-SQLAlchemy.
# see also https://stackoverflow.com/a/12026787/60982
@timmyreilly
timmyreilly / ConnectingToAzureSQLFromPython
Created October 13, 2017 23:02
Using Flask_SQLAlchemy to connect to Azure SQL
#!/usr/bin/env python
import os
import urllib.parse
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
# Configure Database URI:
params = urllib.parse.quote_plus("DRIVER={SQL Server};SERVER=sqlhost.database.windows.net;DATABASE=pythonSQL;UID=username@sqldb;PWD=password56789")
@lly365
lly365 / pg_uuid.py
Created February 7, 2018 09:37
Flask-SQLAlchemy UUID
# -*- coding: utf-8 -*-
"""
pg_uuid
~~~~~~~~~~~~~~~~
<NO DESCRIPTION>.
:copyright: (c) 2018 by WRDLL <4ever@wrdll.com>
"""
from flask import Flask