This file contains hidden or 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
| #ini_set('xdebug.var_display_max_data', '2024'); | |
| xdebug.max_nesting_level=10000 | |
| xdebug.var_display_max_data=2024 |
This file contains hidden or 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
| # get the updated sources list for old debian / stretch | |
| echo "deb http://ftp.debian.org/debian stretch-backports main" | tee /etc/apt/sources.list.d/backports.list | |
| apt-get update | |
This file contains hidden or 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
| /*-- MYSQL timezone conversion | |
| DATE_ADD(CONVERT_TZ(NOW(), 'GMT', 'Europe/London'),INTERVAL 60 MINUTE) | |
| CONVERT_TZ(NOW(), 'GMT', 'Europe/London') | |
| */ | |
| ## test via php.ini timezone set in google app engine | |
| echo date_default_timezone_get(); | |
| date_default_timezone_set('Europe/London'); |
This file contains hidden or 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
| from inspect import getmembers | |
| from pprint import pprint | |
| pprint(getmembers(yourObj)) | |
| # or... | |
| pprint(vars(your_object)) |
This file contains hidden or 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
| # Get project ID dynamically -- will not work on local environment | |
| import urllib.request | |
| url = "http://metadata.google.internal/computeMetadata/v1/project/project-id" | |
| req = urllib.request.Request(url) | |
| req.add_header("Metadata-Flavor", "Google") | |
| PROJECT_ID = urllib.request.urlopen(req).read().decode() | |
| #neater version | |
| import google.auth |
This file contains hidden or 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 os | |
| from google.cloud import secretmanager | |
| # Get project ID dynamically -- will not work on local environment | |
| # not set automatically in newer runtimes - python3.7 and other older runtimes used to have auto access. | |
| import urllib.request | |
| url = "http://metadata.google.internal/computeMetadata/v1/project/project-id" | |
| req = urllib.request.Request(url) | |
| req.add_header("Metadata-Flavor", "Google") | |
| PROJECT_ID = urllib.request.urlopen(req).read().decode() |
This file contains hidden or 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
| echo -n "Hello" | \ | |
| gcloud secrets create greeting \ | |
| --data-file=- --replication-policy=automatic |
This file contains hidden or 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 os | |
| from google.cloud import secretmanager | |
| # init secret manager | |
| client = secretmanager.SecretManagerServiceClient() | |
| secret_name = "TEST_SECRET" | |
| project_id = "861704209512" | |
| request = {"name": f"projects/{project_id}/secrets/{secret_name}/versions/latest"} | |
| response = client.access_secret_version(request) | |
| secret_string = response.payload.data.decode("UTF-8") |
This file contains hidden or 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
| // Ensure no caching takes place in browser | |
| header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1. | |
| header('Pragma: no-cache'); // HTTP 1.0. | |
| header('Expires: 0'); // Proxies. | |
| if ("OPTIONS" === $_SERVER['REQUEST_METHOD']) { | |
| /** | |
| * This request type is purely for browser requests of type 'options' | |
| * This is when a browser network request (i.e. fetch from cross site) | |
| * runs a preflight 'check' to determine the allowed headers from this server. |
This file contains hidden or 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
| public function test() { | |
| $file = file_get_contents(FULL_PATH.'/httpdocs/input.txt'); | |
| $rawNumbers = explode(PHP_EOL, $file); | |
| $count = count($rawNumbers); | |
| echo "Total numbers to count: $count <br/>"; | |
| foreach ($rawNumbers as $key => $no) { | |
| $no = (int) $no; | |
| $neededNo = 2020 - $no; |
NewerOlder