Skip to content

Instantly share code, notes, and snippets.

Avatar
🌏
Our (only!) planet is on fire. How can we help? Help!

Matias Forbord codeluggage

🌏
Our (only!) planet is on fire. How can we help? Help!
View GitHub Profile
@codeluggage
codeluggage / r.dendron.macros.md
Last active May 2, 2022
How to use shortcuts to work with markdown checkboxes for Dendron
View r.dendron.macros.md

To quickly work with checkboxes in Dendron, you can use these settings and shortcuts.

Setup

  1. Install the most up to date macros extension: https://github.com/ctf0/macros
  2. Install the Vim extension: https://github.com/VSCodeVim/Vim
  3. Add the keybindings below to your keybindings.json
  4. Add the macro definitions below to your settings.json
View handler.py
#!/usr/bin/env python
import os
import sys
def hello(event, context):
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mydjangoproject.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
View serverless.yml
service: serverless-django
custom: ${file(./variables.yml)}
provider:
name: aws
runtime: python3.7
functions:
hello:
environment: ${self:custom}
handler: handler.hello
View migrate.py
#!/usr/bin/env python
import os
import sys
def handler(event, context):
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mydjangoproject.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
View serverless.yml
functions:
migrate:
environment: ${self:custom.variables}
handler: migrate.handler
View serverless.yml
functions:
hello:
environment: ${self:custom}
handler: handler.hello
events:
- http: ANY /
- http: ANY {proxy+}
View serverless.yml
plugins:
- serverless-wsgi
- serverless-python-requirements
View settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydjangoproject',
'USER': os.environ.get('DB_USER', 'postgres'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': os.environ.get('DB_HOST', 'localhost'),
'PORT': os.environ.get('DB_PORT', 5432),
}
}
View handler.py
import os
def hello(event, context):
return {
"statusCode": 200,
"body": "The answer is: " + os.environ["THE_ANSWER"]
}
@codeluggage
codeluggage / es6ToNightwatch.js
Last active Oct 22, 2021
Convert ES6 classes to basic Javascript objects to export for Nightwatch
View es6ToNightwatch.js
'use strict';
/*
* The purpose of this function is to convert an ES6 class to either:
* 1) A test suite if it has "tests" as a property
* 2) A page object with optional "elements", "commands" and "url"
* @param es6Class The actual class object (not instance of the class) to convert
*/
module.exports = function(es6Class) {
let properties = Object.getOwnPropertyNames(es6Class.prototype);