Skip to content

Instantly share code, notes, and snippets.

View kevinboosten's full-sized avatar

Kevin Boosten kevinboosten

View GitHub Profile
@mkhatib
mkhatib / geo.js
Created May 24, 2013 02:55
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@walkerjeffd
walkerjeffd / Synology-Diskstation-Git.md
Last active July 17, 2024 08:15
Instructions for setting up git server on Synology Diskstation

Configure Synology NAS as Git Server

Instructions for setting up a git server on a Synology NAS with Diskstation. Specifically, I am using a DS414 with DSM 5.0.

Set Up User and Folder

  • Create user gituser via Diskstation interface (with File Station and WebDAV privilages)
  • Add new shared folder called git (located at /volume1/git) with read/write access for gituser and admin. This folder will hold all the repos.
  • Install Git Server package via Diskstation
@MhdAljuboori
MhdAljuboori / ng-an-folder.js
Last active August 16, 2019 14:07
NG-Annotate for folder
var sh = require('shelljs');
function annotateFile (filePath) {
console.log('annotate ' + filePath);
sh.exec('ng-annotate -a ' + filePath + ' -o ' + filePath);
}
function annotateFolder (folderPath) {
console.log("annotate Folder " + folderPath);
sh.cd(folderPath);
@ygotthilf
ygotthilf / jwtRS256.sh
Last active July 14, 2024 00:03
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@clohr
clohr / sets.js
Created February 26, 2017 19:09
ES6 Sets: Intersection, Difference, and Union
const a = new Set([1, 2, 3, 4, 4, 4])
const b = new Set([3, 4, 5, 6])
const intersect = (set1, set2) => [...set1].filter(num => set2.has(num))
const differ = (set1, set2) => [...set1].filter(num => !set2.has(num))
const joinSet = (set1, set2) => [...set1, ...set2]
const myIntersectedSet = new Set(intersect(a, b))
console.log('myIntersectedSet', myIntersectedSet)
@pianosnake
pianosnake / bounding-box-from-lat-lng-zoom-img-size.js
Last active July 17, 2024 14:19
Get a bounding box from latitude, longitude, zoom level and image size. Useful for getting the bounding box of a static map generated with only those variables.
const EARTH_CIR_METERS = 40075016.686;
const degreesPerMeter = 360 / EARTH_CIR_METERS;
function toRadians(degrees) {
return degrees * Math.PI / 180;
};
function latLngToBounds(lat, lng, zoom, width, height){
const metersPerPixelEW = EARTH_CIR_METERS / Math.pow(2, zoom + 8);
const metersPerPixelNS = EARTH_CIR_METERS / Math.pow(2, zoom + 8) * Math.cos(toRadians(lat));