This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Middleware that removes additional meaningless backslashes. | |
This transforms URLs as follows: | |
- yourwebsite.com// to yourwebsite.com | |
- yourwebsite.com/section/// to yourwebsite.com/section | |
Ideally, this middleware should be placed before Commonmiddleware to avoid | |
conflicts with APPEND_SLASH. However, this code already appends final slash | |
if APPEND_SLASH is set to TRUE trying to reduce one additional redirect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Control MAX age for all Django pages.""" | |
from django.conf import settings | |
from django.utils.deprecation import MiddlewareMixin | |
class MaxAgeMiddleware(MiddlewareMixin): | |
"""Set up Cache-Control header for all Django-handled requests.""" | |
def process_response(self, request, response): | |
"""Adds Cache-Control header to response. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Handles a DialogFlow request and returns a motivational quote. | |
* | |
* In order to deploy, run: | |
* gcloud beta functions deploy getMotivationQuote --trigger-http | |
*/ | |
const /** boolean */ EQUAL_PROBABILITY = true; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Creates a Google Fit sensors. | |
At the moment, provides two measurements: | |
- weight: in KG. | |
- last_updated: entry of the current weight point. | |
Sensor is designed to be flexible and allow customization to add new Google Fit | |
dimensions with minimal effort with relative knowledge of Python and Fitness | |
Rest API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Retrieves price extensions details (at any level, on the data feeds) from a Google Ads account. | |
If you never installed Google Ads API before, you may need to install it first: | |
https://github.com/googleads/googleads-python-lib/blob/master/README.md#getting-started | |
$ pip install setuptools | |
$ pip install googleads | |
$ pip install google-auth-oauthlib | |
In order to use this script, some pre-configuration is needed: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Asks users for input to generate a list of random numbers and print data.""" | |
import random | |
def _generate_print_message(number_list): | |
"""Generates desired print message based on the sequence list of numbers. | |
Args: | |
number_list: List[int], List of numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Clicks the different colored tile. | |
* Wins the game on https://kuku-kube.com/ | |
* To use, simply start the game and paste this code on | |
* the JavaScript console. | |
*/ | |
const clickBoxColor = () => { | |
let lastColor; | |
const boxes = document.querySelectorAll('#box span'); | |
for (let i = 0; i < boxes.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Resizes all images in a document to a desired width | |
* while limited to a max size. Sizes are in cm. | |
* | |
* This code is meant to be implemented as a script on a Google Docs | |
* document: Tools > Script editor. | |
* | |
* Once open, paste the code, adjust your desired sizes and run: | |
* `resizeToDesiredWidth`. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Runs a Hangman game that can be played via terminal. | |
Prerequisites: | |
1. Download the code as hangman.py into any folder. | |
2. Get a .txt file called 'words.txt' with all the words that you want to include in the game. | |
>> Example: https://github.com/dwyl/english-words | |
To play: | |
- Run `python hangman` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flask | |
import reader | |
app = flask.Flask(__name__) | |
enviro_reader = reader.EnviroReader() | |
@app.route("/api/all") | |
def get_all_readings(): |
OlderNewer