Skip to content

Instantly share code, notes, and snippets.

import robot from "robotjs";
import { Command } from 'commander';
const program = new Command();
program
.option('-n, --number <number>', 'specify numbers');
program.parse();
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

live test: https://livelab.glitches.me/

$ sudo nano /etc/nginx/sites-available/livelab.glitches.me 
server {
    root /usr/share/nginx/livelab.glitches.me;
    index index.html index.htm;

 error_page 502 /502.html;
@micuat
micuat / sketch.ipynb
Created July 16, 2022 18:11
p5pylivecode
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <Wire.h>
#include "Adafruit_MPR121.h"
#ifndef _BV
#define _BV(bit) (1 << (bit))
#endif
// You can have up to 4 on one i2c bus but one is enough for testing!
Adafruit_MPR121 cap = Adafruit_MPR121();
//https://refactorman.com/2015/04/28/exploring-the-dct-part-i/
var dct = function (input) {
var output = [], v, u, x, y, sum, val, au, av;
for (v = 0; v < 8; v++) {
output.push([])
for (u = 0; u < 8; u++) {
sum = 0;
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
val = input[y][x];
@micuat
micuat / index.js
Created April 29, 2022 20:40
twitter hashtag+image crawler
const fs = require('fs');
require("dotenv").config();
const Twitter = require('twitter');
const twitter = new Twitter({
consumer_key: process.env.TW_CKEY,
consumer_secret: process.env.TW_CSECRET,
access_token_key: process.env.TW_ATKEY,
access_token_secret: process.env.TW_ATSECRET
s = new WebSocket('wss://192.168.0.129/piezo');
var dd=0
s.onmessage=msg=>{
let d = msg.data.split(",").map(e=>e*1)
dd = Math.max(...d)/4096
}
d=0
update=()=>d=d*.9+dd*.1
shape().scale(()=>d*10+0.001).out()
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// These constants won't change. They're used to give names to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
// Detects interest points between two images and matches them together.
// These matches are shown by drawing a line between the matching features in each images.
import boofcv.processing.*;
import boofcv.struct.image.*;
import boofcv.struct.feature.*;
import georegression.struct.point.*;
import java.util.*;
import boofcv.factory.feature.associate.ConfigAssociateGreedy;
/*
xtra_webcam
You via your webcam on the scope!
mouseX - threshold
mouseY - threshold distance
» Requires OpenCV for Processing + Video libraries
cc teddavis.org 2017
*/