Skip to content

Instantly share code, notes, and snippets.

Michael Szul szul

Block or report user

Report or block szul

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View flask_script_name.md

Serving Flask under a subpath

Your Flask app object implements the __call__ method, which means it can be called like a regular function. When your WSGI container receives a HTTP request it calls your app with the environ dict and the start_response callable. WSGI is specified in PEP 0333. The two relevant environ variables are:

SCRIPT_NAME
The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server.

View howto_python_flask_iis_wfastcgi
Assume IIS is installed. My machine already had IIs 8.5.
Install Python
==============
1. Download web installer (Python 3.6.3).
2. Run as Administrator.
3. Select custom installation for all users.
4. Choose install directory such that there are no white spaces in the path. Not sure if it needs to be done. Just being cautious.
5. Check the box for "Add Python 3.6 to PATH".
@szul
szul / card.ts
Last active Jan 29, 2019
HTML card cloning and text replacement
View card.ts
async function createCard(selector: string, url: string, callback?: Function): Promise<void> {
try {
const response = await fetch(url, { mode: "cors" });
const items = await response.json() as any;
const t = document.querySelector(`#${selector}`);
for(let i = 0; i < items.length; i++) {
const t2 = t.cloneNode(true) as HTMLTemplateElement;
for(let k in items[i]) {
if(items[i].hasOwnProperty(k)) {
const elem: HTMLSpanElement = t2.querySelector(`span[data-m-for='${selector}'][name='${k}']`);
@szul
szul / task.json
Created Sep 25, 2018
Task items for MSBuild, TypeScript, and Firefox debugging, including a task to launch all others
View task.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run",
"dependsOn": [
"MSBuild",
"TypeScript",
@szul
szul / launch.json
Created Sep 25, 2018
Visual Studio Code launch file for Firefox debugging of TypeScript files running under IIS Express locally, as well as ASP.NET MVC .NET Framework debugging under IIS Express
View launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Firefox Debugger",
"type": "firefox",
"request": "attach",
View chatdown.json
{
"version": "2.0.0",
"tasks": [
{
"label": "chatdown",
"type": "shell",
"command": "Get-ChildItem **/*.chat | ForEach-Object { chatdown \"$(Split-Path $_.FullName)/$($_.Name )\" > \"$(Split-Path $_.FullName)/$($_.BaseName).transcript\" }",
"problemMatcher": []
}
]
View g-sample-transcript-2
[
{
"conversation": {
"id": "1"
},
"id": "06aa9cce-7b96-446d-b309-81a0b4c298da",
"recipient": {
"id": "4df8602a-ed75-3b9f-b88f-cd9734ef89c7",
"name": "cafebot",
"role": "bot"
View g-sample-transcript
[
{
"conversation": {
"id": "1"
},
"id": "0a4bbe34-da22-4311-967d-c6ded43e6463",
"recipient": {
"id": "d8c72001-9af1-36d5-8b27-531e849bcc45",
"name": "Angel",
"role": "user"
View hyperstart.bat
@ECHO off
:top
CLS
ECHO Choose a shell:
ECHO [1] cmd
ECHO [2] bash
ECHO [3] PowerShell
ECHO [4] PowerShell Core
ECHO [5] Python
ECHO.
@szul
szul / EventCalendar.cs
Created Feb 20, 2018
Code snippet for ICS attachment creation
View EventCalendar.cs
public sealed class EventCalendar
{
private string _ics;
public EventCalendar()
{
}
public EventCalendar(string summary, string description, System.DateTime start, System.DateTime end, string location)
{
StringBuilder sb;
You can’t perform that action at this time.