Skip to content

Instantly share code, notes, and snippets.

View johhansantana's full-sized avatar

Johhan Santana johhansantana

View GitHub Profile
@eSlider
eSlider / mbtiles2pbf.sh
Created September 24, 2019 13:53
Extract PBF tiles from mbtiles (SQLite)
#!/bin/sh
git clone https://github.com/mapbox/mbutil
cd mbutil
./mb-util --image_format=pbf *.mbtiles tiles
gzip -d -r -S .pbf *
find . -type f -exec mv '{}' '{}'.pbf \;
@roelvan
roelvan / dev-server.js
Created November 26, 2018 11:48
NOW v2 Local DEV env Node.js
require('dotenv').config();
const http = require('http');
const url = require('url');
// import NOW SETTINGS
const now = require('./now.json');
const PORT = process.env.PORT || 3030;
const routes = now.routes.reduce((map, route) => {
@deptno
deptno / fragment.ts
Created June 25, 2018 02:53
graphql-tag fragment example
import gql from 'graphql-tag'
const FRAGMENT_REPOSITORY = gql`
fragment repository on Repository {
name
url
createdAt
description
descriptionHTML
labels {
@Maqsim
Maqsim / 413-payload-too-large-fix.js
Last active March 19, 2024 06:37
HOW TO FIX "413 Payload too large" in NodeJS (Express)
const express = require('express');
const bodyParser = require('body-parser');
...
// Express 4.0
app.use(bodyParser.json({ limit: '10mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '10mb' }));
// Express 3.0
@kevinsalter
kevinsalter / array-spread-reordering.js
Last active June 25, 2023 12:04
reordering array using ES2015 array spread operator
const reorderArray = (event, originalArray) => {
const movedItem = originalArray.find((item, index) => index === event.oldIndex);
const remainingItems = originalArray.filter((item, index) => index !== event.oldIndex);
const reorderedItems = [
...remainingItems.slice(0, event.newIndex),
movedItem,
...remainingItems.slice(event.newIndex)
];
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@lambdahands
lambdahands / _readme.md
Created September 28, 2015 17:09
FlowType and CSS Modules

Huh?

So basically FlowType doesn't know about CSS Modules, a really handy way of dealing with the plagues of CSS in codebases (global variables and dependency wackiness mainly).

What WebPack allows us to do is "require" CSS files and use their class names:

import styles from "my_styles.css";
import React from "react";
@leocaseiro
leocaseiro / .htaccess
Last active February 23, 2022 03:59
Angular html5Mode apache working in a subdirectory /app using ngRoute
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /app/index.html [NC,L]
</IfModule>
@mlynch
mlynch / autofocus.js
Last active August 24, 2022 15:03
AngularJS Autofocus directive
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus>
*
* License: MIT
*/
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();