Skip to content

Instantly share code, notes, and snippets.

@ffxsam
ffxsam / Suspense.ts
Last active May 22, 2024 17:48
Vue 3's Suspense component, ready for use in Vue 2.x (TypeScript)
import Vue from 'vue';
export const Suspense = Vue.extend({
name: 'Suspense',
data: () => ({
resolved: false,
}),
async created() {
const setupMethod = (this.$parent as any).setup;
if (!setupMethod) {
@kedevked
kedevked / tfjs-webworker.html
Created March 14, 2019 02:32
use tensorflow.js in a web worker
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script>
const worker_function = () => {
onmessage = () => {
console.log('from web worker')
this.window = this
importScripts('https://cdn.jsdelivr.net/npm/[email protected]/setImmediate.min.js')
importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]')
@sharkySharks
sharkySharks / Dockerfile example - multi-stage build
Last active August 17, 2021 16:19
docker multi stage build with not-root user permissions set
##############################################################
# This file is intended to be used with ./docker-compose.yml #
##############################################################
FROM node:10.14.1-alpine as build
# working directory
WORKDIR /usr/src/app
# global environment setup : yarn + dependencies needed to support node-gyp
RUN apk --no-cache --virtual add \
@rmela
rmela / SQL query results as nodejs read stream
Last active March 24, 2025 13:12
SQLite query results as nodejs readable stream
/*
*
* Return SQLite3 query results as a Nodejs stream, sensitive to backpressure.
*
* Assumes a foo.db file with a lot of rows - I used 1000 with a number & a string
*/
const stream = require('stream');
const sqlite = require('sqlite3');
class DBStream extends stream.Readable {
@vladbat00
vladbat00 / parcel-node-target-hotreload.js
Created May 9, 2018 13:36
Parcel bundler for hotreloading node.js target. Start with `run` argument in order get your index.js running after each rebuild
const Bundler = require('parcel-bundler');
const childProcess = require('child_process');
const file = 'index.js';
const options = {};
const bundler = new Bundler(file, options);
const runBundle = process.argv.includes('run');
let bundle = null;
@phenax
phenax / absolute-import-codemod-transform.js
Created April 16, 2018 12:38
Codemod transform to convert all relative paths to absolute import paths inside src
const path = require('path');
const SOURCE = 'src';
const SOURCE_PATH = path.resolve(SOURCE) + '/';
const removeSourceDirName = path =>
path.replace(new RegExp(`^${SOURCE}\/?`, 'gi'), '');
@andrewwippler
andrewwippler / install kubeadm kubelet kubectl
Last active April 8, 2021 08:46
Installing kubernetes on CentOS 7 minimal (needs to be initialized after run)
# update and install ntp
yum update -y
yum install ntp -y
systemctl enable ntpd --now
# Install crictl, for Cri-o, but did not work with k8s 1.10 as of yet.
curl -L -O https://github.com/kubernetes-incubator/cri-tools/releases/download/v1.0.0-beta.0/crictl-v1.0.0-beta.0-linux-amd64.tar.gz
tar xvf crictl-v1.0.0-beta.0-linux-amd64.tar.gz
# mv crictl /usr/local/bin/crictl
@mib200
mib200 / App.vue
Created March 19, 2018 08:35
A vue mixin to automatically set loading state
<template>
<div id="app">
<button :disabled="loading" @click="triggerAction">Trigger action</button>
<div v-if="loading">Loading....</div>
<div v-else>Not loading</div>
</div>
</template>
<script>
export default {
@CesarCapillas
CesarCapillas / check-elastic-health.sh
Last active July 27, 2023 06:33
ELK shell scripts
#!/bin/bash
ELKSERVER=${1:-localhost}
ELKPORT=${2:-9200}
if [ -z "$ELKSERVER" ]; then
# Usage
echo 'Usage: check-health.sh <elk-server=localhost> <elk-port=9200>'
# create-index.sh "logstash-solr-*"
else
curl -s "http://$ELKSERVER:$ELKPORT/_cat/health?v"
import numpy as np
import cv2
import dlib
from scipy.spatial import distance as dist
from scipy.spatial import ConvexHull
PREDICTOR_PATH = "../data/dlib_models/shape_predictor_68_face_landmarks.dat"
FULL_POINTS = list(range(0, 68))
FACE_POINTS = list(range(17, 68))