Skip to content

Instantly share code, notes, and snippets.

View viniciusCamargo's full-sized avatar
🧙‍♂️

Vinicius de Sousa Camargo viniciusCamargo

🧙‍♂️
View GitHub Profile
@viniciusCamargo
viniciusCamargo / mta.js
Created August 2, 2017 13:44
MTA GTFS Real Time Proto Decoder
const Proto = require('protobufjs');
const Req = require('request');
var GtfsRealtimeBindings = require('gtfs-realtime-bindings');
const MTA_API_ENDPOINT = "http://datamine.mta.info/mta_esi.php?key=148133e77dd93f66b37d6c5054684401&feed_id=1"
Req({
method: 'GET',
url: MTA_API_ENDPOINT,
encoding: null
@viniciusCamargo
viniciusCamargo / connect.js
Created December 25, 2017 18:52 — forked from gaearon/connect.js
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@viniciusCamargo
viniciusCamargo / gist:16e3af93e4e5601366a34e98db23d362
Last active January 6, 2018 21:17 — forked from mikeal/gist:1840641
get a new/clean port with node.js
const net = require('net')
let portRange = 3000
const getPort = (cb) => {
const port = portRange
portRange += 1
const server = net.createServer()
@viniciusCamargo
viniciusCamargo / getting-started.md
Created March 13, 2018 17:14 — forked from joepie91/getting-started.md
Getting started with Node.js

"How do I get started with Node?" is a commonly heard question in #Node.js. This gist is an attempt to compile some of the answers to that question. It's a perpetual work-in-progress.

And if this list didn't quite answer your questions, I'm available for tutoring and code review! A donation is also welcome :)

Setting expectations

Before you get started learning about JavaScript and Node.js, there's one very important article you need to read: Teach Yourself Programming in Ten Years.

Understand that it's going to take time to learn Node.js, just like it would take time to learn any other specialized topic - and that you're not going to learn effectively just by reading things, or following tutorials or courses. _Get out there and build things!

@viniciusCamargo
viniciusCamargo / LICENSE.txt
Created June 12, 2018 01:47 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@viniciusCamargo
viniciusCamargo / CMakeLists.txt
Created November 22, 2018 18:04 — forked from fracek/CMakeLists.txt
CMake and GTK+ 3
# Set the name and the supported language of the project
PROJECT(hello-world C)
# Set the minimum version of cmake required to build this project
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Use the package PkgConfig to detect GTK+ headers/library files
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
# Setup CMake to use GTK+, tell the compiler where to look for headers
@viniciusCamargo
viniciusCamargo / fastapi_websocket_redis_pubsub.py
Created December 25, 2020 21:36 — forked from timhughes/fastapi_websocket_redis_pubsub.py
FastAPI Websocket Bidirectional Redis PubSub
"""
Usage:
Make sure that redis is running on localhost (or adjust the url)
Install uvicorn or some other asgi server https://asgi.readthedocs.io/en/latest/implementations.html
pip install -u uvicorn
Install dependencies
@viniciusCamargo
viniciusCamargo / multiple_ssh_setting.md
Last active August 3, 2023 00:01 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different Github accounts

github multiple keys

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/{private_key}
$ git clone git@{alias}:{github_user}/{repo}.git

~/.ssh/config

@viniciusCamargo
viniciusCamargo / token-generator.js
Created February 4, 2021 23:53 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
const express = require('express');
const { html, Component } = require('htm/preact');
const renderToString = require('preact-render-to-string');
class App extends Component {
render(props) {
return html`
<div class="app">
<h1>This is an app</h1>
<p>Current server time: ${new Date + ''}</p>