Skip to content

Instantly share code, notes, and snippets.

View firminochangani's full-sized avatar
🖊️
probably shipping software.

Firmino Changani firminochangani

🖊️
probably shipping software.
View GitHub Profile
@firminochangani
firminochangani / exponential_backoff.go
Created December 10, 2022 16:10 — forked from dantheman213/exponential_backoff.go
Golang exponential back off simple example
package main
import "fmt"
import "time"
import "math"
var exponentialBackoffCeilingSecs int64 = 14400 // 4 hours
func main() {
fmt.Println("Hello World")
@firminochangani
firminochangani / styled-component.d.ts
Created September 2, 2022 10:48
Adding styled-components theme auto-completion
import { ThemeType } from "./theme";
import "styled-components";
declare module "styled-components" {
export interface DefaultTheme extends ThemeType {}
}
@firminochangani
firminochangani / match_a_slug.go
Created September 2, 2022 10:31
Regex to match a slug in Go (Lang)
package main
import (
"fmt"
"log"
"regexp"
)
// Regex source: https://ihateregex.io/expr/url-slug/
func main() {
import (
"fmt"
"regexp"
"strconv"
)
func ipToInt(value string) (int, error) {
r := regexp.MustCompile(`[a-z]|:|\.`) // match chars from a to z, or : (colon), or . (dot)
v := r.ReplaceAll([]byte(value), []byte("")) // replace all chars matched previously
@firminochangani
firminochangani / HttpStatusCode.ts
Created July 30, 2022 17:24 — forked from scokmen/HttpStatusCode.ts
Typescript Http Status Codes Enum
"use strict";
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body
@firminochangani
firminochangani / insertionSort.js
Last active July 14, 2021 07:44
Insertion sort
"use strict";
function insertionSort() {
var list = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
for (var i = 0; i < list.length; i++) {
var key = list[i];
var prevIndex = i - 1;
while (prevIndex >= 0 && list[prevIndex] > key) {
list[prevIndex + 1] = list[prevIndex];
<template>
<div id="app">
<h1>Plot with x and y axes</h1>
<plot :height="200"/>
</div>
</template>
<script>
import plot from "@/components/plotWithXandYaxis.vue";
export default {
import * as d3 from "d3";
methods: {
render() {
this.setSizes();
this.setScales();
this.renderAxes();
}
},
mounted(){
this.render();
}
/**
* renderAxes: Based on the x and y scales it will
* render the axes in the svg.
*/
renderAxes() {
const { x, y } = this.scales;
d3.select(".plot__axes__x").call(d3.axisBottom(x));
d3.select(".plot__axes__y").call(d3.axisLeft(y));
},