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
@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;
}
@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; }
@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 );

🔻

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.

@nerdyman
nerdyman / resolve-tsconfig-path-to-webpack-alias.js
Last active June 19, 2025 19:38
Convert TypeScript tsconfig paths to webpack alias paths
const { resolve } = require('path');
/**
* Resolve tsconfig.json paths to Webpack aliases
* @param {string} tsconfigPath - Path to tsconfig
* @param {string} webpackConfigBasePath - Path from tsconfig to Webpack config to create absolute aliases
* @return {object} - Webpack alias config
*/
function resolveTsconfigPathsToAlias({
tsconfigPath = './tsconfig.json',
@Houserqu
Houserqu / action.js
Last active April 2, 2018 14:50
React
import 'whatwg-fetch';
import {openSnackbar} from '../../public/action/globalAction';
export function setAttractions(attractions){
return {
type:'SET_ATTRACTIONS',
attractions:attractions
}
}
@codediodeio
codediodeio / database.rules.json
Last active November 9, 2025 17:54
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@coreequip
coreequip / short-ali.userscript.js
Last active August 29, 2022 17:32 — forked from eremin/ageShot.js
Aliexpress/eBay/Gearbest URL Shortener
// ==UserScript==
// @name Aliexpress/eBay/Gearbest/Amazon URL Shortener
// @namespace http://tampermonkey.net/
// @version 0.5
// @author hedgehog, core.equip
// @match https://*.aliexpress.com/item/*
// @match https://*.ebay.de/itm/*
// @match https://*.ebay.com/itm/*
// @match https://*.gearbest.com/*
// @match https://*.amazon.de/*
@Klerith
Klerith / parse-jwt.js
Created March 15, 2018 15:07
Parse - JWT - Obtener Payload y fecha de creación y expiración
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
return JSON.parse(window.atob(base64));
};