Skip to content

Instantly share code, notes, and snippets.

View sambshapiro's full-sized avatar

Sam Shapiro sambshapiro

View GitHub Profile
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Client;
private function purgeImgixUrl($url) {
$client = new Client();
try {
$response = $client->post('https://api.imgix.com/v2/image/purger', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Basic ' . base64_encode($this->ImgixApiToken . ':')
@sambshapiro
sambshapiro / firebase.js
Last active March 8, 2020 19:19
Firebase Firestore & Cloud Functions Local Development with React
const firebase = require('firebase/app');
require('firebase/auth');
require('firebase/functions');
require('firebase/firestore');
const firebaseConfig = {
apiKey: '',
authDomain: '',
databaseURL: '',
projectId: '',
@sambshapiro
sambshapiro / firebase.js
Created March 8, 2020 19:20
Firebase local development with Firestore & Cloud Functions
if (window.location.hostname === 'localhost') {
console.log("testing locally -- hitting local functions and firestore emulators");
firebase.functions().useFunctionsEmulator('http://localhost:5001');
firebase.firestore().settings({
host: 'localhost:8080',
ssl: false
});
}
@sambshapiro
sambshapiro / firebase.json
Created March 8, 2020 19:31
Firebase.json example
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
}
}
@sambshapiro
sambshapiro / upload_large_file_to_google_drive.py
Created November 21, 2020 04:44
Upload large file to Google Drive as Resumable Upload using Google Drive API
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
media = MediaFileUpload(filename, mimetype='video/MP2T', resumable=True) # change mimetype to appropriate mimetype
google_drive_request = drive.files().create(media_body=media)
google_drive_response = None
while google_drive_response is None:
status, response = google_drive_request.next_chunk()
if status:
print("Uploaded %d%%." % int(status.progress() * 100))
import os
import Crypto
from hashlib import md5
from Crypto.Cipher import AES
from Crypto import Random
import hexdump
from chardet import detect
source_directory = ''
target_directory = ''