Skip to content

Instantly share code, notes, and snippets.

@shaffeeullah
shaffeeullah / generateV4SignedPolicy.js
Last active October 17, 2023 07:50
Generate signed policy URL for upload via PUT request
async function generateV4SignedPolicy() {
// The ID of your GCS bucket
const bucketName = 'your-unique-bucket-name';
// The ID of your GCS file
const fileName = 'your-file-name';
const bucket = storage.bucket(bucketName);
const file = bucket.file(fileName);
@shaffeeullah
shaffeeullah / generateV4UploadSignedUrl.js
Last active October 17, 2023 07:50
Get a v4 signed URL for uploading file
async function generateV4UploadSignedUrl() {
// The ID of your GCS bucket
const bucketName = 'your-unique-bucket-name';
// The full path of your file inside the GCS bucket, e.g. 'yourFile.jpg'
// or 'folder1/folder2/yourFile.jpg'
const fileName = 'your-file-name';
// These options will allow temporary uploading of the file with outgoing
// Content-Type: application/octet-stream header.
@shaffeeullah
shaffeeullah / useCreateReadStreamWithExpress.js
Created November 1, 2021 17:11
Used createReadStream to read data from a Cloud Storage file
app.get('/', async (req, res) => {
const bucket = storage.bucket(bucketName);
const file = bucket.file(fileName);
const readStream = file.createReadStream();
//Pipe data from the read-stream into the HTTP response body
readStream.pipe(res);
});
@shaffeeullah
shaffeeullah / useSignedURLForDownloadWithExpress.js
Last active October 17, 2023 07:50
Use Cloud Storage signed URL with Express.js
app.get('/', async (req, res) => {
// Get signed URL with action 'read'
const signedUrl = await getReadSignedUrl(bucketName, videoName, 10);
let output = `<video width="400" controls>
<source src=${signedUrl} type="video/mp4">
</video>`
res.send(output);
});
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active November 14, 2024 08:31
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@nicholaskajoh
nicholaskajoh / index.html
Last active November 27, 2023 10:01
Lazy load your content with Django and jQuery
<html>
<head>
<script type="text/javascript">
// A CSRF token is required when making post requests in Django
// To be used for making AJAX requests in script.js
window.CSRF_TOKEN = "{{ csrf_token }}";
</script>
</head>
<body>
<h2>My Blog Posts</h2>
@otkrsk
otkrsk / multiple-ssh-authkeys.md
Last active May 6, 2024 14:12
Add multiple SSH keys to the authorized_keys file to enable SSH authentication when connecting to a server.

Step 1: Generate first ssh key Type the following command to generate your first public and private key on a local workstation. Next provide the required input or accept the defaults. Please do not change the filename and directory location.

workstation 1 $ ssh-keygen -t rsa

Finally, copy your public key to your remote server using scp

@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"