Skip to content

Instantly share code, notes, and snippets.

function listDocsInFolder() {
var folderId = '########' // folder id that can be retrived from the url of the Google Drive folder
var folder = DriveApp.getFolderById(folderId);
var files = folder.getFiles();
var fileDetails = []
while (files.hasNext()){
file = files.next();
fileDetails.push({id:file.getId(), name: file.getName()})
}
var jsonFiles = JSON.stringify(fileDetails, null, 2)
<head>
<title>### Google Slides name ###</title>
</head>
<body><iframe
src="https://docs.google.com/presentation/d/### Google Slides id ###/embed
frameborder="0"
width="960"
height="569"
allowfullscreen="true"
mozallowfullscreen="true"
function listDocsInFolder() {
var folderId = '########' // folder id that can be retrived from the url of the Google Drive folder
var folder = DriveApp.getFolderById(folderId);
var files = folder.getFiles();
while (files.hasNext()){
file = files.next();
Logger.log('File name: %s', file.getName());
Logger.log('File id: %s', file.getId());
...
}
@EnricoPicci
EnricoPicci / pageWithEmbeddedDoc.html
Last active May 24, 2023 06:04
Page embedding a Google Docs published document
<head>
<title>A page embedding a Google Docs published document</title>
</head>
<body><iframe
src="https://docs.google.com/presentation/d/abcs........1234/embed?start=false&loop=false&delayms=3000"
frameborder="0"
width="960"
height="569"
allowfullscreen="true"
mozallowfullscreen="true"
@EnricoPicci
EnricoPicci / bufferConcatMap-with-defer.ts
Created March 18, 2022 12:58
bufferConcatMap operator that works also with concurrent subscriptions
export function bufferConcatMap<T, R>(project: (val: T[], index: number, bufferIndex: number) => Observable<R>) {
return (sourceObservable: Observable<T>) => {
// buld the Observable returned by this operator
return defer(() => {
// this function will be called each time this Observable is subscribed to.
// initialize the state - these variables will hold the state for every subscripition of the returned Observable
let bufferedNotifications = [] as T[];
let processing = false;
let _index = -1; // index of the notification from upstream
// example of how to use bufferConcatMap
import { delay, interval, of, take } from 'rxjs';
import { bufferConcatMap } from './bufferedConcatMap';
// source Observable
const source = interval(100).pipe(take(5));
// new transformed Observable created with bufferConcatMap
// this is when bufferConcatMap is actually invoked
export function bufferConcatMap<T, R>(project: (val: T[]) => Observable<R>) {
return (sourceObservable: Observable<T>) => {
// this function will be called each time this Observable is subscribed to.
// initialize the state - these variables will hold the state for every
// subscripition of the returned Observable
let bufferedNotifications = [] as T[];
let processing = false;
// buld the Observable returned by this operator
@EnricoPicci
EnricoPicci / another-component-state-hook.tsx
Last active June 26, 2021 15:53
State definition for AnotherComponent
export const AnotherComponent: FC = () => {
const [data, setData] = useState("No data received yet from remote service");
return (
<div className="AnotherComponent">
<h3>AnotherComponent</h3>
<p>{data}</p>
</div>
);
@EnricoPicci
EnricoPicci / use-effect-another-component.tsx
Last active June 26, 2021 16:05
useEffect in AnotherComponent
const myService = useContext(MyServiceContext);
const [data, setData] = useState("No data received yet from remote service");
useEffect(() => {
const data$ = myService.remoteData$.pipe(
tap((data) => setData(data))
);
const reset$ = myService.reset$.pipe(
tap((data) => setData(""))
);
@EnricoPicci
EnricoPicci / my-context.ts
Last active June 26, 2021 14:52
MyServiceContext implementation for reactive-programming-with-react-basic-example
const service = new MyService();
export const MyServiceContext = React.createContext(service);