Skip to content

Instantly share code, notes, and snippets.

View jeremydw's full-sized avatar

Jeremy Weinstein jeremydw

View GitHub Profile
@jeremydw
jeremydw / reupload.sh
Created March 27, 2023 18:54
Download all JSON files from a page and reupload them to GCS with compression
#!/bin/bash -e
# Reuploads files to Google Cloud Storage and adds gzip compression and 60
# second cache headers.
#
# Usage:
# ./urls.sh https://sites.research.google/relate/ > urls.txt
# ./reupload.sh urls.txt
function get_gs_url() {
import {terser} from 'rollup-plugin-terser';
import {UserConfig} from 'vite';
import fs from 'fs';
import litStylesLoader from '../configs/lit-styles.js';
export interface VitePresetOptions {
scssIncludePaths: string[];
}
function toScssPath(path) {
var el = document.createElement('script');
el.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js';
document.body.appendChild(el);
var el2 = document.createElement('script');
el2.src = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js';
document.body.appendChild(el2);
el2.addEventListener('load', function() {
$('html, body').animate({
scrollTop: 3495
}, 2000, 'easeOutCubic');
@jeremydw
jeremydw / .gitconfig
Created June 9, 2018 06:16 — forked from kwk/.gitconfig
Aliases to quickly find git commits made in quarter of a year
[alias]
# List your commits by quarters of a year in reverse order (short version)
q1 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"January $year\" --until \"March $year\" --oneline --reverse $@; }; f"
q2 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"April $year\" --until \"June $year\" --oneline --reverse $@; }; f"
q3 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"July $year\" --until \"September $year\" --oneline --reverse $@; }; f"
q4 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"October $year\" --until \"December $year\" --oneline --reverse $@; }; f"
# List your commits by quarters of a year in reverse order (long version)
quarter1 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"January $year\" --until \"March $year\" --reverse $@; }; f"
quarter2 = "!f() { year=$1; shift; git
@jeremydw
jeremydw / gist:42139a15f2fc802d3bddeab95b64b646
Created December 12, 2017 06:17
Enforce account chooser on Google App Engine
When using the Google App Engine Users API, there is no way to enforce the account chooser for users signed in to multiple accounts. You can do so by using `users.create_login_url` and replacing the output of the function as so:
```
from google.appengine.api import users
url = users.create_login_url()
url = url.replace('/accounts/ServiceLogin', '/a/SelectSession', 1)
```
This is not guaranteed to work if the output of `users.create_login_url` changes.
```
gcloud service-management enable drive
gcloud service-management enable storage-api.googleapis.com
gcloud service-management enable language.googleapis.com
gcloud iam service-accounts list
gcloud iam service-accounts create <name>
gcloud iam service-accounts keys create --iam-account <name>@$(project).iam.gserviceaccount.com <filename>
```
```
jpegoptim -f --strip-all file.jpg
optipng -force -o7 file.png \
&& advent -z4 file.png \
&& pngcrush \
-rem gAMA \
-rem alla \
-rem cHRM \
-rem iCCP \
-rem sRGB \
@jeremydw
jeremydw / annotate.sh
Created April 11, 2017 16:46
Annotate image with text
convert \
-fill "#485A64" \
-font 'HelveticaNeue.dfont' \
-gravity south \
-weight 400 \
-draw "translate 7,53 text 0,0 'FEGRB'" \
-pointsize 65 \
base.png \
out/out.png
open out/out.png
bucket ?= bucket
update_cors:
gsutil cors set gcs-cors.json gs://$(bucket)