Skip to content

Instantly share code, notes, and snippets.

View marlo22's full-sized avatar

Marcin Lasecki marlo22

View GitHub Profile
@tingwei628
tingwei628 / docker-compose.yml
Created October 27, 2019 15:20
use postgresql and pgAdmin in docker
version: "3.4"
services:
pgAdmin:
restart: always
image: dpage/pgadmin4
ports:
- "8000:80"
environment:
PGADMIN_DEFAULT_EMAIL: 1234@admin.com
@parties
parties / renameReactJsToJsx.sh
Last active July 19, 2024 19:27
rename all *.js files containing React markup to *.jsx
# finds all *.js files that have either `</` or `/>` tags in them and renames them to *.jsx
find ./src -type f -name '*.js' -not -name '*.jsx' -not -name '*.ejs' -exec bash -c 'grep -l -E "</|/>" "$0"' {} \; -exec bash -c 'mv "$0" "${0%.js}.jsx"' {} \;
@codediodeio
codediodeio / database.rules.json
Last active July 24, 2024 21:05
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@joepie91
joepie91 / express-server-side-rendering.md
Last active July 26, 2024 09:56
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
@jeffreymorganio
jeffreymorganio / centerLeafletMapOnMarker.js
Created July 5, 2016 15:40
Zoom and center a Leaflet map on a single marker.
function centerLeafletMapOnMarker(map, marker) {
var latLngs = [ marker.getLatLng() ];
var markerBounds = L.latLngBounds(latLngs);
map.fitBounds(markerBounds);
}
@joshnuss
joshnuss / app.js
Last active March 4, 2024 00:01
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@TakashiSasaki
TakashiSasaki / gist:4282903
Created December 14, 2012 05:32
HTML5 StorageEvent does not fire "storage" event in the window that changes the state of the local storage. This sample shows how to fire self-"storage" event.
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script>
"use strict";
@yuletide
yuletide / epsg.js
Created October 18, 2012 01:22
Proj4js EPSG Definitions as a node module
module.exports = function(Proj4js){
Proj4js.defs["EPSG:3819"] = "+proj=longlat +ellps=bessel +towgs84=595.48,121.69,515.35,4.115,-2.9383,0.853,-3.408 +no_defs";
Proj4js.defs["EPSG:3821"] = "+proj=longlat +ellps=aust_SA +no_defs";
Proj4js.defs["EPSG:3824"] = "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs";
Proj4js.defs["EPSG:3889"] = "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs";
Proj4js.defs["EPSG:3906"] = "+proj=longlat +ellps=bessel +towgs84=682,-203,480,0,0,0,0 +no_defs";
Proj4js.defs["EPSG:4001"] = "+proj=longlat +ellps=airy +no_defs";
Proj4js.defs["EPSG:4002"] = "+proj=longlat +ellps=mod_airy +no_defs";
Proj4js.defs["EPSG:4003"] = "+proj=longlat +ellps=aust_SA +no_defs";
Proj4js.defs["EPSG:4004"] = "+proj=longlat +ellps=bessel +no_defs";
@zspine
zspine / countries.csv
Last active July 11, 2024 14:36
Country Code, ISO and Nationality ( Please use https://mledoze.github.io/countries/ )
CCA2 Name CCA3 Nationality
AD Andorra AND Andorran
AE United Arab Emirates ARE Emirati
AF Afghanistan AFG Afghan
AG Antigua and Barbuda ATG Antiguan, Barbudan
AI Anguilla AIA Anguillian
AL Albania ALB Albanian
AM Armenia ARM Armenian
AN Netherlands Antilles ANT Dutch
AO Angola AGO Angolan