Skip to content

Instantly share code, notes, and snippets.

View raveenb's full-sized avatar
:octocat:
Learning, Always!

Raveen Beemsingh raveenb

:octocat:
Learning, Always!
View GitHub Profile
@amites
amites / center_geo.py
Last active October 15, 2021 23:14
Center Geolocations
from math import cos, sin, atan2, sqrt
def center_geolocation(geolocations):
"""
Provide a relatively accurate center lat, lon returned as a list pair, given
a list of list pairs.
ex: in: geolocations = ((lat1,lon1), (lat2,lon2),)
out: (center_lat, center_lon)
"""
x = 0
@ericdke
ericdke / splitBy.swift
Last active July 10, 2023 09:55
Swift: split array by chunks of given size
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
extension Array {
func splitBy(subSize: Int) -> [[Element]] {
return 0.stride(to: self.count, by: subSize).map { startIndex in
let endIndex = startIndex.advancedBy(subSize, limit: self.count)
return Array(self[startIndex ..< endIndex])
}
}
}
@ghiermann
ghiermann / PolylineUtils.kt
Created August 23, 2016 08:20
Kotlin PolylineUtils - encoding/decoding of polylines, simplification with Ramer-Douglas–Peucker algorithm
data class Coordinate(val longitude: Double, val latitude: Double)
/**
* Encodes a polyline using Google's polyline algorithm
* (See http://code.google.com/apis/maps/documentation/polylinealgorithm.html for more information).
*
* code derived from : https://gist.github.com/signed0/2031157
*
* @param (x,y)-Coordinates
@ivermac
ivermac / fetch-basic-auth.md
Created August 1, 2018 14:45
Using fetch with basic auth
let username = 'john';
let password = 'doe';
let url = `https://httpbin.org/basic-auth/${username}/${password}`
let authString = `${username}:${password}`
let headers = new Headers();
headers.set('Authorization', 'Basic ' + btoa(authString))
fetch(url,{method: 'GET', headers: headers})
    .then(function (response) {
 console.log (response)
@jsvine
jsvine / visidata-pipx-installation.md
Last active May 28, 2024 07:18
Installing VisiData via pipx

Installing VisiData via pipx

pipx is a command-line tool that allows you to run Python applications in isolated environments. It's a great way to make VisiData available across your system without worrying that its dependencies will conflict with other Python projects. This short guide will show you how.

Step 0: Uninstall global VisiData

If you have have previously VisiData installed globally, uninstall it by running pip3 uninstall visidata.

Otherwise, you can skip this step.

@raveenb
raveenb / fastapi_inside_jupyter.md
Last active September 18, 2023 06:32
Run FastAPI inside Jupyter

How to Run FastAPI inside Jupyter

  • Ensure you have these installed and accessible from the notebook pyngrok, nest_asyncio, fastapi, uvicorn and other libs you want
%pip install pyngrok nest_asyncio fastapi uvicorn loguru
  • Create a FastAPI app
from fastapi import FastAPI