Skip to content

Instantly share code, notes, and snippets.

View jmf-player.html
<script type="text/javascript">
// On creer le player
const player = document.createElement('audio')
// Un peu de style pour indiquer d'afficher le player en bas a droite
player.style.display = 'none'
player.style.position = 'fixed'
player.style.bottom = '6px'
player.style.right = '6px'
View all-with-concurrency.js
const allLimited = (actions, { delay = 0, concurrency = 1 }) =>
new Promise((s, f) => {
let i = -1
const end = actions.length
const result = Array(end)
const delayed = delay && (fn => setTimeout(fn, delay))
async function next(x) {
if (x >= end) return x - end >= concurrency && s(result)
try {
const pause = delay && new Promise(delayed)
@kigiri
kigiri / emoji.html
Created May 11, 2021
favicon emoji
View emoji.html
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>👕</text></svg>">
View minimal-discord-deno-connection.js
const ws = new WebSocket(`wss://gateway.discord.gg/?v=8&encoding=json`)
const ONCE = {}
const ON = {}
let s = null
let heartbeatAc
const heartbeat = () => {
console.log('heartbeat')
heartbeatAc = setTimeout(() => {
console.log('the client was ZOMBIFED')
View bootstrap-windows.js
import { readFileStr } from 'https://deno.land/std@v1.0.0-rc1/fs/read_file_str.ts'
import { writeFileStr } from 'https://deno.land/std@v1.0.0-rc1/fs/write_file_str.ts'
const toUTF8 = buff => {
const decoder = new TextDecoder()
return decoder.decode(buff)
}
export const bootstrap = async ({ debug = false } = {}) => {
const pid = await readFileStr('.pid')
@kigiri
kigiri / izidom.js
Last active Aug 25, 2020
frameworkless workflow spa pwa serverless JSON blockchain
View izidom.js
const append = (p, ...n) => (p.append(...n.flat()), p)
const create = new Proxy((t,...c)=>append(Object.assign(document.createElement(t),c[0]&&c[0]==Object?c.shift():void 0),...c),{get:(f,t)=>(...c)=>f(t,...c)})
View replace-numbers.js
import { readFileStr, writeFileStr } from 'https://deno.land/std/fs/mod.ts'
const ext = `.${Deno.args[0] || 'txt'}`.replace(/^\.\.+/, '.')
const filenames = (await Deno.readdir('.'))
.map(file => file.name)
.filter(name => name.endsWith(ext))
.filter(name => !name.endsWith(`-replaced${ext}`))
const work = filenames.map(async name => {
const text = await readFileStr(name)
@kigiri
kigiri / functions.js
Last active Apr 6, 2020
Synchronise time across clients & server
View functions.js
const functions = require('firebase-functions')
const cors = res => {
res.setHeader('Timing-Allow-Origin', 'https://nice-timer.web.app')
res.setHeader('Access-Control-Allow-Origin', 'https://nice-timer.web.app')
res.setHeader('Access-Control-Allow-Methods', 'GET,HEAD,OPTIONS')
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
return res
}
exports.now = functions.https.onRequest((_, res) => cors(res).send(`${Date.now()}`))
View sound2wav.js
const parseNote = noteStr => {
const [ note, rest = '' ] = noteStr.split('.')
const duration = durations[rest.slice(0, -1)] / tempo
return {
duration,
frequency: notes[note],
type: types[rest[rest.length - 1]] || types[0],
}
}
@kigiri
kigiri / tbp-top-100-movies.txt
Last active Mar 23, 2020
ThePirateBay - top 100 of the 23/05/2020 as a JSON dataset
View tbp-top-100-movies.txt
(HD - Movies) Birds.Of.Prey.2020.1080p.WEBRip.x264.AAC5.1-MP4, Uploaded Y-day 06:49, Size 2.01 GiB, ULed by MrStark
(HD - Movies) The.Invisible.Man.2020.1080p.WEBRip.x264.AAC5.1-MP4, Uploaded 03-20 17:45, Size 2.29 GiB, ULed by MrStark
(HD - Movies) The.Invisible.Man.2020.720p.WEBRip.x264.AAC2.0-MP4, Uploaded 03-20 15:43, Size 1.12 GiB, ULed by MrStark
(HD - Movies) Onward.2020.720p.WEBRip.x264.AAC2.0-MP4, Uploaded 03-21 21:06, Size 939.84 MiB, ULed by MrStark
(HD - Movies) Contagion.2011.1080p.BRRip.x264.AAC5.1-MP4, Uploaded 03-20 16:35, Size 1.89 GiB, ULed by MrStark
(HD - Movies) Star.Wars.Episode.IX.The.Rise.Of.Skywalker.2019.1080p.BRRip.x264, Uploaded 03-16 08:29, Size 2.61 GiB, ULed by MrStark
(HD - Movies) Contagion.2011.720p.BRRip.x264.AAC2.0-MP4, Uploaded 03-20 16:34, Size 978.29 MiB, ULed by MrStark
(HD - Movies) Parasite.2019.1080p.HDRip.X264.AC3-EVO[TGx], Uploaded 08-16 2019, Size 2.8 GiB, ULed by sotnikam
(HD - Movies) Jumanji.The.Next.Level.2019.720p.BRRip.x264.AAC2.0-MP4, Uploaded 03-01