Skip to content

Instantly share code, notes, and snippets.

View aculich's full-sized avatar
😀
Having fun exploring repos for Computational Text Analysis with D-Lab CTAWG

Aaron Culich aculich

😀
Having fun exploring repos for Computational Text Analysis with D-Lab CTAWG
View GitHub Profile
@aculich
aculich / GithubClient.gs
Created September 24, 2021 09:11 — forked from pamelafox/GithubClient.gs
Google Apps Script for committing a file to Github Repo
/* A bare-bones GithubClient, just used for commits */
function GithubClient(owner, repo, username, passwordOrToken) {
this.owner = owner;
this.repo = repo;
this.username = username;
this.passwordOrToken = passwordOrToken;
}
/*
@aculich
aculich / whatFilesHaveIShared.gs
Last active September 21, 2021 19:37 — forked from danjargold/whatFilesHaveIShared.gs
Google script to list (on a Google Sheet) all files shared in your google drive, including all viewers, editors, and sharing permissions. Credit goes to @woodwardtw (https://gist.github.com/woodwardtw/22a199ecca73ff15a0eb) as this is an improvement on his code which only assesses a single folder and one level of sub-folders down.
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "Sharing Access", "Sharing Permission", "Get Editors", "Get Viewers", "Date", "Size", "URL", "Download", "Description", "Type"]); //writes the headers
//var folder = DriveApp.getFolderById("INSERT_YOUR_FILE_ID");//that long chunk of random numbers/letters in the URL when you navigate to the folder
//getLooseFiles(folder, sheet);
//getSubFolders(folder, sheet);
//instead of getting folder by ID rather get all folders and cycle through each. Note this will miss loose files in parent directory.
var folder = DriveApp.getFolders()
@aculich
aculich / chrome-profiles.sh
Created September 19, 2021 10:46
Open a Chrome profile based on email-address from data in chrome://local-state/ JSON format
# To get a list of Chrome profiles in JSON format use this URL in your Chrome browser:
# chrome://local-state/
# Save the content to local-state.json and then:
cat local-state.json| jq '.profile.info_cache | to_entries | .[] | [{person:.value.gaia_given_name, label:.value.name, email:.value.user_name, profile:.key}]'
cat local-state.json| jq '.profile.info_cache | to_entries | .[] | select(.value.user_name=="aculich@berkeley.edu") | [{person:.value.gaia_given_name, label:.value.name, email:.value.user_name, profile:.key}]'
# jq-cheetsheet.md
# https://gist.github.com/olih/f7437fb6962fb3ee9fe95bda8d2c8fa4
@aculich
aculich / block_personal_appts
Created September 14, 2021 02:19 — forked from ttrahan/block_personal_appts
Google Apps Script to automatically create, edit and delete events on work calendar for personal calendar events. Instructions on how to set up can be found at https://medium.com/@willroman/auto-block-time-on-your-work-google-calendar-for-your-personal-events-2a752ae91dab
function sync() {
var id="XXXXXXXXXX"; // CHANGE - id of the secondary calendar to pull events from
var today=new Date();
var enddate=new Date();
enddate.setDate(today.getDate()+7); // how many days in advance to monitor and block off time
var secondaryCal=CalendarApp.getCalendarById(id);
var secondaryEvents=secondaryCal.getEvents(today,enddate);

Remove white background color of an image in ImageMagick

$ convert  your.jpg  -transparent white  your.png

Flatten a transparent image with a white background:

@aculich
aculich / sort-tabs.txt
Created July 27, 2021 02:15 — forked from bpmore/sort-tabs.txt
Sort Tabs in Google Spreadsheets
1. Copy/Paste the information below to the clipboard
2. Open the spreadsheet whose sheets need to be alphabetised
3. Choose Tools > Script editor > Blank (this opens a new tab in the browser)
4. Press Control+A followed by Control+V copy and paste the script in
5. Press Control+S to save the script
6. Choose Run > sortSheets
7. Go back to the spreadsheet tab to view the new sorted tab order
--Copy everything below this line--
function sortSheets () {
@aculich
aculich / walk_gdrive.py
Created July 9, 2021 15:23 — forked from xflr6/walk_gdrive.py
Recursively traverse the directory tree of a Google Drive folder as variation of os.walk()
# walk_gdrive.py - os.walk variation with Google Drive API
import os
from apiclient.discovery import build # pip install google-api-python-client
FOLDER = 'application/vnd.google-apps.folder'
def get_credentials(scopes, secrets='~/client_secrets.json', storage='~/storage.json'):
from oauth2client import file, client, tools
@aculich
aculich / spacemacs-install-source-code-pro-font.md
Last active July 4, 2021 02:03
download and install source code pro font for spacemacs

Install Adobe Source Code Pro fonts for Spacemacs

Get latest release from github repo: https://github.com/adobe-fonts/source-code-pro

This assumes you have the gh github package installed. Either for Ubuntu snap install gh or OSX: brew install gh

$ gh release view -R adobe-fonts/source-code-pro --jq '.assets[].url' --json assets | grep TF
https://github.com/adobe-fonts/source-code-pro/releases/download/2.038R-ro/1.058R-it/1.018R-VAR/OTF-source-code-pro-2.038R-ro-1.058R-it.zip
https://github.com/adobe-fonts/source-code-pro/releases/download/2.038R-ro/1.058R-it/1.018R-VAR/TTF-source-code-pro-2.038R-ro-1.058R-it.zip
@aculich
aculich / add-dlab-team-members.sh
Created June 23, 2021 01:10
Add D-Lab Team members
# brew install hub jq
### Create a list of github usernames in a file and then:
for i in `cat curriculum-development`; do hub api --flat orgs/dlab-berkeley/teams/curriculum-development/memberships/$i -X PUT; done
### see docs in: https://docs.github.com/en/rest/reference/teams#add-or-update-team-membership-for-a-user