Instantly share code, notes, and snippets.

View all_constants_defined_in_drupal_7_core.md

Base

define('DRUPAL_ROOT', getcwd());
define('VERSION', '7.60-dev');
define('DRUPAL_CORE_COMPATIBILITY', '7.x');

The value of VERSION (7.60-dev) above varies for each version.

View fabric_sample.py
'''デプロイ関連タスクのための Fabric コマンド'''
# .env ファイルの中身は次のとおり
# hosts=ホスト名A|ホスト名B
# shell='/usr/local/bin/bash -l -c'
# project_path='/var/www/プロジェクト名'
from functools import wraps
from pathlib import Path
View python_test_sample_with_mocks.py
import unittest
from unittest import mock
import requests
import PypiPackageInfo
URL_JSON = ...
View compress_dir_exluding_ds_store.py
# coding: utf-8
'''Compresses a directory into a zip file excluding .DS_Store files in MacOS.
'''
import argparse
import zipfile
from pathlib import Path
from typing import Iterable, List
View chmod.py
# coding: utf-8
'''Provides functions to add file permissions.
'''
import stat
from pathlib import Path
from functools import reduce
# read:
View fibonacci_with_linear_order.py
# coding: utf-8
"""Gets Fibonacci numbers with a linear Order.
"""
def get_fibonacci(n):
a = 0
b = 1
for i in range(0, n):
View fibonacci_with_log_order.py
# coding: utf-8
"""Get a Fibonacci number with O(log(n)).
1, 1, 2, 3, 5, 8, 13, 21, ...
The logic to get a Figonacci number with O(log(n)) is explained at https://kukuruku.co/post/the-nth-fibonacci-number-in-olog-n .
"""
from functools import lru_cache, reduce
View tower_of_hanoi.py
# coding: utf-8
"""Tower of Hanoi.
"""
TOTAL_DISK = 3
def main():
print('started.')
View po_extract_entry.py
# coding: utf-8
"""Extract entries from GetText (.po) file.
usage:
print __script__ in.po filter.txt > out.po
- standard input: not used.
- standard output: filtered po file content.
View find_large_files.py
# coding: utf-8
"""特定のパス以下にあるサイズの大きなファイルを探すスクリプト
usage:
$ python __script__ [path] --size [size]
$ # カレントディレクトリ以下の 100 MB 以上のファイルを探す場合
$ python __script__ . --size 100