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
/* | |
* Throwable, StackTraceElement is in java.lang | |
* | |
* StackTraceElement has the following attributes (get methods) | |
* className | |
* methodName | |
* fileName | |
* lineNumber | |
*/ |
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 base64 | |
# ipynbファイルを読み込む | |
with open("notebook.ipynb", "r", encoding="utf-8") as f: | |
notebook = json.load(f) | |
# セルを解析して画像データを抽出 | |
for cell in notebook.get("cells", []): | |
if cell.get("cell_type") == "markdown": |
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 datetime import datetime | |
def calculate_days(from_date, to_date): | |
""" | |
Calculate the number of days between two dates. | |
Parameters: | |
from_date (str): The start date in the format 'YYYY-MM-DD'. | |
to_date (str): The end date in the format 'YYYY-MM-DD'. |
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
/** | |
This is a code of Google Apps Script for copying google drive folder content to other folder. | |
## Which situation the code resolve. | |
Google doesn't allow to move folder content to other folder which is managed by | |
other organization according to the policy of the GSUITE organization. | |
And, Google doesn't allow to change the content owner to the user in other | |
organizations. |
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 datetime | |
import time | |
total = 60 | |
total_width = len(str(total)) | |
s = datetime.datetime.now() | |
while True: | |
c = datetime.datetime.now() | |
t = int(total - (c - s).total_seconds()) | |
if t <= 0: |
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
// Require `PhoneNumberFormat`. | |
const PNF = require('google-libphonenumber').PhoneNumberFormat; | |
// Get an instance of `PhoneNumberUtil`. | |
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance(); | |
function test(text) { | |
// Parse number with country code and keep raw input. | |
let number = phoneUtil.parseAndKeepRawInput(text, 'JP'); | |
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
for sub in $(az account list -o tsv --query '[].name'); do | |
echo "# subscription = $sub" | |
for id in $(az network private-endpoint list --subscription $sub --query '[] | networkInterfaces[].id' -o tsv); do | |
address=$(az network nic show --ids $id --query 'ipConfigurations[].privateIpAddress' -o tsv) | |
for fqdn in $(az network nic show --ids $id --query 'ipConfigurations[].privateLinkConnectionProperties.fqdns' -o tsv); do | |
if [ -z "$fqdn" ]; then | |
continue | |
fi | |
echo "$address $fqdn" | |
done |
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 pptx | |
from pptx.enum.shapes import MSO_SHAPE_TYPE | |
import os | |
# extract all images in the pptx file | |
def extract_images(pptx_path, output_dir): | |
i = 0 | |
ppt = pptx.Presentation(pptx_path) | |
for slide in ppt.slides: |
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
# HMAC with SHA-256 | |
def sha256(message): | |
# SHA-256 implementation | |
import hashlib | |
return hashlib.sha256(message).digest() | |
def xor(a, b): | |
# XOR two byte strings | |
return bytes([x ^ y for x, y in zip(a, b)]) |
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
# メッセージをビット列に変換する関数 | |
def message_to_bitstring(message): | |
bitstring = "" | |
for char in message: | |
# ASCII コードを 8 ビットのビット列に変換する | |
bit = bin(ord(char))[2:].zfill(8) | |
bitstring += bit | |
return bitstring | |
NewerOlder