Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
@pfiadDi
pfiadDi / firestore.rules
Created August 4, 2021 17:08
Firestore Advanced Security Rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null;
}
function isDefined(field) {
return field in request.resource.data
@MorenoMdz
MorenoMdz / batchWrapper.js
Last active July 21, 2023 10:55
Firebase Firestore batch more than 500 docs or operations
const batchWrapper = async (documentRef, action, update) => {
const batchArray = [];
batchArray.push(db.batch());
let operationCounter = 0;
let batchIndex = 0;
documentRef.forEach(doc => {
console.log('Org cleanup: deleting notifications', doc.id);
if (action === 'delete') {
batchArray[batchIndex].delete(doc.ref);
@kevinmungai
kevinmungai / sapper_with_firebase_hosting.md
Created December 27, 2020 07:15
Sapper with Firebase Hosting
  1. Create Directory for your app mkdir my-app
  2. get the sapper template npx degit "sveltejs/sapper-template#rollup"
  3. Install the packages npm i
  4. Install express server npm i express
  5. Initialize Firebase firebase init
name: Test, Build and Deploy
on:
pull_request:
types: [closed]
jobs:
build-test-release:
if: github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
@vasind
vasind / ember-cli-build.js
Last active June 8, 2023 04:33
Ember CLI performance improvements and tips
// Credits to the following posts that helps me to reduce build times drastically
// https://discuss.emberjs.com/t/tips-for-improving-build-time-of-large-apps/15008/12
// https://www.gokatz.me/blog/how-we-cut-down-our-ember-build-time/
//ember-cli-build.js
let EmberApp = require('ember-cli/lib/broccoli/ember-app');
let env = EmberApp.env(),
echo code --install-extension
code --install-extension aaron-bond.better-comments
code --install-extension alefragnani.project-manager
code --install-extension ardenivanov.svelte-intellisense
code --install-extension cbuelter.vscode-toggle-max-editor
code --install-extension christian-kohler.path-intellisense
code --install-extension DavidAnson.vscode-markdownlint
code --install-extension dbaeumer.vscode-eslint
code --install-extension donjayamanne.githistory
code --install-extension dracula-theme.theme-dracula
{"lastUpload":"2020-08-13T16:51:00.817Z","extensionVersion":"v3.4.3"}
@keimlink
keimlink / nvm_vs_volta.md
Last active June 3, 2024 09:57
nvm vs Volta

nvm vs Volta

A comparison of nvm and Volta to manage Node.js projects (without Yarn).

Bootstrapping a Project

Bootstrapping a Project with nvm

nvm install
@katowulf
katowulf / pseudo_code.js
Last active June 16, 2021 19:29
Convert Cloud Storage json file to event stream and store output in Firestore
JSONStream = require('JSONStream');
es = require('event-stream');
fileStream = storage.bucket('your-bucket').file('your-JSON-file').createReadStream();
db = admin.firestore();
return new Promise( (resolve, reject) => {
batchPromises = [];
batchSize = 0;
batch = db.batch();
@farminf
farminf / nespresso_expert_hack.md
Last active July 3, 2024 19:35
Hacking Nespresso Expert Machine to brew coffee using custom applications via bluetooth

Nespresso Expert machine Hack (Bluetooth)

Nespresso Expert machine has the Bluetooth ability which officially can be used only by Nespresso mobile app and it does not offer any API for 3rd party applications and services. Moreover, the Bluetooth services and characteristics are not documented and easy to use by the other Bluetooth libraries plus there is no documentation for the Bluetooth packets payload that need to be sent or received.

However, after searching a lot and sniffing the packets for a couple of days, I've been able to hack the machine and write the small nodejs application using noble and express to control and monitor the machine with Rest API exposed by express through Bluetooth connection. As I did this application for my ex-company and they are still using it for their demo I cannot share the code but I'm going to explain how it works.

_Thanks to this