Skip to content

Instantly share code, notes, and snippets.

Avatar

Aecio Levy aeciolevy

  • Canada
View GitHub Profile
View socket-estop-test.js
const net = require('net');
const client = net.createConnection({ host: '192.168.7.2', port: 9999 });
const delay = time => new Promise(resolve => setTimeout(resolve, time));
client.on('data', (data) => {
data = data.toString().trim();
console.log('data received: ', data);
});
View socket-test.js
const net = require('net');
let isConnected = false;
const delay = time => new Promise(resolve => setTimeout(resolve, time));
const client = net.createConnection({ host: '192.168.7.2', port: '9999' }, () => {
console.log('client connected to machine motion');
isConnected = true;
});
let count = 1;
@aeciolevy
aeciolevy / Example.js
Created Mar 3, 2019
Example of mongoose transaction. MongoDB transaction example
View Example.js
exports.deleteUser = async (req, res, next) {
const session = await mongoose.startSession();
try {
const { id } = req.params;
// Start session
await session.startTransaction();
// deleteMany in this session
const [errorOp, result] = await toAll([App.deleteMany({ user: id }).session(session), UserModel.findByIdAndRemove(id).session(session)]);
if (errorOp) {
throw new ErrorRequest(STATUS_CODE.UNPROCESSABLE, errorOp.message);
@aeciolevy
aeciolevy / .vimrc
Last active Feb 3, 2019
Vim config
View .vimrc
" Load Pathogen Plugin
execute pathogen#infect()
" General
set number " Show line numbers
set linebreak " Break lines at word (requires Wrap lines)
set showbreak=+++ " Wrap-broken line prefix
set textwidth=100 " Line wrap (number of cols)
set showmatch " Highlight matching brace
set hlsearch " Highlight all search results
@aeciolevy
aeciolevy / javascript.json
Created Dec 12, 2018
Javascript Snippet for VS Code
View javascript.json
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1', $2);",
@aeciolevy
aeciolevy / vscodeStyle.css
Last active Nov 11, 2018
Custom style to vscode
View vscodeStyle.css
/*
I decided on the flottflott cursive font for now. Works better for me than FlottFlott.
*/
.mtk7,
.mtk3,
.mtk13,
span.mtk11.mtki {
margin-left: 1px;
font-family: "flottflott";
font-size: 1.5em;
@aeciolevy
aeciolevy / php.ini
Created Mar 19, 2018
PHP configuration to Xdebug in Mac OS with Apache only
View php.ini
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
@aeciolevy
aeciolevy / Singleton.cpp
Last active Apr 4, 2018
Singleton C++ allowing Inheritance
View Singleton.cpp
/* Copyright (C) Aécio Levy
* Written by Aécio Levy - 16/03/2018
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View Sublime-text-preferences.json
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"bold_folder_labels": false,
"color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
"default_encoding": "UTF-8",
"file_exclude_patterns":
[
"*.log"
],