Skip to content

Instantly share code, notes, and snippets.

@evilUrge
evilUrge / .fetchRemoteConf.js
Created Sep 1, 2020
Fetch firebase remote config - a script for npm build
View .fetchRemoteConf.js
require('dotenv').config()
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.cert(
process.env.NODE_ENV === 'production'
? require('./gcp.json')
: JSON.parse(process.env.FIREBASE_ADMIN_SDK)
),
databaseURL: process.env.FIREBASE_DATABASE_URL
});
@evilUrge
evilUrge / webhook.py
Last active Oct 13, 2020
Plain webhook - Report for every change in a spesific model based on a pre-exists django WebHook model condition
View webhook.py
import logging
logger = logging.getLogger(__name__)
def report(saved_object):
"""
report is the main function in reporter
# :param uid: django ORM unique identifier; for internal usage.
@evilUrge
evilUrge / view.py
Last active Oct 13, 2020
Django external webhook view
View view.py
import logging
from json import loads
from django.apps import apps
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.core.serializers import serialize
from django.http import JsonResponse
logger = logging.getLogger(__name__)
@evilUrge
evilUrge / firebase-deploy.js
Created May 2, 2019
Deploy to firebase with any CI
View firebase-deploy.js
const fs = require('fs');
const token = process.env['FIREBASE_TOKEN']; // Keep your firebase cli token in FIREBASE_TOKEN as a env param
const projectName = (JSON.parse(fs.readFileSync(`${__dirname}/.firebaserc`, 'utf8')))
.projects[process.env.NODE_ENV ? process.env.NODE_ENV : 'default'];
/**
* FireBase Deployment script
* FOR CI USE ONLY!
*/
@evilUrge
evilUrge / fetch.js
Last active May 2, 2019
Fetch configurations from Firestore's collection "configurations" as json files.
View fetch.js
process.env.NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
require('../src/firebase').admin.firestore().collection('configurations').get()
.then(documents =>
documents.forEach((document) =>
require('fs').writeFile(`${require('../src/utils').baseDir}/config/${document.id}.json`, JSON.stringify(document.data()), (error) =>
error ? console.error(error) : console.log(`Configuration file ${document.id}.json has been created!`))));
@evilUrge
evilUrge / server.js
Last active May 6, 2019
Express.js\restify auto register handlers by path
View server.js
module.exports = (() => {
/**
* Map all available handlers to express route.
* @type {{handler}|*}
*/
const fs = require('fs');
const express = require('express');
const bodyParser = require('body-parser');
const bunyan = require('bunyan');
@evilUrge
evilUrge / express_server_obj_exposed_to_firebase.js
Last active May 13, 2019
Firebase function serving restify server if production(else just start server onj)
View express_server_obj_exposed_to_firebase.js
const server = require(`./src/server`);
process.env.NODE_ENV === "DEV" ?
/**
* If dev environment, run express server for local debugging.
*/
server.listen(process.env.PORT || 3000) :
/**
* Creates a function instance and with a specific specs.
@evilUrge
evilUrge / docker-compose.yml
Created Mar 15, 2018 — forked from KrustyHack/docker-compose.yml
Docker-compose for rancher, nginx and let's encrypt
View docker-compose.yml
nginx-proxy:
image: jwilder/nginx-proxy:latest
ports:
- "80:80"
- "443:443"
volumes:
- '/home/docker/nginx-proxy/ssl:/etc/nginx/certs:ro'
- '/etc/nginx/vhost.d'
- '/usr/share/nginx/html'
- '/var/run/docker.sock:/tmp/docker.sock:ro'
View gist:488c65e1822c9e2c2ad8c75fcb24b746
### Keybase proof
I hereby claim:
* I am evilurge on github.
* I am evilurge (https://keybase.io/evilurge) on keybase.
* I have a public key ASDtn_MWVDpdsa6Did8RWtLKYNqkG3GFXSfaB-OGON0Idwo
To claim this, I am signing this object:
You can’t perform that action at this time.