Skip to content

Instantly share code, notes, and snippets.

View ra9r's full-sized avatar

RA9R ra9r

View GitHub Profile
@ra9r
ra9r / launch.json
Last active June 14, 2019 18:51
Mocha Launcher for VSC #vsc #mocha
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Mocha",
"type": "node",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"args": ["--no-timeouts", "test"],
"cwd": "${workspaceRoot}",
@ra9r
ra9r / HOWTO.md
Last active June 10, 2019 03:03
How to move a private #Git repository

Step 1: Create Github repository

First, create a new private repository on Github.com. It’s important to keep the repository empty, e.g. don’t check option Initialize this repository with a README when creating the repository.

Step 2: Move existing content

Next, we need to fill the Github repository with the content from our Bitbucket repository:

  1. Check out the existing repository from Bitbucket:
$ git clone https://USER@bitbucket.org/USER/PROJECT.git
@ra9r
ra9r / firestore.js
Last active June 10, 2019 03:02
Initialize #firestore on a server
const admin = require('firebase-admin');
let serviceAccount = require('path/to/serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
let db = admin.firestore();
@ra9r
ra9r / jest-exceptions.md
Last active June 10, 2019 03:10
Cheatsheet for #jest #unit-tests #mock #nodejs

Basic expectations

expect(value)
  .not
  .toBe(value)
  .toEqual(value)
  .toBeTruthy()

Note that toEqual is a deep equality check. See: expect()

@ra9r
ra9r / firestore_ref_test.js
Last active June 14, 2019 18:50
Store a DocumentReference #firestore #nodejs
const admin = require('firebase-admin');
let serviceAccount = require('./service_key.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
let db = admin.firestore();
@ra9r
ra9r / gpsDistanceInKM.dart
Created June 27, 2019 16:23
An example of how to compute the distance between two lat/lon points.
double getDistanceFromLatLonInKm(double lat1, double lon1, double lat2, double lon2) {
var R = 6371; // Radius of the earth in km
var dLat = deg2rad(lat2-lat1); // deg2rad below
var dLon = deg2rad(lon2-lon1);
var a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2)
;
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
@ra9r
ra9r / N992BA.yaml
Created June 28, 2019 19:07
Sample Aircraft Data Import File #aeyrium
aircraft:
tailNumber: N992BA
serialNumber: 1781
manufacturer: BellHelicopter
model: 206B
year: 1999
aircraftType: Rotorcraft
engineType: Turbine
engineCount: 1
purposes:
@ra9r
ra9r / install-google-services.sh
Created June 29, 2019 23:53
How to install GoogleService-Info.plist and google-services.json from env variables #codemagic #cicd
#!/usr/bin/env sh
set -e # exit on first failed commandset
echo $ANDROID_FIREBASE_SECRET | base64 --decode > $FCI_BUILD_DIR/android/app/google-services.json
echo $IOS_FIREBASE_SECRET | base64 --decode > $FCI_BUILD_DIR/ios/Runner/GoogleService-Info.plist
@ra9r
ra9r / proguard-rules.pro
Created July 4, 2019 20:32
Proguard Properties for Flutter and Firebase #flutter #firebase #android
## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
# Basic ProGuard rules for Firebase Android SDK 2.0.0+
-keep class com.firebase.** { *; }
@ra9r
ra9r / list-example.swift
Created September 25, 2022 04:10
Styling SwiftUI List backgrounds
List {
}
.onAppear {
// If you set the underlying UITableView appearance to "clear"
// it will allow the view's background colors to show through.
UITableView.appearance().backgroundColor = UIColor.clear
UITableViewCell.appearance().backgroundColor = UIColor.clear
}