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 / 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 / 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!

# fetch the event, all its tickets and each batch of each ticket
node(node_type: EVENT id:X) {
...on Event {
tickets {
nodes {
batches {
nodes {
price
committed_count
sold_count
@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 / 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 / react-closure-vs-hoc.md
Last active February 11, 2021 10:26
React: Closure x Higher Order Component
const ListItems = [
  { id: 1, address: '/link-one', text: 'Link One' },
  { id: 2, address: '/link-two', text: 'Link Two' },
  { id: 3, address: '/link-three', text: 'Link Three' },
  { id: 4, address: '/link-four', text: 'Link Four' },
  { id: 5, address: '/link-five', text: 'Link Five' }
]
@viniciusCamargo
viniciusCamargo / .gitignore
Last active November 27, 2017 03:51
How to quickly create and deploy an Node.js app to AWS Elastic Beanstalk
node_modules
.elasticbeanstalk
@viniciusCamargo
viniciusCamargo / README.md
Last active February 11, 2021 10:26
atom: Redux-inspired state manager with simpler API
const l = console.log.bind(this)

const _a = atom({ list: [1,2,3,4], bool: false, key: 'value' })

_a.subscribe(() => l(_a.get())) // will log the state on every change

_a.get('key') // 'value'
const { key } = _a.get() // key === { key: 'value' }
@viniciusCamargo
viniciusCamargo / index.js
Last active October 17, 2017 16:59
Postgres 10 installation + Hello World
// npm i pg -S
const { Client } = require('pg')
const client = new Client({ user: 'user', password: '12345' })
const hello = async () => {
await client.connect()
const res = await client.query('SELECT $1::text as message', ['Hello world!'])
@viniciusCamargo
viniciusCamargo / index.js
Created October 11, 2017 20:43
mithril - fetch example
const root1 = document.getElementById('root1')
const root2 = document.getElementById('root2')
const root3 = document.getElementById('root3')
const l = console.log.bind(this)
const api = {
path: 'https://jsonplaceholder.typicode.com',
getPostById(id) {
return m.request({ url: `${this.path}/posts/${id}` })
},