Skip to content

Instantly share code, notes, and snippets.

View DannyFeliz's full-sized avatar

Danny Feliz DannyFeliz

View GitHub Profile
var tryCount = 0;
var minimalUserResponseInMiliseconds = 200;
function check() {
console.clear();
before = new Date().getTime();
debugger;
after = new Date().getTime();
if (after - before > minimalUserResponseInMiliseconds) {
document.write(" Dont open Developer Tools. ");
self.location.replace(window.location.protocol + window.location.href.substring(window.location.protocol.length));
@DavidWells
DavidWells / github-proxy-client.js
Last active June 27, 2024 14:52
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
import createAuth0Client from '@auth0/auth0-spa-js'
import { computed, reactive, watchEffect } from 'vue'
let client
const state = reactive({
loading: true,
isAuthenticated: false,
user: {},
popupOpen: false,
error: null,
import { useEffect } from "react"
import { confirm } from "../modals"
const hrefBlank = element => {
const href = element.getAttribute("href")
return !href || href === "#"
}
function useBeforeLeave({
message = "",
@coryhouse
coryhouse / PromptOnUnload.jsx
Last active January 7, 2022 11:53
Prompt user when they navigate away
import React, { useEffect } from "react";
import PropTypes from "prop-types";
import { Prompt } from "react-router-dom";
// Prompt the user onbeforeunload or when navigating away by clicking a link
export default function PromptOnUnload({ when, message }) {
const enabled = when;
useEffect(() => {
if (!enabled) return;
const handleBeforeUnload = (event) => {
@m3g4p0p
m3g4p0p / validate_email.js
Created April 26, 2020 19:30
Test if a string is a valid email address using the constraint validation API
/**
* Test if a string is a valid email address
* using the constraint validation API, rather
* than unwieldy regular expressions
*
* @param {string} value
* @returns {boolean}
*/
const validateEmail = value => Object.assign(
document.createElement('input'),
@bellbind
bellbind / index.html
Last active January 17, 2024 14:14
[chrome][android] BarcodeDetector example
<!doctype html>
<html>
<head>
<script type="module">
// WICG Shape Detection API
// - https://wicg.github.io/shape-detection-api/
try {
const start = document.getElementById("start");
const video = document.getElementById("video");
const result = document.getElementById("result");
@peyanski
peyanski / Alexa_and_HA-Whispering_test.json
Created April 1, 2020 05:42
My Alexa and Home Assistant video - Announce/Whispering test
{
"message":"<amazon:effect name='whispered'>I am whispering this.</amazon:effect>",
"data":{"type":"announce", "method":"speak"},
"target":["media_player.CHANGE_ME_TO_YOUR_DEVICE"]
}
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active December 9, 2024 14:38
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user