Skip to content

Instantly share code, notes, and snippets.

@sanraul
sanraul / README.md
Last active July 18, 2024 19:58
Google Doc Stitcher

Daily Planner Add-on for Google Docs

This Google Docs Add-on allows you to insert predefined templates into your document at the cursor position. The Add-on provides a custom menu with options to insert various templates, such as "CTele", "TVFU", and others.

Features

  • Insert predefined templates at the cursor position.
  • Custom menu for easy access to templates.
  • Supports various document elements, including paragraphs, tables, and list items.
@sanraul
sanraul / media-response-to-blob.js
Created March 10, 2024 19:39
Converts a media response from a server into a blob that can be opened in a separate browser tab.
fetch("https://chat.openai.com/backend-api/synthesize?message_id=cb427681-eebc-4211-86f3-7331bf241bc5&conversation_id=262e2953-d0b1-48bc-9fad-b42a8c0e47d5&voice=sky", {
"headers": {
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,es;q=0.8,fr;q=0.7,it;q=0.6,la;q=0.5",
"authorization": "Bearer ...",
"oai-device-id": "a41ffdea-e287-40f8-888e-a5ad0702a415",
"oai-language": "en-US",
"sec-ch-ua": "\"Chromium\";v=\"122\", \"Not(A:Brand\";v=\"24\", \"Google Chrome\";v=\"122\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
@sanraul
sanraul / example-exportCanvasToImage.js
Created February 23, 2024 15:22
This JavaScript snippet demonstrates how to export the content of a canvas element to an image in the form of a Data URI (specifically in PNG format, though it can be adjusted for other formats like JPEG). It outlines the process of converting canvas content to a base64-encoded image, displaying this image within an <img> element on the webpage,…
// To export and display an image from a canvas specified by a CSS selector:
exportCanvasToImage('.kix-canvas-tile-content');
// To export and download an image from a canvas element directly:
const myCanvasElement = document.getElementById('myCanvas');
exportCanvasToImage(myCanvasElement, true);
@sanraul
sanraul / typewriter-attach.html
Created March 10, 2023 06:08
Assign a typewriter effect to an existing DOM element.
<script>
/**
* @example
*
* <h2>You can try to</h2>
*
* TxtType.attach('h2:contains("You Can")', ['do this', 'do that'])
*/
var TxtType = function(el, toRotate, period) {
@sanraul
sanraul / typewriter.js
Created March 24, 2022 15:03
test for a typewriter effect
// paste this in the developer console
var text = 'Hello';
var mode = 'ADD'; // SUB, HOLD
var index = 0;
function type(dir) {
index = index + dir;
let output = text.substr(0, index);
return output;
}
@sanraul
sanraul / http_response_code.php
Created February 13, 2022 12:55
Set HTTP response header code and message
<?php
function http_response_code($code = NULL) {
if ($code !== NULL) {
switch ($code) {
case 100: $text = 'Continue';
break;
case 101: $text = 'Switching Protocols';
break;
case 200: $text = 'OK';
@sanraul
sanraul / google-translate.html
Created February 10, 2022 05:35
Adding Google Translate (elements) to a page
<!-- See: https://stackoverflow.com/questions/12243818/adding-google-translate-to-a-web-site -->
<style>
/*
body {
top: auto !important;
}
.skiptranslate {
display: none !important;
@sanraul
sanraul / floating-video.html
Created February 7, 2022 02:36
Keeps a video widget floating as the page scrolls
<div id="BLOCK" class="block py-5">
<div class="container">
<div class="row">
<div class="col-md-5">
<div class="appc-widget d-flex align-items-center h-100">
<div>
<h1>Build digital experiences, incredibly fast</h1>
<p class="lead">Stop waiting on development release cycles. Start dragging and dropping to
build and optimize digital experiences for your website, app, or ecommerce store.
No coding required.
@sanraul
sanraul / curl-ignore-ssl.php
Created November 7, 2021 21:34
Ignore SSL Certificate errors in PHP (good for debugging or when connecting to trusted domains that re using Let's Encrypt
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data) );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Ignore SSL Certificate errors
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
@sanraul
sanraul / sample.html
Created November 4, 2021 20:50
Meta radial background color
<div class="radial">
</div>
<style>
.radial {
width: 100vw;
height: 100vh;
background-image: conic-gradient( from
180deg at 50% 50%, rgba(36, 209, 101, .09)