Skip to content

Instantly share code, notes, and snippets.

View gabrielqmatos88's full-sized avatar

Gabriel Q. Matos gabrielqmatos88

  • Manaus, Am, Brasil
View GitHub Profile
@gabrielqmatos88
gabrielqmatos88 / wildcard-to-regexp.js
Created November 4, 2022 01:02 — forked from donmccurdy/wildcard-to-regexp.js
Wildcard and glob matching in JavaScript.
/**
* Creates a RegExp from the given string, converting asterisks to .* expressions,
* and escaping all other characters.
*/
function wildcardToRegExp (s) {
return new RegExp('^' + s.split(/\*+/).map(regExpEscape).join('.*') + '$');
}
/**
* RegExp-escapes all characters in the given string.
@gabrielqmatos88
gabrielqmatos88 / pubsub.js
Created September 13, 2020 15:33 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@gabrielqmatos88
gabrielqmatos88 / mongo.bash
Created June 11, 2018 18:04 — forked from iwatakeshi/mongo.bash
Create a Windows service for MongoDB
# Create directories
mkdir c:\mongo\db
mkdir c:\mongo\config
mkdir c:\mongo\log
# Create a configuration file
# in c:\mongo\config\ as
# 'mongod.cfg' and paste:
#|==================================|
#| logpath=C:\mongo\log\mongodb.log |
@gabrielqmatos88
gabrielqmatos88 / background.js
Created July 26, 2017 22:39 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@gabrielqmatos88
gabrielqmatos88 / chat_server.pl
Created November 16, 2016 13:35 — forked from chankeypathak/chat_server.pl
Simple chat server in perl
#!/usr/bin/perl -w
# chat_server.pl
use strict;
use IO::Socket::INET;
my $port = shift or die "Port required!\n";
my $socket = IO::Socket::INET->new(
LocalPort => $port,
Proto => 'tcp',
Listen => SOMAXCONN
@gabrielqmatos88
gabrielqmatos88 / chat_client.pl
Created November 16, 2016 13:34 — forked from chankeypathak/chat_client.pl
Simple chat client in Perl
#!/usr/bin/perl -w
# chat_client.pl
use strict;
use IO::Socket::INET;
my $port = shift or die "No port\n";
my $server = shift or die "No server\n";
my $client_socket = IO::Socket::INET->new(
PeerPort => $port,
PeerAddr => $server,
@gabrielqmatos88
gabrielqmatos88 / AngularJS Provider Test Example
Created March 11, 2016 21:35 — forked from cesarandreu/AngularJS Provider Test Example
Example of how you can test your AngularJS providers.
Look at the README.