Skip to content

Instantly share code, notes, and snippets.

View mrfoh's full-sized avatar

Patrick Foh Jr mrfoh

View GitHub Profile
@asoorm
asoorm / docker-compose-mongo-replicaset.yml
Created September 14, 2018 19:00
Mongo Replica Set docker compose
version: "3"
services:
mongo1:
hostname: mongo1
container_name: localmongo1
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27011:27017
@lukas-zech-software
lukas-zech-software / GeoCodingService.ts
Last active April 9, 2021 21:56
Typescript Definitions for official GoogleMaps API for Node.js (https://github.com/googlemaps/google-maps-services-js)
import { createClient, GoogleMapsClient } from '@google/maps';
export class GeoCodingService {
private geoCoder: GoogleMapsClient;
public constructor() {
this.geoCoder = createClient({
key: 'YOUR-API-KEY',
});
@radrice
radrice / fsAngular.js
Created February 9, 2016 15:41
A quick setup for AngularJS + FullStory
/*
A kludgey example of how to use FullStory with AngularJS.
Just shove it into .run :-)
Do with it as you please, but use at your own risk.
This is not officially sanctioned code and intended to provide an example
of how FullStory is implemented in an Angular application.
*/
(function(){
'use strict';
@logbon72
logbon72 / nigeria_state_polygons.json
Created January 2, 2016 13:12
Coordinate Boundaries for Nigerian States
{
"ABIA": [
[5.3918045732398, 7.3196411132812],
[5.4246168391946, 7.3388671875],
[5.4437565043427, 7.3663330078125],
[5.5285105256928, 7.4020385742188],
[5.6282859838703, 7.4006652832031],
[5.6856833027592, 7.3814392089844],
[5.6952489676056, 7.4020385742188],
[5.8428131655266, 7.3855590820312],
@SerhiiKozachenko
SerhiiKozachenko / repository.js
Created August 6, 2013 21:54
Mongoose odm and repository pattern.
var mongoose = require('mongoose');
var repository = function (modelName) {
var self = this;
self.Model = require('../models/' + modelName);
self.FindById = function (id, cb) {
self.FindOne({
@jonlabelle
jonlabelle / string-utils.js
Last active October 30, 2023 20:33
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@qiao
qiao / ip.js
Created January 17, 2012 11:27
Node.js get client IP address
// snippet taken from http://catapulty.tumblr.com/post/8303749793/heroku-and-node-js-how-to-get-the-client-ip-address
function getClientIp(req) {
var ipAddress;
// The request may be forwarded from local web server.
var forwardedIpsStr = req.header('x-forwarded-for');
if (forwardedIpsStr) {
// 'x-forwarded-for' header may return multiple IP addresses in
// the format: "client IP, proxy 1 IP, proxy 2 IP" so take the
// the first one
var forwardedIps = forwardedIpsStr.split(',');
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//