Skip to content

Instantly share code, notes, and snippets.

@rgaidot
rgaidot / pairsum.ts
Last active March 4, 2022 09:57
pairSum in javascript
View pairsum.ts
const pairSumExplain = (array: Array<number>, target: number): Array<Array<number>> => {
const length: number = array.length;
const found: Array<Array<number>> = [];
for(let i = 0; i < length; i++) {
for(let j = (i + 1); j < length; j++) {
if(target == array[i] + array[j]) found.push([array[i], array[j]]);
}
}
View boostrap-k3d.sh
#!/bin/sh -e
cat <<EOF
__ ________ .___
| | __\_____ \ __| _/
| |/ / _(__ < / __ |
| < / \/ /_/ |
|__|_ \/______ /\____ |
\/ \/ \/
@rgaidot
rgaidot / WorkingAgreementsTech.md
Last active July 12, 2022 01:38
Working Agreements Tech
View WorkingAgreementsTech.md

Rules & Conventions

You're contributor, here are the guidelines we would must follow:

  • We've very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate change log. We use Conventional Commits guideline. It's better to create branches and commit messages in English and make them understandable
  • I.N.V.E.S.T.(Independent, Negotiable, Valuable, Estimatable, Small, Testable) ! Each Stories are a widely accepted set of criteria, or checklist, to assess the quality. If stories fails to meet one of these criteria, the team may want to reword it, or even consider a rewrite.
  • DRY ! It's better whenever possible, re-using as much code as possible rather than duplicating similar
@rgaidot
rgaidot / TextWithCR.js
Last active August 28, 2019 18:49
Text with carriage returns without dangerouslySetInnerHTML #react
View TextWithCR.js
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
const TextWithCR = ({ text }) => {
const lines = text.split('\n');
return (
<Fragment>
{lines.map(line => (
<Fragment key={line}>
@rgaidot
rgaidot / useStateFetch.js
Last active June 11, 2019 11:46
useStateFetch
View useStateFetch.js
import { useState, useEffect } from 'react';
const render = data => match =>
data.pending ? match.pending()
: data.error ? match.error(data.error)
: data.data ? match.data(data.data)
: null;
export const useStateFetch = url => {
const [data, setData] = useState({ pending: true });
View k8s-ecr-refresh.yml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
annotations:
name: ecr-cred-helper
namespace: default
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
jobTemplate:
@rgaidot
rgaidot / the-basics-of-JavaScript-with-arrays.js
Created July 17, 2018 18:56
The basics of JavaScript with Arrays
View the-basics-of-JavaScript-with-arrays.js
// Code Challenge #11: JavaScript Functional Programming
// https://scotch.io/bar-talk/code-challenge-11-javascript-functional-programming
// ARRAY 1
const texasss = [{
name: 'Mike',
age: 23,
gender: 'm',
us: false,
@rgaidot
rgaidot / gist:72e34ca92f62382e7b9c18afc06b5762
Created June 16, 2017 08:24 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup
View gist:72e34ca92f62382e7b9c18afc06b5762

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@rgaidot
rgaidot / compose-install.service
Created January 28, 2017 13:11
Docker Compose on CoreOS
View compose-install.service
[Unit]
Description=Docker Compose on CoreOS
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutStartSec=0
View The Three Go Landmines.markdown

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }