Skip to content

Instantly share code, notes, and snippets.

View EngPeterShaker's full-sized avatar

Peter Shaker EngPeterShaker

View GitHub Profile
@MadhuNimmo
MadhuNimmo / rangeerror.js
Created October 14, 2022 19:53
Simplest solution to JSON.stringify RangeError: Invalid string length
var out="[";
for(var indx=0;indx<data.length-1;indx++){
out+=JSON.stringify(data[indx],null,4)+",";
}
out+=JSON.stringify(data[data.length-1],null,4)+"]";

AlpineJS with ViteJS

ViteJS is a modern JavaScript build tool that can be used to build modern JavaScript frameworks including ReactJS and VueJS to name only two. In this tutorial you will explore how to use ViteJS with AlpineJS. This will prepare you for using ViteJS with ReactJS or other modern web framework.

Modern JavaScript built tools like ViteJS, ParcelJS & react-create-app (built with webpack) embrace ES Modules. Meaning that external dependencies are installed via npm and imported. So no more script, style or link tags. HTML, CSS & JavaScript are bundled into compact bundle.

Create app using Vite

Let's start exploring ViteJS by creating a new application. Using this command:

@pishangujeniya
pishangujeniya / Ubuntu-Mojave-Mac-OS-Theme.md
Last active October 18, 2024 10:06
Mac OS Mojave Theme for Ubuntu

Ubuntu To Mac OS Mojave theme

Mc OS Mojave Ubuntu Look alike


Pre-requisites

  • sudo apt update
  • sudo apt install gnome-tweaks
  • sudo apt-get install gir1.2-clutter-1.0 gir1.2-clutter-gst-3.0 gir1.2-gtkclutter-1.0
@francisrstokes
francisrstokes / AsyncAwaitGenerators.js
Created December 28, 2018 23:50
Async/Await in 5 lines
const interpret = iterator => last => {
const {value, done} = iterator.next(last);
return (done) ? Promise.resolve(value) : value.then(interpret(iterator));
};
const asyncAwait = g => interpret(g())();
// ... Usage ...
const addOneSoon = (x, t) => new Promise(resolve => {
@pabloleonalcaide
pabloleonalcaide / checkImageExist.js
Created May 17, 2018 08:08
Check if a image file exists with Javascript
/**
* Checking if an image exist in your image folder
*/
let loadImage = function(variable){
var image = new Image();
var url_image = './ImageFolder/' + variable + '.jpg';
image.src = url_image;
if (image.width == 0) {
return `<img src='./ImageFolder/defaultImage.jpg'>`;
} else {
@dasblitz
dasblitz / example.js
Last active July 4, 2021 19:25
React createFetcher explained
// This gist aims to explain how it's possible that async functions inside React
// using createFetcher(Promise).next(key) can work.
// A possible implementation of the new createFetcher function
// as shown by https://twitter.com/jamiebuilds/status/969169357094842368
// @param method, should be a function returning a Promise.
// @returns an object with a property 'read', used to read values from the resolved 'cache'.
const createFetcher = function(method) {
// First create a Map for the resolved values.
const resolved = new Map()
@jwo
jwo / map.js
Last active March 31, 2022 10:41
React google maps with multiple markers, only one info window
import React, { Component } from "react"
import { compose } from "recompose"
import {
withScriptjs,
withGoogleMap,
GoogleMap,
Marker,
InfoWindow
} from "react-google-maps"
function InsertionSort(arr) {
let len = arr.length, // number of items in the array
value, // the value currently being compared
i, // index into unsorted section
j; // index into sorted section
for(i = 1; i < len; i++) {
// store the current value because it may shift later
@0livare
0livare / .gitconfig
Last active July 8, 2024 04:07
My git alias list. Running 'git alias' will pretty-print these commands to the terminal.
# Some options that may or may not be applicable to you
[user]
name = Zach Olivare
email = [email protected]
[push]
default = upstream
[core]
autocrlf = input # Force replacing CRLF line endings with LF
ignorecase = false
# editor = code --wait