Skip to content

Instantly share code, notes, and snippets.

View catarak's full-sized avatar
🌈
it's a unix system, i know this

Cassie Tarakajian catarak

🌈
it's a unix system, i know this
View GitHub Profile
@catarak
catarak / packetSniffer.js
Created March 19, 2020 18:51
Node <=> Max Packet Sniffer Example
const pcap = require('pcap');
const maxApi = require('maxApi');
const tcp_tracker = new pcap.TCP_tracker(),
const pcap_session = pcap.createSession("", "tcp");
tcp_tracker.on('start', function (session) {
console.log("Start of TCP session between " + session.src_name + " and " + session.dst_name);
});
@catarak
catarak / privacy_policy.md
Last active June 18, 2020 22:53
Privacy Policy

Who We Are and What This Policy Covers

We are the folks at Processing Foundation, on a mission to promote software literacy within the visual arts, and visual literacy within technology-related fields. This Privacy Policy applies to information that we collect about you when you use the p5.js Web Editor (editor.p5js.org).

Throughout this Privacy Policy we’ll refer to the editor.p5js.org as the “Service.” Below we explain how we collect, use, and share information about you, along with the choices that you have with respect to that information.

This Privacy Policy is a customized version of the open source Privacy Policy created and maintained by Automattic. Feel free to repurpose it for your own use!

Information We Collect

Terms of Service

The Gist

We (the folks at Processing Foundation) have a mission to promote software literacy within the visual arts, and visual literacy within technology-related fields. We do this by developing and distributing a group of related software projects, which includes Processing (Java), p5.js (JavaScript), and Processing.py (Python), and facilitating partnerships and collaborations with allied organizations and individuals, to build a more diverse community around software and the arts. We also maintain this Service, the p5.js Web Editor (editor.p5js.org). These Terms of Service (“Terms”) describe our commitments to you, and your rights and responsibilities when using the p5.js Web Editor. Please read them carefully and reach out to us if you have any questions.

This Terms of Service is customized version of the open source Terms of Service created and maintained by Automattic,

// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Define search commands. Depends on dialog.js or another
// implementation of the openDialog method.
// Replace works a little oddly -- it will do the replace on the next
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
// replace by making sure the match is no longer selected when hitting
// Ctrl-G.
// Partial Express.js API for accessing microservices from front end dashboard
// ...
app.get('/api/tmstocsv/info', (req, res) => {
seneca.act('role:tmstocsv,cmd:info').then((info) => {
res.json(info);
});
});
app.get('/api/tmstocsv/run', (req, res) => {
seneca.act('role:tmstocsv,cmd:run').then(() => {
// An example of one of our microservices - handles importing to Elasticsearch
class ESCollection extends UpdateEmitter {
get status() {
// should return a JSON object which is passed along with the websocket event
}
syncESWithCSV(csvName) {
this.started(); // emits 'started' event to any front-end listening for it
// do stuff to load CSV to Elasticsearch
this.progress(); // emits 'progress' event with the status
const EventEmitter = require('events');
/**
* Subclass to add `started`, `progress` and `completed` functions. Then, just implement
* the `status` getter that returns an object describing the status of your object. Long
* running objects like {@link TMSExporter} subclass this class to send updates as they run.
* @interface
* @global
*/
class UpdateEmitter extends EventEmitter {
const io = require('socket.io-client');
/**
* Forwards updates from a subclass of {@link UpdateEmitter} to a websocket
* @global
* @param {string} name - Name string to be send with each {@link UpdateEmitter#status} event
* @param {number} port - Websocket port to which to connect and forward events
* @param {UpdateEmitter} updateEmitter - Concrete subclass of {@link UpdateEmitter}
*/
class WebsocketUpdater {
@catarak
catarak / api.js
Last active April 25, 2017 02:44
module.exports = function api(options) {
var validActions = { add:'add' }
this.add('role:api,path:todo', function (msg, respond) {
var action = msg.args.params.action;
var todoText = msg.args.body.text;
this.act('role:todo', {
cmd: validActions[action], // do this to prevent injection attacks
text: text,
var SenecaWeb = require('seneca-web')
var express = require('express');
var Router = express.Router;
var context = new Router();
var senecaWebConfig = {
context: context,
adapter: require('seneca-web-adapter-express'),
options: { parseBody: false } // if you want to use body parser, put this in
};