Skip to content

Instantly share code, notes, and snippets.

View StoneyEagle's full-sized avatar
🦅

Stoney_Eagle StoneyEagle

🦅
View GitHub Profile
@StoneyEagle
StoneyEagle / matchPercentage .js
Last active April 4, 2023 23:19
Match percentage
const matchPercentage = (strA, strB) => {
let result = 0;
for (let i = strA.length; (i -= 1);) {
if (typeof strB[i] == 'undefined' || strA[i] == strB[i]) {
//
} else if (strA[i].toLowerCase() == strB[i].toLowerCase()) {
result += 1;
} else {
result += 4;
}
@StoneyEagle
StoneyEagle / db.ts
Created March 20, 2023 17:05
Prisma hack to avoid db timeout.
export const checkDbLock = async () => {
const { confDb } = require('./config');
try {
await confDb.$queryRaw`BEGIN EXCLUSIVE;`;
await confDb.$queryRaw`COMMIT;`;
return false;
} catch (error) {
return true;
}
};
@StoneyEagle
StoneyEagle / NoMercyPlayer.html
Last active April 4, 2023 23:21
NoMercyPlayer example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NoMercyPlayer API</title>
<script src="./dist/app.js?v=kw4n5l2n45" defer></script>
@StoneyEagle
StoneyEagle / timers.ts
Created March 1, 2023 23:38
Seconds to human time
humanTime (time: string | number) {
time = parseInt(time as string, 10);
let days: any = parseInt(`${(time / (3600 * 24))}`, 10);
let hours: any = this.pad(parseInt(`${(time % 86400) / 3600}`, 10), 2);
let minutes: any = parseInt(`${(time % 3600) / 60}`, 10);
let seconds: any = parseInt(`${time % 60}`, 10);
if (`${minutes}`.length === 1) {
minutes = `0${minutes}`;
@StoneyEagle
StoneyEagle / generateBlurHash.ts
Created January 11, 2023 02:03
Generate BlurHash
const digitCharacters = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
@StoneyEagle
StoneyEagle / trickle.scss
Last active January 11, 2023 12:10
Trickle show images
// image
.trickle-div {
transition: all;
transition-delay: var(--delay1);
transition-duration: 300ms;
}
// itemcontainer
@for $i from 1 to 100 {
.trickle > *:nth-child(#{$i}) {
@StoneyEagle
StoneyEagle / deploy.js
Created November 21, 2022 11:01
Digital Ocean deploy script
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const { readFileSync } = require('fs');
const { Client } = require('node-scp');
const { join } = require('path');
const env = require('dotenv');
env.config();
export const greenToRed = [
{
pct: 0,
color: {
r: 0,
g: 0x40,
b: 0,
},
},
{
@StoneyEagle
StoneyEagle / redux_content_actions.js
Created September 14, 2022 01:00
Redux base template
// ./redux/content/actions.js
import { store } from '..';
import content from './content';
export const setLoading = (payload) => store.dispatch(content.actions.setContentLoading(payload));
export const setError = (payload) => store.dispatch(content.actions.setContentError(payload));
export const setInfo = (payload) => store.dispatch(content.actions.setInfo(payload));
@StoneyEagle
StoneyEagle / loop.jsx
Last active August 17, 2022 23:44
React loop component
import react, {useEffect, useState} from 'react';
function Looper() {
const [number, setNumber] = useState(0);
useEffect(() => {
let newNumber = 0;
const interval = setInterval(() => {