Skip to content

Instantly share code, notes, and snippets.

View apocas's full-sized avatar

Pedro Dias apocas

  • PTisp / team.blue
  • Portugal
  • 06:23 (UTC +01:00)
  • X @pedromdias
View GitHub Profile
strings '/Applications/Docker.app/Contents/MacOS/Docker Desktop.app/Contents/Resources/app.asar' | grep 'Pedro Dias' -a3 -b3
@apocas
apocas / vic_v1.ino
Created August 3, 2020 22:06
Cherokee VIC Arduino example
#include <LiquidCrystal.h>
#define pinDriverDoor 30
#define pinPassengerDoor 31
#define pinRearRightDoor 32
#define pinRearLeftDoor 33
#define pinRearDoor 34
#define pinOil 35
#define pinWater 36
#define pinWasher 37
@apocas
apocas / tensorflow_node.js
Last active September 19, 2022 21:57
Tensorflow Nodejs example. Read an image from file, detect objects and save a new image with bounding boxes drawn. 100% server side no browser code.
const tf = require('@tensorflow/tfjs-node')
//const tf = require('@tensorflow/tfjs-node-gpu')
const cocossd = require('@tensorflow-models/coco-ssd');
const fs = require('fs');
const gm = require('gm');
var path = 'image.jpg';
@apocas
apocas / nodev4centos6.sh
Last active March 6, 2017 16:40
Compiling Nodejs v4 in Centos 6
#!/bin/bash
#Nodejs v4.x needs gcc v4.8, Centos 6 comes with gcc v.4.4.
#devtools-2 comes already bundled with v4.8
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install -y devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
scl enable devtoolset-2 bash
wget https://nodejs.org/dist/latest/node-v4.0.0-linux-x64.tar.gz
tar -zxvf node-v4.0.0-linux-x64.tar.gz
@apocas
apocas / one_vnc_token.js
Last active August 29, 2015 14:24
Opennebula VNC token
//fetching/scraping'ish the VNC token for a VM
request.post({
'url': host + '/login',
'auth': {
'user': username,
'pass': password,
'sendImmediately': true
}
}, function(err, res, body) {
#include "DHT.h"
#define DHTPIN 8
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
@apocas
apocas / gist:51d15100ee882fda5f92
Last active August 29, 2015 14:02
LXJS 2014 CSV Workshops Importer
var csv = require('ya-csv'),
github = require('octonode');
var client = github.client({
username: 'apocas',
password: 'xxxxxxxx'
});
var reader = csv.createCsvFileReader('lxjs.csv', {'columnsFromHeader':true, 'separator': ','});
@apocas
apocas / docker_weird
Last active December 20, 2015 17:39
docker rare bug in ~37k containers this happens ~20 times. container was created using remote api, when it sent a start request it received a 404 container does not exist.
root@research:~/nodechecker-engine# docker ps -a
ID IMAGE COMMAND CREATED STATUS PORTS
f4748f971abd apocas/nodechecker:latest bash -c ulimit -m 30 9 minutes ago Exit 0
25ccf9351662 apocas/nodechecker:latest bash -c ulimit -m 30 10 minutes ago Exit 137
root@research:~/nodechecker-engine# docker start f4748f971abd
Error: No such container: f4748f971abd
############################
NOW USING FULL IDS (SAME RESULT)
@apocas
apocas / connectionpool.js
Last active February 3, 2018 19:48
Node,js SSH2 connection pool
var ConnectionPool = function (connection) {
this.connection = connection;
this.queue = [];
this.counter = 0;
this.running = false;
};
ConnectionPool.prototype.start = function () {
var self = this;
if (!this.running) {
@apocas
apocas / gist:4583334
Last active November 26, 2017 12:05
Node NPM registry crawler.
var jsdom = require('jsdom'),
request = require('request'),
url = require('url'),
npm = require("npm"),
redis = require("redis");
var client = redis.createClient();
var configObject = {
"dev": false,