Skip to content

Instantly share code, notes, and snippets.

View grantglidewell's full-sized avatar

Grant Glidewell grantglidewell

View GitHub Profile
@grantglidewell
grantglidewell / uuid.js
Created September 18, 2019 01:13
UUIDv4 implementation
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
console.log(uuidv4());
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Swap the Option/Alt and Command keys for Mac keyboards
RAlt::RWin
RWin::RAlt
LAlt::LWin
LWin::LAlt
import { useEffect, useState } from 'react';
let intersectionObserver;
let intersectionObserverOptions = {};
const subscribers = new WeakMap();
const handleIntersections = entries =>
entries.forEach(entry => subscribers.get(entry.target).call(null, entry));
const getIntersectionObserver = () => {
const colors = {
Reset: "\x1b[0m",
Bright: "\x1b[1m",
Dim: "\x1b[2m",
Underscore: "\x1b[4m",
Blink: "\x1b[5m",
Reverse: "\x1b[7m",
Hidden: "\x1b[8m",
FgBlack: "\x1b[30m",
const { get } = require('https')
const { readFileSync, writeFileSync } = require('fs')
const checkPageForText = (page, text) => {
// Make the http request for the resource
get(page, resp => {
let data = ''
// Build the 'data' string as chunks come in
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"
"time"
)
from urllib2 import urlopen
import time
def scrape(url, term) :
# Make the http request for the resource
response = urlopen(url)
# Read the response body to a variable
html = response.read()
extern crate reqwest;
use std::time::SystemTime;
use std::fs::File;
use std::io::prelude::*;
fn write_file(filename: &str, data: &str) {
let bytes = data.as_bytes();
let mut file = File::create(filename).expect("Error creating file");
file.write_all(bytes).expect("Error writing file");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<style>
body {
margin: 0;
padding: 0;
const fuzzyCompare = (term, compare, tolerance = 0) => {
if(term.length > compare.length){
return false;
}
return term.split('').filter(l => {
return compare.split('').find(cl => {
return cl === l
});
}).length >= (term.length - tolerance)
}