Skip to content

Instantly share code, notes, and snippets.

EECOLOR EECOLOR

View GitHub Profile
@EECOLOR
EECOLOR / .git_sit_awareness.sh
Last active May 8, 2020
.git_sit_awareness.sh
View .git_sit_awareness.sh
#!/usr/bin/env bash
PROMPT_GREEN='\001'`tput setaf 2`'\002'
PROMPT_PINK='\001'`tput setaf 5`'\002'
PROMPT_PLAIN='\001'`tput op`'\002'
function in_git_repo {
[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1
}
@EECOLOR
EECOLOR / throttledChildAdded.js
Last active Jul 2, 2019 — forked from iclems/Firebase Lazy-Safe Iterator
This snippet enables to iterate over a Firebase reference in a non-blocking way. If you need to iterate over a large reference, a child_added query may block your Firebase as it will query the whole data before iteration. With this snippet, children are retrieved one by one, making it slower / safer.
View throttledChildAdded.js
module.exports = function throttledChildAdded(ref, callback, onError, sortChildKey = null /* uses `key` if null */) {
const state = { stopped: false }
let listener = null
throttledChildAdded({ state, endReached: lastSeen => { listener = listenForNewChildren({ startAfter: lastSeen }) } })
return () => {
state.stopped = true
if (listener) ref.off('child_added', listener)
@EECOLOR
EECOLOR / firebaseSaveFile.js
Created Aug 30, 2017
Saves a file to Firebase storage with token authentication as if created from the console.
View firebaseSaveFile.js
const storage = require('@google-cloud/storage')
const createUuid = require("uuid-v4")
const credentials = require('./test-firebase-credentials.json')
const firebaseProjectName = 'test'
const bucketName = `${firebaseProjectName}.appspot.com`
const bucket = storage({ credentials }).bucket(bucketName)
module.exports = firebaseSaveFile
View keybase.md

Keybase proof

I hereby claim:

  • I am eecolor on github.
  • I am eecolor (https://keybase.io/eecolor) on keybase.
  • I have a public key whose fingerprint is AF78 4091 483A 8E95 E0F4 FE7F 103A 000A 62BA 9F9B

To claim this, I am signing this object:

View blue-green-services.sh
#!/bin/bash -e
#DEPLOY_SERVERS=(vm273 vm274)
#APP_NAME=via-autobeheer-app-test
#DIST=dist/
#STATUS_CHECK_BASE=https://via-autobeheer-app-tst.firebaseio.com
#STATUS_CHECK_LOCATIONS=(/userData/status /token/status)
#SERVICES=(authentication-service userdata-service)
# .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. #
@EECOLOR
EECOLOR / react without webpack.js
Last active Oct 19, 2016
react without webpack
View react without webpack.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Firebase component lifecycle</title>
</head>
<body>
<div id="container" />
<script src="../react/react.js"></script>
<script src="../react/react-dom.js"></script>
@EECOLOR
EECOLOR / .bashrc
Created Jan 31, 2016
Git situational awareness
View .bashrc
source ~/.git_sit_awareness.sh
View duck without actions.js
const ACTION = 'my-app/widgets/ACTION';
export default function reducer(state = {}, action = {}) {
switch (action.type) {
case ACTION:
return action.reduce(state)
default:
return state;
}
}
@EECOLOR
EECOLOR / commands.json
Created Nov 10, 2015
Elasticsearch nested sort problem
View commands.json
PUT /testindex
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"testtype": {
"dynamic": "strict",
"properties": {
View Option and categories
_ = magic
Option[A] = Some[A] | None
/*
O: Objects
A: Arrows
*/
O_00 = { _, X }
O_00 = { _ -> X }
You can’t perform that action at this time.