Skip to content

Instantly share code, notes, and snippets.

View lucianmachado's full-sized avatar
:octocat:

Lucian lucianmachado

:octocat:
  • 06:29 (UTC -03:00)
View GitHub Profile
@lucianmachado
lucianmachado / nc
Created June 23, 2015 22:12
NetCat Usage Tips
http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/
One of the Linux command line tools I had initially under-estimated is netcat or just nc. By default, netcat creates a TCP socket either in listening mode (server socket) or a socket that is used in order to connect to a server (client mode). Actually, netcat does not care whether the socket is meant to be a server or a client. All it does is to take the data from stdin and transfer it to the other end across the network.
The simplest example of its usage is to create a server-client chat system. Although this is a very primitive way to chat, it shows how netcat works. In the following examples it is assumed that the machine that creates the listening socket (server) has the 192.168.0.1 IP address. So, create the chat server on this machine and set it to listen to 3333 TCP port:
$ nc -l 3333
On the other end, connect to the server with the following:
#include <glob.h>
#include <vector>
#include <string>
inline std::vector<std::string> glob(const std::string& pat){
using namespace std;
glob_t glob_result;
glob(pat.c_str(),GLOB_TILDE,NULL,&glob_result);
vector<string> ret;
for(unsigned int i=0;i<glob_result.gl_pathc;++i){
ret.push_back(string(glob_result.gl_pathv[i]));
@lucianmachado
lucianmachado / 0_reuse_code.js
Created November 26, 2015 17:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/bin/bash
# ----------------------------------------------------------------------------
# Gerador e Validador de CPF em Shell Script (Bash)
#
# Uso: cpf [cpf]
# Ex.: cpf 552.056.731-09 # pode utilizar assim
# cpf 55205673109 # pode utilizar assim
# cpf # gera um CPF válido
#
# Autor: Marcos da B. M. Oliveira , http://www.terminalroot.com.br/
@lucianmachado
lucianmachado / wildfly-toolbelt.md
Created May 11, 2016 04:44 — forked from sebastianwebber/wildfly-toolbelt.md
Wildfly administration tips

#Wildfly Toolbelt

Deploy Related

Find domain deployments in filesystem

Basically, you need to open domain.xml under WILDFLY_HOME/domain/configuration and find the <deployments> session. In that session, each deployment contain a <content> tag. The attribute sha1 contains details where the file is storaged on the filesystem. EG:

<deployments>
 
@lucianmachado
lucianmachado / gist:1586fa1313316d5d56926413eaa130fa
Created May 22, 2017 18:52 — forked from danielbaccin/gist:2499371
comando uteis para config do oracle
Comandos uteis do oracle para obter configiurações:
Parâmetros da NLS:
=> Select * from nls_database_parameters
=> Select * from nls_session_parameters
=> Select * from nls_instance_parameters
Exibe os valores de database_parameters
=> SELECT name,value$ from sys.props$ where name like '%NLS_LANG%'
=> SELECT name,value$ from sys.props$ where name like '%NLS_CHAR%'
=> SELECT name,value$ from sys.props$ where name like '%_CHARACTER%'
@lucianmachado
lucianmachado / webtail.py
Created September 12, 2018 16:25 — forked from Henningstone/webtail.py
HTTP server that provides a web interface to run "tail" on a file, like the Unix command
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
HTTP server that provides a web interface to run "tail" on a file,
like the Unix command.
This is a standalone script. No external dependencies required.
How to invoke:
@lucianmachado
lucianmachado / google-login.html
Created September 13, 2018 13:12
Google Sign in snippet
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<div style="padding-top:20px" ><a href="#" onclick="signOut();">Sign out</a></div>
@lucianmachado
lucianmachado / node_socket_http.js
Created October 5, 2018 17:51
Socket Nodejs HTTP Output
var net = require('net');
const OUTPUT = "<html><head><title>Example</title></head><body><p>Worked!!!</p></body></html>";
const OUTPUT_HEADERS = "HTTP/1.1 200 OK\r\n" +
"Content-Type: text/html\r\n" +
"Content-Length: ";
const OUTPUT_END_OF_HEADERS = "\r\n\r\n";
var server = net.createServer(function(socket) {
socket.write(OUTPUT_HEADERS + OUTPUT.length + OUTPUT_END_OF_HEADERS + OUTPUT);
@lucianmachado
lucianmachado / RESTdoc
Created February 6, 2019 03:06 — forked from coderofsalvation/RESTdoc
Quickndirty bash-utility to generate REST-documentation from sourcecode comments into css-styles html (or plainhtml). Can be handy for inclusion into phpdoc/phpdoctor/doxygen-dochains, instead of using heavyweight alternatives.
#!/bin/bash
#
# A quickndirty bash-utility to generate REST-documentation from sourcecode comments.
# (initially aimed at php-files, but js should also work)
# Basically its a c-style comment -> markdown -> html converter
# Dependancies:
# - awk
# - sed
# - bash
# - php