Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
chris-ramon / gist:570bc21008a22544134fd285f59f6d20
Created Jun 18, 2020 — forked from moraes/gist:2141121
LIFO Stack and FIFO Queue in golang
View gist:570bc21008a22544134fd285f59f6d20
package main
import (
"fmt"
)
type Node struct {
Value int
}
@chris-ramon
chris-ramon / ordered_serially_execution.go
Created Feb 5, 2020
github.com/graphql-go ordered serially execution
View ordered_serially_execution.go
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/graphql-go/graphql"
)
@chris-ramon
chris-ramon / tmux.md
Created Nov 2, 2019 — forked from Bekbolatov/tmux.md
Clean tmux cheat-sheet
View tmux.md

Clean tmux cheat-sheet

By resources

sessions

list-sessions        ls         -- List sessions managed by server
new-session          new        -- Create a new session
@chris-ramon
chris-ramon / StripeCardsSection.js
Created Apr 12, 2019 — forked from lfalke/StripeCardsSection.js
Usage of react-stripe-elements with Material UI (v1.0) styling
View StripeCardsSection.js
import React, { PureComponent } from 'react'
import Grid from 'material-ui/Grid'
import { CardNumberElement, CardExpiryElement, CardCVCElement } from 'react-stripe-elements'
import StripeElementWrapper from './StripeElementWrapper'
export default class extends PureComponent {
static displayName = 'StripeCardsSection'
@chris-ramon
chris-ramon / README.md
Created Mar 19, 2019 — forked from joyrexus/README.md
Node.js streams demystified
View README.md

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@chris-ramon
chris-ramon / .vimrc
Created Mar 15, 2019 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
View .vimrc
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
@chris-ramon
chris-ramon / CountLinesAndLetters.js
Created Mar 7, 2019 — forked from maxrabin/CountLinesAndLetters.js
Example Lambda Function to process lines of text files when uploaded to S3
View CountLinesAndLetters.js
'use strict';
var AWS = require('aws-sdk');
var S3 = new AWS.S3();
var readline = require('readline');
exports.handler = function (event, context) {
//Get S3 file bucket and name
//Make sure to loop through event.Records, don't assume there is only 1 in production!!!
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
@chris-ramon
chris-ramon / lambda-s3-read-write-by-line.js
Created Mar 7, 2019 — forked from hboylan/lambda-s3-read-write-by-line.js
AWS Lambda function to read and write S3 files by line to perform efficient processing
View lambda-s3-read-write-by-line.js
const stream = require('stream')
const readline = require('readline')
const AWS = require('aws-sdk')
const S3 = new AWS.S3()
// read S3 file by line
function createReadline(Bucket, Key) {
// s3 read stream
const input = S3
@chris-ramon
chris-ramon / main.go
Created Sep 10, 2018
full working example PR#388 + PR#393
View main.go
/*
2018/09/09 20:33:22 [GetCustomerBatchFn] batch size: 3
2018/09/09 20:33:22 [GetCustomerAffiliationsBatchFn] batch size: 3
2018/09/09 20:33:22 [GetGroupBatchFn] batch size: 4
2018/09/09 20:33:22 [GraphQL result] total customers: 3
2018/09/09 20:33:22 [GraphQL result]:
{"data":{"CustomerVisit":{"items":[{"customer":{"affiliations":{"items":[{"group":{"id":1,"name":"first group"}},{"group":{"id":4,"name":"fourth group"}}]},"first_name":"first customer","id":1,"last_name":"first customer last name"}},{"customer":{"affiliations":{"items":[{"group":{"id":2,"name":"second group"}},{"group":{"id":4,"name":"fourth group"}}]},"first_name":"second customer","id":2,"last_name":"second customer last name"}},{"customer":{"affiliations":{"items":[{"group":{"id":3,"name":"third group"}},{"group":{"id":4,"name":"fourth group"}}]},"first_name":"third customer","id":3,"last_name":"third customer last name"}}]}}}
*/
package main
@chris-ramon
chris-ramon / main.go
Last active Oct 24, 2019
Alternative solution to concurrent resolvers
View main.go
/*
$ go run main.go
rootObject() | took: 1.000260951s
graphql.Do() | took: 367.401µs
graphql.Do() | result: {"data":{"me":{"github":{"issues":[{"id":"100"},{"id":"101"}],"pullRequests":[{"id":"200"},{"id":"201"}]}}}}
*/
package main
import (