Skip to content

Instantly share code, notes, and snippets.

View katzueno's full-sized avatar

Katz Ueno katzueno

View GitHub Profile
@katzueno
katzueno / aws-s3-mass-undelete.sh
Created September 23, 2020 06:27 — forked from crazycodr/aws-s3-mass-undelete.sh
Batch restore deleted s3 objects by accident
# Set the bucket name and date limit that you want to scan for...
#
# For example, if you deleted everything at 9'ish, set the DATE_LIMIT for a
# few minutes before to ensure you find only the stuff you deleted by error
#
BUCKET_NAME="..."
DATE_LIMIT="0000-00-00T00:00:00.000Z"
aws s3api list-object-versions --bucket "${BUCKET_NAME}" > objects.json
cat objects.json | jq --arg DATE_LIMIT "${DATE_LIMIT}" '[ .DeleteMarkers[] | select(.LastModified > $DATE_LIMIT and .IsLatest) | { file: .Key, version: .VersionId } ]' > markers-to-delete.json
@crazycodr
crazycodr / aws-s3-mass-undelete.sh
Last active September 16, 2022 16:56
Batch restore deleted s3 objects by accident
# Set the bucket name and date limit that you want to scan for...
#
# For example, if you deleted everything at 9'ish, set the DATE_LIMIT for a
# few minutes before to ensure you find only the stuff you deleted by error
#
BUCKET_NAME="..."
DATE_LIMIT="0000-00-00T00:00:00.000Z"
aws s3api list-object-versions --bucket "${BUCKET_NAME}" > objects.json
cat objects.json | jq --arg DATE_LIMIT "${DATE_LIMIT}" '[ .DeleteMarkers[] | select(.LastModified > $DATE_LIMIT and .IsLatest) | { file: .Key, version: .VersionId } ]' > markers-to-delete.json
@kanetei
kanetei / controller.php
Created April 11, 2017 03:30
【concrete5】特定のエクスプレスオブジェクトで、属性(チェックボックス)にチェックがない時に項目を表示するカスタマイズ
<?php
namespace Application\Block\ExpressEntryList;
use Concrete\Core\Express\Entry\Search\Result\Result;
use Concrete\Core\Express\EntryList;
class Controller extends \Concrete\Block\ExpressEntryList\Controller
{
public function view()
@hissy
hissy / import_files.php
Last active May 16, 2017 20:45
[concrete5][V8] Search all files from legacy database, then import files to modern concrete5
<?php
namespace Application\Job;
use Concrete\Core\File\Importer;
use Concrete\Core\Job\QueueableJob;
use ZendQueue\Message as ZendQueueMessage;
use ZendQueue\Queue as ZendQueue;
class ImportFiles extends QueueableJob
{
@hissy
hissy / scan_duplicate_file_name.php
Last active April 11, 2017 06:02
[concrete5][Legacy] Find duplicate file name and change it
<?php
class ScanDuplicateFileName extends QueueableJob
{
public $jNotUninstallable=0;
public $jSupportsQueue = true;
public function getJobName()
{
return t('Scan Duplicate File Name');
@hissy
hissy / ManualNavPublisher.php
Last active May 1, 2020 09:15
[concrete5][V8][MigrationTool] Example of creating custom publisher
<?php
// application/src/Concrete/MigrationTool/Publisher/Block/ManualNavPublisher.php
namespace Application\Concrete\MigrationTool\Publisher\Block;
use Concrete\Core\Block\Block;
use Concrete\Core\Page\Page;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\Batch;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\BlockValue\BlockValue;
use PortlandLabs\Concrete5\MigrationTool\Publisher\Block\PublisherInterface;
@hissy
hissy / app.php
Created April 9, 2017 07:22
[concrete5] [V8] Add password validation rule
<?php
// application/bootstrap/app.php
/** @var \Concrete\Core\Validator\ValidatorManagerInterface $passwordValidator */
$passwordValidator = Core::make('validator/password');
/** @var \Concrete\Core\Validator\String\RegexValidator $regexValidator */
$regexValidator = Core::make(
\Concrete\Core\Validator\String\RegexValidator::class,
['/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/']
);
@YuzuruSano
YuzuruSano / add_page_by_composer.php
Last active November 24, 2016 15:27
コンポーザーを通して新規ページを追加して、初期出力の記事ブロックに記事を挿入する。自動実行ジョブにどうぞ
<?php
//ページタイプの「出力」で'Main'エリアにコンポーザーで扱うcontentブロックを入れてる場合
$pageType = \PageType::getByHandle('ページタイプハンドル');
$template = $pageType->getPageTypeDefaultPageTemplateObject();
$d = $pageType->createDraft($template);
$d->setPageDraftTargetParentPageID(親ページID);
$pageType->savePageTypeComposerForm($d);
$pageType->publish($d);
//$dには追加したページオブジェクトが入ってくる
@biojazzard
biojazzard / facebook_page_latest_post_no_php_sdk.php
Created March 6, 2016 11:32
Get Latest Post From a Facebook Page without PHP SDK (Graph Version v2.5)
<?php
/*
1.- Create an App.
2.- Go to: https://developers.facebook.com/tools/explorer/
+ Select your new created app on the right top.
+ Select "Get App Token"
@hissy
hissy / concrete.php
Last active September 2, 2019 02:47
#concrete5 #5.7 How to work concrete5 behind a load balancer or a reverse proxy
<?php
/**
* Always trust incoming request.
*
* application/config/concrete.php
*
* For more detail, see: http://symfony.com/doc/current/cookbook/request/load_balancer_reverse_proxy.html
*/