Skip to content

Instantly share code, notes, and snippets.

View JonathanLoscalzo's full-sized avatar

Jonathan Loscalzo JonathanLoscalzo

View GitHub Profile
@JonathanLoscalzo
JonathanLoscalzo / Sample.cs
Created March 31, 2018 01:39 — forked from marisks/Sample.cs
Improved Jimmy Bogard's ValueObject<T> which supports inheritance
// Ordinary
public class SimpleDto : ValueObject<SimpleDto>
{
public string Value { get; set; }
}
// With base class
public abstract class BaseDto<T> : ValueObject<T>
{
public string BaseValue { get; set; }

Often referred to as the "swiss army of knife" for TCP/IP networking, [Netcat][1] is an extremely versatile Linux utility that allows you to do anything under the sun using TCP/UDP sockets. It is one of the most favorite tools for system admins when they need to do networking related troubleshooting and experimentation.

In this tutorial, I am sharing a few useful netcat examples, although the sky is the limit when it comes to possible netcat use cases. If you are using netcat regularly, feel free to share your use case.

Note that when you are binding to well-known ports (0-1023) with nc, you need root privilege. Otherwise, run nc as a normal user.

1. Test if a particular TCP port of a remote host is open.

$ nc -vn 192.168.233.208 5000
using System;
class DateTimeRange : ValueObject<DateTimeRange>
{
public DateTime Start { get; }
public DateTime End { get; }
public DateTimeRange(DateTime start, DateTime end)
{
Start = start;
@JonathanLoscalzo
JonathanLoscalzo / correctuse-example-2.js
Created June 18, 2018 12:27 — forked from itaditya/correctuse-example-2.js
Snippet for Avoiding the async/await hell medium article
async function orderItems() {
const items = await getCartItems() // async call
const noOfItems = items.length
const promises = []
for(var i = 0; i < noOfItems; i++) {
const orderPromise = sendRequest(items[i]) // async call
promises.push(orderPromise) // sync call
}
await Promise.all(promises) // async call
}
@JonathanLoscalzo
JonathanLoscalzo / gist:ff2f1ec1a9bf1422eb18482eae23cddf
Created July 19, 2018 18:27 — forked from julianlam/expose-directory-on-host-to-lxc-container.md
Exposing a directory on the host machine to an LXC container

Exposing a directory on the host machine to an LXC container

  1. Log into the container and create an empty directory, this will be the mount point
  2. Log out and stop the container.
  3. Open to your container's config file
    • For regular LXC containers: /var/lib/lxc/mycontainer/config
    • For unprivileged LXC containers: $HOME/.local/share/lxc/mycontainer/config
  4. Add a new line above the lxc.mount directive, that follows the format below. Substitute proper paths as necessary:
    • lxc.mount.entry = /path/to/folder/on/host /path/to/mount/point none bind 0 0
  • Both of these paths are relative to the host machine.
@JonathanLoscalzo
JonathanLoscalzo / paginated.js
Created September 2, 2018 00:01 — forked from jstott/paginated.js
lodash paginated items
function getPaginatedItems(items, page, pageSize) {
var pg = page || 1,
pgSize = pageSize || 100,
offset = (pg - 1) * pgSize,
pagedItems = _.drop(items, offset).slice(0, pgSize);
return {
page: pg,
pageSize: pgSize,
total: items.length,
total_pages: Math.ceil(items.length / pgSize),
@JonathanLoscalzo
JonathanLoscalzo / PConcurrente.md
Last active February 8, 2019 00:54 — forked from Titinx/PConcurrente.md
Apuntes Concurrente

Programación Concurrente 2015

Apuntes de Programación Concurrente, Facultad de Informatica, UNLP. Promoción teorica 2015 - febrero.

Teoria 1

##Qué es la concurrencia?

from sklearn.datasets import *
from sklearn import tree
import graphviz
wine = load_wine()
clf = tree.DecisionTreeClassifier() # init the tree
clf = clf.fit(wine.data, wine.target) # train the tree
# export the learned decision tree
dot_data = tree.export_graphviz(clf, out_file=None,
feature_names=wine.feature_names,
from sklearn.datasets import *
from sklearn import tree
from sklearn.metrics import roc_curve, auc
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import label_binarize
n_classes = 3
wine = load_wine()
clf = tree.DecisionTreeClassifier()