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 / 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();
/**
* 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();
@stefanjudis
stefanjudis / stayScrolledDown.vue
Last active May 3, 2023 18:33
ScrollContainer always on bottom using MutationObserver using a vue.js directive
export default {
bind() {
let element = this.el;
this.observer = new MutationObserver( ( mutations ) => {
for ( var i = 0; i < mutations.length; i++ ) {
// adjust element scrollTop depending on it's changed height
element.scrollTop = element.scrollHeight;
}
} ) ;
var SLOW_TIME = 3000;
this.addEventListener( 'install', function () {
console.log('Installed service worker');
} );
this.addEventListener( 'fetch', function(event) {
var url = event.request.url;
if ( url.indexOf( 'blocking' ) === -1) {
@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 / 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
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" }
@stefanjudis
stefanjudis / package.json
Last active October 2, 2019 07:36
Cached SQIP implementation on Netlify
{
"name": "sqip-cache-tryout",
"version": "1.0.0",
"description": "",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "stefan judis <stefanjudis@gmail.com>",
const actionType = "LUNCH_ORDERED"
switch(actionType) {
case "LUNCH_ORDERED":
console.log("lunch")
case "DINNER_ORDERED":
console.log("dinner")
break
default:
console.log(":/")