Skip to content

Instantly share code, notes, and snippets.

View vishwarajanand's full-sized avatar
😎
¯\_(ツ)_/¯

Vishwaraj Anand vishwarajanand

😎
¯\_(ツ)_/¯
View GitHub Profile
@vishwarajanand
vishwarajanand / testParallelUploadToGcs.php
Created March 15, 2024 13:31
Uploading GCS Objects in parallel using PHP SDK
<?php
require __DIR__ . "/vendor/autoload.php";
use Google\Cloud\Storage\StorageClient;
use GuzzleHttp\Promise;
# control the number of objects to upload
$NUM_OBJECTS = 5;
$storage = new StorageClient();
@vishwarajanand
vishwarajanand / 5118-touch_throws_warnings.php
Created March 14, 2024 12:25
Test Script for implementing touch in google cloud storage php library
<?php
require __DIR__ . '/vendor/autoload.php';
// https://github.com/googleapis/google-cloud-php/issues/5118
// Warning: touch(): Google\Cloud\Storage\StreamWrapper::stream_metadata is not implemented! #5118
// PR raised: https://github.com/googleapis/google-cloud-php/pull/7144
use Google\Cloud\Storage\StorageClient;
$client = new StorageClient(['projectId' => 'XXXXXXXXXXX']);
@vishwarajanand
vishwarajanand / folder_upload_resumable.php
Last active March 15, 2024 11:38
Folder uploads for google cloud php storage
<?php
require __DIR__ . "/vendor/autoload.php";
use Google\Cloud\Storage\StorageClient;
use GuzzleHttp\Promise\Each;
// Create a Storage client
$storage = new StorageClient([
'projectId' => 'XXXXXXXXXX',
@vishwarajanand
vishwarajanand / issue_7088.php
Created February 26, 2024 22:38
Testing Google Cloud Storage Resumable Uploader headers
<?php
// Ref: https://github.com/googleapis/google-cloud-php/issues/7088
require __DIR__ . "/vendor/autoload.php";
use Google\Cloud\Storage\StorageClient;
$gcsClient = new StorageClient([
"projectId" => "XXXXXXX",
"requestTimeout" => 10,
]);
$gcsBucket = $gcsClient->bucket("XXXXXXX");
@vishwarajanand
vishwarajanand / deleteUnusedBuckets.php
Created December 14, 2023 13:50
Delete buckets (and all objects inside it) with a certain prefix name from Google Cloud Storage
<?php
require_once __DIR__ . '/../vendor/autoload.php';
## Delete all buckets (and objects inside it) with bucket name having prefix: `gcloud_testing_`
use Google\Cloud\Storage\StorageClient;
$client = new StorageClient();
$buckets = $client->buckets();
@vishwarajanand
vishwarajanand / deleteUnusedTopics.php
Created December 14, 2023 13:44
Delete topics with a certain prefix name from Google PubSub
<?php
require_once __DIR__ . '/../vendor/autoload.php';
## Delete all topics and subscriptions with name having prefix: `gcloud_testing_`
use Google\Cloud\PubSub\PubSubClient;
$client = new PubSubClient();
$topics = $client->topics();
@vishwarajanand
vishwarajanand / crcTest.php
Created August 10, 2023 13:53
Product CRC32C in Pure PHP7.4+
<?php
use Google\CRC32\CRC32;
use GuzzleHttp\Psr7\Utils;
include __DIR__.'/vendor/autoload.php';
$filePath = __DIR__.'/tests/System/data/5mb.txt';
## USAGE:
# Paste the file into https://github.com/googleapis/google-cloud-php/tree/main/Storage
@vishwarajanand
vishwarajanand / php.ini
Last active December 14, 2023 13:51
php.ini configs for Google Cloud Platform
extension=protobuf.so
extension=grpc.so
grpc.enable_fork_support=1
; extension=php_openssl.so
; extension=xdebug.so
[Xdebug]
zend_extension=xdebug.so
xdebug.mode=debug
@vishwarajanand
vishwarajanand / SBI-PDF-Statement-cracker.py
Created March 9, 2022 09:27
Crack open your SBI PDF Statements if forgot the registered phone number
# 1: Install pdfplumber from terminal : `pip3 install pdfplumber`
# 2: Save bank statement to a folder as `savings_bank_account_statement.pdf`
# 3: Password is of the format: <last 5 digit of a mobile number><dob>
# 4: Download `SBI-PDF-Statement-cracker.py` file and save to the same folder
# 5: Run this program from terminal as `python3 SBI-PDF-Statement-cracker.py`
import pdfplumber
dob = '131255' # ddmmyy format, dob value is randomized for privacy
for i in range (10000,100000):
pwd = str(i) + dob
@vishwarajanand
vishwarajanand / yt_video_availability.js
Created February 17, 2022 04:34
JS snippet to check whether a YouTube video is available or not
// Load a YT URL like https://www.youtube.com/watch?v=XYZABC
let is_not_available = ["video unavailable", "video isn't available"].
some(needle =>
document.getElementById("contents").textContent.toLowerCase().includes(needle));