Skip to content

Instantly share code, notes, and snippets.

@elct9620
elct9620 / README.md
Created February 11, 2024 14:35
Hugo to Embedding Example

Hugo to Embedding Example

Convert Hugo articles to Embendding for Cloudflare Vectorize Store

Add JSON output to Hugo

The single.json is a example to add JSON outptu for your theme.

Setup a new config ai.toml to extend output

@tejpochiraju
tejpochiraju / offline_caching.js
Created November 27, 2020 07:03
Example showing how to download large objects from S3 and cache using IndexedDB
// Example showing how to download large objects from S3 and cache using IndexedDB
// Once downloaded, all future requests for the file are automatically served from IndexedDB.
// Offline caching module -
import Dexie from 'dexie';
import axios from 'axios';
const db = new Dexie('offline-blobs');
db.version(1).stores({
blobs: 'key,id, blob'
@ionurboz
ionurboz / debounce-throttle.md
Last active October 9, 2024 11:16
Simple JavaScript debounce and throttle (Pure, Vanilla, Plain JS)

If you've written any kind of validation on user input, like onkeypress then you'll know that sometimes you want to throttle the amount of times your function runs. A good example of this is Ajax based username validation - you don't want to hit the server on every key press, because most users will be able to write their name in around 1/10th of a second, so you should throttle the ajax request until the input is dormant for 100ms.

So with a bit of magic JavaScript making use of the ever useful closure JavaScript offers, we can create a simple method to handle this for us:

function debounce(fn, delay) {
  var timer = null;
  return function () {
    var context = this, args = arguments;
    clearTimeout(timer);
 timer = setTimeout(function () {
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@extremecoders-re
extremecoders-re / vmware-no-vmem.md
Last active April 6, 2024 08:09
Boost VMWare Performance by disabling vmem files.

Prevent creation of vmmem files in VMware (Windows)

Issue

VMWare creates .vmem files to back the guest RAM. On the host this causes disk thrashing especially during powering on and off the guest.

Solution

Add the following lines to the .vmx file to prevent creation of .vmem files. This will reduce disk IO and VM performance will improve especially on non-SSD disks.

@meain
meain / loading_messages.js
Last active November 18, 2024 12:25
Funny loading messages
export default [
"Reticulating splines...",
"Generating witty dialog...",
"Swapping time and space...",
"Spinning violently around the y-axis...",
"Tokenizing real life...",
"Bending the spoon...",
"Filtering morale...",
"Don't think of purple hippos...",
"We need a new fuse...",
@Integralist
Integralist / 1. Example.scss
Created October 22, 2012 14:10
Sass Mixin for CSS3 Animations
@include keyframe(fadeout) {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}