Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
chris-ramon / git.sh
Last active November 24, 2023 19:17
git notes
# undo last commit, keep changes
git reset --mixed HEAD~1
# git log by directory
git log --oneline -n 10 -- dir_name/
# ammend git commit message
git rebase -i parent-commit-hash
# replace pick with reword, then update the commit message.
@chris-ramon
chris-ramon / notes.go
Last active April 20, 2023 19:16
golang notes
// go imports
go install golang.org/x/tools/cmd/goimports@latest
// enable ms
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
// count number of tests
go test ./... -v | grep -c RUN
@chris-ramon
chris-ramon / vim.sh
Last active September 7, 2022 19:53
vim notes
# show number all tabs
:tabdo windo set number
# copy to clipboard fix
sudo apt-get install vim-gtk
# editorconfig
https://github.com/editorconfig/editorconfig-vim
# autocomplete
@chris-ramon
chris-ramon / curl.sh
Last active August 12, 2022 23:36
curl notes
· curl
curl -G "https://api.github.com/search/repositories?page=1&per_page=6" --data-urlencode "sort=stars" --data-urlencode "order=desc" --data-urlencode "q=language:html" | jq ".items[0,1,2,3,4,5] | {name, description, html_url}"
# set headers
curl localhost:8080 --header "jwt: mycooltoken"
# display headers
curl localhost:8080 -v
# show output in new line
@chris-ramon
chris-ramon / main.go
Created September 10, 2018 15:48
full working example PR#388 + PR#393
/*
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 / gist:570bc21008a22544134fd285f59f6d20
Created June 18, 2020 06:28 — forked from moraes/gist:2141121
LIFO Stack and FIFO Queue in golang
package main
import (
"fmt"
)
type Node struct {
Value int
}
@chris-ramon
chris-ramon / ordered_serially_execution.go
Created February 5, 2020 01:56
github.com/graphql-go ordered serially execution
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/graphql-go/graphql"
)
@chris-ramon
chris-ramon / tmux.md
Created November 2, 2019 02:59 — forked from Bekbolatov/tmux.md
Clean tmux cheat-sheet

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 / main.go
Last active October 24, 2019 20:37
Alternative solution to concurrent resolvers
/*
$ 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 (
@chris-ramon
chris-ramon / StripeCardsSection.js
Created April 12, 2019 01:03 — forked from lfalke/StripeCardsSection.js
Usage of react-stripe-elements with Material UI (v1.0) styling
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'