Skip to content

Instantly share code, notes, and snippets.

var fs = require('fs');
var Bleacon = require('bleacon');
var UUID = 'your UUID';
var Major = 'Your Major';
Bleacon.startScanning(UUID,Major); // scan for ibeacons
var jsonArray =[];
Bleacon.on('discover', function(bleacon) {
//bleacon properties are: uuid, major, minor, measuredPower, rssi, accu$
var beacon = JSON.stringify(bleacon);
jsonArray.push(bleacon)
const util = require('util');
class Node {
constructor(data, next=null) {
this.data = data;
this.next = next;
}
}
class LL {
constructor() {
@nschairer
nschairer / components.js
Last active November 29, 2019 04:34
React Components
//Header component
const Header = props => {
return (
<div style={style.containerStyle}>
<div style={style.navStyle}>
<a style={style.navItem}href='#'>About</a>
<a style={style.navItem}href='#'>Home</a>
</div>
<h3 style={style.textStyle}>Noah Schairer</h3>
</div>
@nschairer
nschairer / Distance.py
Created February 21, 2020 03:03
Function to compute distance in Miles or Kilometers between two latitude, longitude points on Earth using the Haversine formula
'''Haversine formula - Shortest distance between two points on a sphere
Steps:
1) Convert lat,long for two points from degrees to radians --> divide by 180/pi == 57.29577951
2) Earth radius in miles -> 3958.8, Km -> 6371
3) Formula
hav(lat2 - lat1) + cos(lat1)*cos(lat2)*hav(long2-long1)
hav(theta) = sin^2(theta/2) = (1 - cos(theta)) / 2
Let h = hav(theta)
d = radius * archav(h) = 2 * radius * arcsin(sqrt(h))
@nschairer
nschairer / attributes.py
Created July 20, 2020 21:29
Medium Python Dynamic Attributes
import json
#Unique type class to decipher between attributes
class ORMType:
def __init__(self, key, value):
self.key = key
self.value = value
def __repr__(self):
return str(self.value)
@nschairer
nschairer / postgres.sh
Created December 21, 2020 21:49
Postgres dev setup
# Ref article: https://towardsdatascience.com/local-development-set-up-of-postgresql-with-docker-c022632f13ea
if [ ! "$(docker ps -q -f name=dev-postgres)" ]; then
mkdir ${HOME}/postgres-data/
docker run -d \
--name dev-postgres \
-e POSTGRES_PASSWORD=password\
-v ${HOME}/postgres-data/:/var/lib/postgresql/data \
-p 5432:5432 \
@nschairer
nschairer / README.md
Last active January 15, 2024 13:23 — forked from ryu1kn/README.md
Getting GCP access token from a service account key JSON file

Getting GCP access token from a service account key

Use your service account's key JSON file to get an access token to call Google APIs.

Good for seeing how things work, including the creation of JWT token.

To create a JWT token, you can replace create-jwt-token.sh script with tools like step.

If you just want to get an access token for a service account,