Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>cannon.js - container demo</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
</head>
<body>
<script type="module">
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#ifndef CUDA_H
#define CUDA_H
// https://stackoverflow.com/a/27992604
#ifdef __INTELLISENSE__
@oxyflour
oxyflour / main.sh
Created February 13, 2021 12:08
private docker registry
# https://medium.com/swlh/deploy-your-private-docker-registry-as-a-pod-in-kubernetes-f6a489bf0180
docker run --rm --entrypoint htpasswd registry:2.6.2 -Bbn docker docker > auth/htpasswd
kubectl create secret tls certs-secret --cert=/mnt/d/Programs/nginx-1.17.1/conf/yff.me/fullchain.pem --key=/mnt/d/Programs/nginx-1.17.1/conf/yff.me/privkey.pem
kubectl create secret generic auth-secret --from-file=auth/htpasswd
cat > deploy.yaml << EOF
apiVersion: v1
kind: PersistentVolume
metadata:
name: docker-repo-pv
spec:
@oxyflour
oxyflour / index.js
Last active November 28, 2020 13:43
guacamole lite
import { Client, Keyboard, Mouse, WebSocketTunnel } from 'guacamole-common-js'
async function start() {
const req = await fetch('/token'),
token = await req.text(),
client = new Client(new WebSocketTunnel(`http://localhost:8088/?token=${token}`)),
elem = client.getDisplay().getElement()
document.body.appendChild(elem)
client.connect({ })
import React, { useEffect, useState } from 'react'
import ReactDOM from 'react-dom'
/** @type { (fcs: number[][]) => number[][] } */
function getLoops(fcs) {
/** @type { { [k: string]: number } } */
const faceNum = { }
for (const [a, b, c] of fcs) {
for (const [i, j] of [[a, b], [b, c], [c, a]]) {
const e = [i, j].sort().join('/')
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCdCmF6MD9BTkf5RpZjrz8PlXOUJx4HE4GBXo09OugK4sPMc+Cwzk50IF7EEUum4x3tk7iBNZ6ZeEY4ixx5aep3UKUxbahurEIdi1cD08xcVlrbiu9ziYiHBgoYrXoblbZq2V77SbRUrvjwvfM7TwpavB5M/2dezns1zEZXSHiq9K//ZecatKsyeicQqD2UYo58ISacaTIwYeVtGVQt8ocLgcxC9x7LBUsFZk5d9Kao+AfCGKq/o+HhU64lzD/TDdqBWPVV+hdSa7Qn0bBkeWAzjc5K/erCIFDUEv982miya4sjn92LHWkrU8FY1tP8ZMVBiKT/nDpszM3xszlXSAaD nwsrv@ubuntu
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxOss/1hayQvFBJpl/DkrlS9uXx1VTuVHWz2ETZJ2xd3UfFC/eO9GqQTPWrGiIRGsLJzH4JpgQdpAd+bfdE39XZDFG7idcY6OTg26kejtcOdq4uhDOtoirqq/5WR5mqP1nsKRaBGJYP6lbuLwCXl6/3rjcre30+eehAthkGI0zjh2kL8kVv9IabIpJTdIPbP9Lrr5hEJu8PAzr7Rp9u2+UiDd5LSu8lgej3DDCf+xc11kMTIG1haXBczzikOhRXVCsJYzZ0xfa5z2s43mycpgk+ZR0JpE8qObtq8WT377InTPvPKoKz7oFziKGYfp2EEgJeZnek7F49yKNNTJU4DkB oxyflour@oxyflour-nuc7
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDN5nZFOJ/XrGuVDfuWHiBbc5PRJfZxyuZ/NaBBjpArTULHGelNsfzWTIBnZMnd4OR8CAx6EcPk5YajkgLgRnJNXjYDA0yd3hrcd/b0uxvOLv5AQIrR4+jttyE+zOOMVlrjSpFbSDRE3cN8ElrxKgw51O2i5dkrXOssb9mUw85aCLoRy9hk9kakm3AMJ5
@oxyflour
oxyflour / cuda_utils.h
Last active October 4, 2020 13:52
fit cu
#include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include "cuda_fp16.h"
// https://stackoverflow.com/a/27992604
#ifdef __INTELLISENSE__
typedef struct xyz {
int x;
@oxyflour
oxyflour / main.py
Created September 23, 2020 15:42
async exec batch
import asyncio
async def execBatch(next, exec, concurrency=5):
running = [None] * concurrency
torun = await next([], running)
dones = []
async def schedule():
while len(torun) > 0 or len(dones) > 0 or len([task for task in running if task]) > 0:
if len(dones) > 0:
@oxyflour
oxyflour / main.py
Created September 20, 2020 09:52
simple async ea
import asyncio
from random import random, choices
def clip(x, x0, x1):
return x0 if x < x0 else x1 if x > x1 else x
def make_masks(geneSize, popSize, crossoverNum):
mask0 = [0] * geneSize
mask1 = [int(i / int(geneSize / crossoverNum)) % 2 for i in range(geneSize)]
mask2 = [-x for x in mask1]
@oxyflour
oxyflour / index.js
Created September 19, 2020 17:08
async reduce of array
async function reduce(arr, fn) {
let tasks = arr.map(item => ({ item })),
reqs = []
while (true) {
if (tasks.length === 1) {
return tasks[0].item
}
const toRun = tasks.filter(task => !task.started)
for (let i = 0; i + 1 < toRun.length; i += 2) {
const [a, b] = toRun.slice(i, i + 2)