Skip to content

Instantly share code, notes, and snippets.

View stefanjudis's full-sized avatar
🙉
Jo!

Stefan Judis stefanjudis

🙉
Jo!
View GitHub Profile
@stefanjudis
stefanjudis / asset-update.js
Last active June 2, 2021 10:21
A Node.js script to programmatically update uploads of Contentful assets
const { createReadStream } = require("fs");
const { join } = require("path");
const contentful = require("contentful-management");
const client = contentful.createClient({
accessToken: process.env.CTF_TOKEN,
});
async function main() {
const space = await client.getSpace("[SPACE_ID]");
@stefanjudis
stefanjudis / importJSON.gs
Created January 15, 2020 08:31
API data in google sheets
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
Object.entries({ 1985: "foo", 1984: "bar", 1987: "baz" })
.reverse()
.forEach(([year, content]) => console.log(year, content));
const CPU = {
ram: '32gb',
ssd: '64gb',
micro: 'i7'
};
const { ssd, ...newCPU } = CPU;
console.log(newCPU);
// Object { ram: "32gb", micro: "i7" }
const actionType = "LUNCH_ORDERED"
switch(actionType) {
case "LUNCH_ORDERED":
console.log("lunch")
case "DINNER_ORDERED":
console.log("dinner")
break
default:
console.log(":/")
@stefanjudis
stefanjudis / keys.md
Last active May 20, 2021 22:24
Stefan Learns Emacs
ctrl+/            - undo
ctrl+b            - Switch to buffer
ctrl+c            - special command to invoke "stuff"
ctrl+c ctrl+e     - open Export Dispatcher
ctrl+c ctrl+s     - schedule todo
ctrl+c ctrl+'     - open buffer with code block
ctrl+x LEFT       - switch to prev buffer
ctrl+x RIGHT      - switch to next buffer
ctrl+x ctrl+e     - evaluate line
@stefanjudis
stefanjudis / README.md
Last active August 6, 2019 13:38
Twilio CLI snippets

Useful Twilio CLI snippets. :)

@stefanjudis
stefanjudis / console.js
Last active July 31, 2019 17:09
Suprising replacement patterns in String.prototype.replace
const msg = 'This is a great message';
msg.replace('great', 'wonderful');
// "This is a wonderful message"
//
// -> 'great' is replaced by 'wonderful'
msg.replace('great', '$&-$&');
// "This is a great-great message"
// '$&' represents the matched substring
@stefanjudis
stefanjudis / script.sh
Created July 29, 2019 20:36
create-dirs-recursively.sh
mkdir -p new-dir/{foo,baz}/whatever-{1,2}/{a,b};
exa --tree new-dir;
# new-dir
# ├── baz
# │ ├── whatever-1
# │ │ ├── a
# │ │ └── b
# │ └── whatever-2
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();