Skip to content

Instantly share code, notes, and snippets.

View PterPmnta's full-sized avatar
💭
FullStack Web Developer

Pedro Pimienta M. PterPmnta

💭
FullStack Web Developer
View GitHub Profile

🔻

NOTE: This page is currently a work in progress. There is a lot to cover in detail. The plan is to breakout details on conventions like 'How To Write Your Selectors' and 'How To Normalize Your Data' a bit later. For now just look for existing examples in the code or ask a friend.

To get the quick and dirty bullet list, scroll down to the TL;DR; below.


React Best Practices & Patterns

There are a few tricks we've picked up since we started that will help us with debugging, reuse, scalability, performance, and common pitfalls of complex singles page app development. We are not code Nazis but getting familiar with these things will help the whole team increase output and reduce code debt. These things should be pointed out in code reviews and corrected.

The goal is to write consistent code with less opportunities for bugs. Complex code is buggy code. It's really that simple.

@scottopolis
scottopolis / splice-object-array.js
Last active July 4, 2025 13:21
Remove object from array of objects in Javascript
// we have an array of objects, we want to remove one object using only the id property
const apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
// get index of object with id of 37
const removeIndex = apps.findIndex( item => item.id === 37 );
// remove object
apps.splice( removeIndex, 1 );
@kkdd
kkdd / mapboxgl.marker.html
Last active October 11, 2022 22:14
Mapbox GL JS で矢尻形マーカー(mapboxgl.Marker 利用) ref: https://qiita.com/kkdd/items/0eb24549d10e875c1fa5
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.30.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.30.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@evdokimovm
evdokimovm / index.js
Created June 19, 2016 14:10
JavaScript Convert Radians to Degrees and Degrees to Radians
// Convert from degrees to radians.
Math.radians = function(degrees) {
return degrees * Math.PI / 180;
}
Math.radians(90); // 1.5707963267948966
// Convert from radians to degrees.
Math.degrees = function(radians) {
return radians * 180 / Math.PI;
}
@darklilium
darklilium / [React]Exportar e Importar Componentes.txt
Last active January 3, 2022 21:08
[React]Exportar e Importar Componentes
Para exportar componentes, se deben seguir los siguientes pasos:
• En un archivo js indicar los import correspondientes a las librerias react y react-dom, como otras(con rutas relativas).
Ejemplo: statistics-toolbar.js
import React from 'react';
import ReactDOM from 'react-dom';
import token from '../services/token-service';
import layers from '../services/layers-service';
import mymap from '../services/map-service';
• Construir el componente.
@maximilian-lindsey
maximilian-lindsey / sqlite3_electron_windows_integration.md
Last active August 29, 2021 14:55
SQLite3 Electron windows integration

SQLite3 Electron windows integration

This guide is based on the very informative discussion in this article: Using node_sqlite3 with Electron

Install sqlite3

npm install sqlite3 --save
flex-flow:column-reverse wrap-reverse;
justify-content:center;
align-content:space-between;
@gokulkrishh
gokulkrishh / media-query.css
Last active October 28, 2025 18:36
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@porfidev
porfidev / ultimos_tweets.php
Created August 8, 2015 17:01
API Twitter 2015: Mostrar los últimos 10 tweets de un usuario
<?php
/**
* Created by PhpStorm.
* User: elporfirio
* Date: 08/08/15
* Time: 10:56
*/
require "twitteroauth-master/autoload.php";