Skip to content

Instantly share code, notes, and snippets.

View thecotne's full-sized avatar

Tsotne Nazarashvili thecotne

  • Tbilisi, Georgia
View GitHub Profile
import { serve } from '@hono/node-server'
import { serveStatic } from '@hono/node-server/serve-static'
import { getCertificate } from '@vitejs/plugin-basic-ssl'
import { Hono } from 'hono'
import assert from 'node:assert'
import fs from 'node:fs/promises'
import { createServer } from 'node:https'
import path from 'node:path'
import { loadEnv } from 'vite'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
function fit ([wi, hi], [ws, hs]) {
const ri = wi / hi
const rs = ws / hs
return rs > ri ? [wi * hs / hi, hs] : [ws, hi * ws / wi]
}
// usage
const [width, height] = fit([16, 9], [2560, 1600])
@thecotne
thecotne / toUpperCase.js
Last active June 15, 2020 21:01
toUpperCase without fucking georgian text
function toUpperCase (text) {
return Array.prototype.map.call(text, char => /[ა-ჰ]/.test(char) ? char : char.toUpperCase()).join('')
}
@thecotne
thecotne / pornhub-fullscreen.js
Last active March 11, 2021 09:55
pornhub fullscreen on orientation change avoiding "API can only be initiated by a user gesture." warning
if(('orientation' in screen) && !player.settings.embeds.enabled) {
screen.orientation.addEventListener('change', function (e) {
if (screen.orientation.type === 'landscape-primary' || screen.orientation.type === 'landscape-secondary') {
player.fullscreen.enter();
} else {
player.fullscreen.exit();
}
e.preventDefault();
e.stopPropagation();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thecotne
thecotne / subl-project
Created November 28, 2015 11:09
open sublime text project with fzf from terminal
#!/usr/bin/bash
proj="$(find ~/Projects/*.sublime-project -printf '%f\n' | awk 'match($0, /^(.+)\./, a) {print a[1]}' | fzf)"
if [ $proj ]
then
subl --project ~/Projects/$proj.sublime-project
fi
@thecotne
thecotne / fun_func.js
Created June 24, 2014 07:26
javascript function with defoult params
function f(func){
var func_str = func.toString();
var params = func_str.match(/\((.+)\)/)[1].split(',');
var params_str = '';
for(var key in params){
var parsed_param = params[key].match(/(.+)(\/\*)(.+)(\*\/)/);
params_str += "var "+parsed_param[1]+"= (typeof "+parsed_param[1]+" == 'undefined' )?"+parsed_param[3]+":"+parsed_param[1]+";\n";
}
func_str = func_str.replace(/\{/, '{\n\t' + params_str);
eval("var fun = "+func_str);