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
| #!/usr/bin/env python | |
| # -*- coding: utf_8 -*- | |
| import json | |
| import sys, os, datetime | |
| import pymongo | |
| # sysモジュールをリロードする | |
| reload(sys) | |
| # デフォルトの文字コードを変更する. | |
| sys.setdefaultencoding('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
| /** | |
| * スプレッドシートに記載したURLの外形監視を実行する。 | |
| * 指定されたURLに接続してステータスコードが200以外の場合メールで通知する。 | |
| * また、前回の実行時に200以外のステータスコードだった場合で、 | |
| * ステータスが200になった場合は復旧メールを送信する。 | |
| * スプレッドシートの項目は、サービス名, 監視対象URL, ステータス, emails(10個まで) とする。 | |
| */ | |
| function monitoring() { | |
| var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); |
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
| SELECT | |
| protoPayload.authenticationInfo.principalEmail AS email, | |
| ROUND(SUM(protoPayload.serviceData.jobCompletedEvent.job.jobStatistics.totalBilledBytes) /1000000000, 3) AS total_GBytes, | |
| protoPayload.serviceData.jobCompletedEvent.job.jobStatistics.billingTier AS billing_tier, | |
| COUNT(protoPayload.serviceData.jobCompletedEvent.job.jobConfiguration.query.query) AS query_count, | |
| protoPayload.serviceData.jobCompletedEvent.job.jobConfiguration.query.query AS query_string, | |
| FROM | |
| TABLE_DATE_RANGE(AuditLogs.cloudaudit_googleapis_com_data_access_, DATE_ADD(CURRENT_TIMESTAMP(), -7, 'DAY'), CURRENT_TIMESTAMP()) | |
| WHERE | |
| protoPayload.serviceData.jobCompletedEvent.eventName = 'query_job_completed' |
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
| var request = require('request'); | |
| var fs = require('fs'); | |
| const SLACK_BOT_TOKEN = 'hogehoge'; | |
| const api_url = 'https://slack.com/api/'; | |
| var fileName = 'hogefuga.png'; | |
| var channel = 'general'; | |
| options = { | |
| token: SLACK_BOT_TOKEN, | |
| filename: fileName, |
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 math | |
| n = 100 | |
| digits = int(math.log10(n) + 1) # 3 |
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 json | |
| import requests | |
| import urllib | |
| import sys | |
| from xml.etree import ElementTree | |
| doItAgain = "yes" #Control While loop | |
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
| function deleteOldMail() { | |
| var sheet = SpreadsheetApp.getActive().getSheetByName('label'); | |
| for(var row=2; row<=sheet.getLastRow(); row++){ | |
| var labelName = sheet.getRange(row, 1).getValue(); | |
| var days = sheet.getRange(row, 2).getValue(); | |
| var deleteThreads = GmailApp.search('older_than:'+days+'d -is:starred label:'+ labelName); | |
| for (var i = 0; i < deleteThreads.length; i++) { | |
| deleteThreads[i].moveToTrash(); | |
| } |
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 sys | |
| sys.path.append(path.normpath(path.join(path.dirname(path.abspath( __file__ )), '..'))) |
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
| class AwsLambdaClient { | |
| val aws_access_key_id = "<YOUR_ACCESS_KEY_PASTE_HERE>" | |
| val aws_secret_access_key = "<YOUR_SECRET_KEY_PASTE_HERE>" | |
| val region = "ap-northeast-1" | |
| val function_name = "test_func" | |
| fun invoke() { | |
| val payload = """ | |
| { | |
| "token": "TOKEN", |
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
| class Solution: | |
| def twoSum(self, nums: List[int], target: int) -> List[int]: | |
| for i1, num1 in enumerate(nums): | |
| for i2, num2 in enumerate(nums[i1+1:]): | |
| if target == (num1 + num2): | |
| return [i1, i2 + i1 + 1] |