Skip to content

Instantly share code, notes, and snippets.

View nitobuendia's full-sized avatar

Nito Buendia nitobuendia

View GitHub Profile
@nitobuendia
nitobuendia / console_code.js
Created May 24, 2019 09:01
Colors of the Wind - Kube-Kube AutoWin
/**
* 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++) {
@nitobuendia
nitobuendia / citc1.py
Created September 8, 2018 10:13
Code in the Community application exercises.
"""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.
@nitobuendia
nitobuendia / get_all_price_extensions.py
Last active August 14, 2018 09:46
Retrieves price extensions details at different levels from a Google Ads account.
"""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:
@nitobuendia
nitobuendia / google_fit.py
Last active August 22, 2021 15:17
Custom sensor for Home Assistant to integrate Google Fit data.
"""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.
@nitobuendia
nitobuendia / index.js
Last active May 27, 2018 14:19
[My Motivational Coach] - A DialogFlow-powered add-on for Google Home Assistant that replies with a randomly generated motivational quote.
/**
* @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;
/**
@nitobuendia
nitobuendia / cache_control.py
Created October 26, 2017 13:38
Django middleware that allows to set up a global cache limit for all your requests.
"""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.
@nitobuendia
nitobuendia / trailing_slash_middleware.py
Last active November 9, 2017 17:02
Django middleware that removes additional erroneous backslashes from your requests.
"""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.