Skip to content

Instantly share code, notes, and snippets.

View mithi's full-sized avatar

Mithi Sevilla mithi

View GitHub Profile
import { useState, useCallback } from 'react'
const getTotalPages = (total: number, perPage: number) => Math.ceil(total / perPage)
const usePagination = () => {
const [state, setPaginationState] = useState<{
totalItems: number
itemsPerPage: number
currentPage: number
}>({ totalItems: 0, itemsPerPage: 1, currentPage: 1 })

Commit Messages Example Style Guide

Message Structure

A commit messages consists of three distinct parts separated by a blank line: the title, an optional body and an optional footer. The layout looks like this:

type: subject

body
@mithi
mithi / question.md
Last active January 28, 2021 15:53

Also about exercise 2, extra credit 3... The solution has this:

function asyncReducer(state, action) {
  switch (action.type) {
    case 'pending': {
      return {status: 'pending', data: null, error: null}
    }
    case 'resolved': {
      return {status: 'resolved', data: action.data, error: null}
@mithi
mithi / pipeline.py
Last active January 20, 2021 13:04
feature_params = {
'color_model': 'yuv', # hls, hsv, yuv, ycrcb
'bounding_box_size': 64, # 64 pixels x 64 pixel image
'number_of_orientations': 11, # 6 - 12
'pixels_per_cell': 16, # 8, 16
'cells_per_block': 2, # 1, 2
'do_transform_sqrt': True
}
src = FeatureSourcer(feature_params, temp_frame)
// Get data
let newToDelete = [];
for (const element of document.querySelectorAll(".mn-connection-card")) {
newToDelete.push([element.querySelector("a").href, element.querySelector(".mn-connection-card__name").textContent.trim(), element.querySelector(".mn-connection-card__occupation").textContent.trim()])
}
// Copy data to clipboard
copy(JSON.stringify(newToDelete));
/*
@mithi
mithi / dark-hexapod-robot-simulator.markdown
Created January 5, 2021 19:10
DARK-HEXAPOD-ROBOT-SIMULATOR
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
int DELAY = 10;
int INCREMENT = 1;
int FREQ = 150;
int LARGE_DELAY = 400;
Adafruit_PWMServoDriver pwmTop = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver pwmBottom = Adafruit_PWMServoDriver(0x41);
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// frequency for servo drivers
int FREQ = 150;
Adafruit_PWMServoDriver pwmTop = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver pwmBottom = Adafruit_PWMServoDriver(0x41);
// Load Wi-Fi library
#include <ESP8266WiFi.h>
#include <Wire.h> //include Wire.h library
void setup()
{
Wire.begin(); // Wire communication begin
Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
while (!Serial); // Waiting for Serial Monitor
Serial.println("\nI2C Scanner");
}
/*
0 | 1 | 2
----------
3 | 4 | 5
----------
6 | 7 | 8
*/