Skip to content

Instantly share code, notes, and snippets.

@karim23657
karim23657 / downsample.bat
Created May 24, 2024 15:40 — forked from nathanchere/downsample.bat
Downsample mp4s in directory to 360p with ffmpeg
for %%f in (*.mp4) do call ffmpeg -i "%%~nf.mp4" -vcodec libx264 -vf scale=-1:360 -r 12 -preset fast -acodec copy "%%~nf.360p.mp4"
# coding:utf-8
# author LuShan
# version : 1.1.9
import json
# import urllib3
import logging
import random
import re
import requests
from urllib.parse import quote
@karim23657
karim23657 / gas.js
Created February 8, 2024 06:58 — forked from Googlefan256/gas.js
Gasでgoogle translateを自動言語検知ありで使えるやつです
function translate(text, from = "auto", to) {
try {
const result = UrlFetchApp.fetch(
"https://translate.google.com/_/TranslateWebserverUi/data/batchexecute",
{
payload:
"f.req=" +
encodeURIComponent(
JSON.stringify([
[
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>body {
font-family: Arial, sans-serif;
}
h1 {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
</style>
</head>

Get script base path fron code

// window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf('/')) + '/'
document.currentScript.src.toString().substring(0, document.currentScript.src.toString().lastIndexOf('/'))+ '/'

if path of js file is https://cdn.jsdelivr.net/npm/bbb/mmm.js it returns https://cdn.jsdelivr.net/npm/bbb/

function getScriptFileName() {
 return (new Error).fileName;
@karim23657
karim23657 / javascript-human-readable.md
Created December 24, 2022 15:17
javascript human readable code snippets
@karim23657
karim23657 / index.html
Created November 16, 2022 09:00 — forked from KentaYamada/index.html
Python Flask + JavaScript XMLHttpRequest
<!DOCTYPE html>
<html>
<head>
<title>Practice AJAX</title>
<script type="text/javascript">
function do_ajax() {
var req = new XMLHttpRequest();
var result = document.getElementById('result');
req.onreadystatechange = function()
{
@karim23657
karim23657 / Drawing board for colab notebook.md
Last active September 17, 2022 07:58
Drawing on Google Colab

You can draw something and pass image to your code.

drag and drop image loading supported.

Usage:

from base64 import b64decode
from IPython.display import HTML, Image
from google.colab.output import eval_js
import urllib.request
board_html = urllib.request.urlopen('https://gist.githubusercontent.com/karim23657/5ad5e067c1684dbc76c93bd88bf6fa53/raw/2ef57f881bc700c2c346bd6c7a7f2d5364b21048/drawing%2520board.html').read().decode('utf-8')