Skip to content

Instantly share code, notes, and snippets.

View spac3unit's full-sized avatar

Denis spac3unit

View GitHub Profile
@spac3unit
spac3unit / App.js
Created November 30, 2019 14:10 — forked from madcoda/App.js
React-router v4 multi layout
import React, { Component } from 'react'
import { BrowserRouter as Router, Route, Link, Match, Redirect, Switch } from 'react-router-dom'
import OverviewPage from './page/OverviewPage'
import AccountPage from './page/AccountPage'
/*
Layouts, inline define here for demo purpose
you may want to define in another file instead
*/
@spac3unit
spac3unit / application_helper.rb
Created May 27, 2019 14:36 — forked from mynameispj/application_helper.rb
Rails - Easy "active" classes for menu links in Rails
module ApplicationHelper
def current_class?(test_path)
return 'active' if request.path == test_path
''
end
end
@spac3unit
spac3unit / gulpfile.js
Created May 19, 2019 21:20 — forked from demisx/gulpfile.js
Gulp 4 gulpfile.js
// Gulp 4
var gulp = require('gulp');
var using = require('gulp-using');
var grep = require('gulp-grep');
var changed = require('gulp-changed');
var del = require('del');
var coffee = require('gulp-coffee');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var sourcemaps = require('gulp-sourcemaps');
'use strict';
var gulp = require('gulp'),
watch = require('gulp-watch'),
prefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
rigger = require('gulp-rigger'),
cssmin = require('gulp-minify-css'),
@spac3unit
spac3unit / flowcart.ts
Created November 27, 2018 00:16 — forked from spion/flowcart.ts
A typesafe shopping cart in typescript
// A typesafe shopping cart in typescript.
// Immutable map :)
declare class Map<T, U> {
set(t:T, u:U):Map<T, U>
has(t:T):boolean;
delete(t:T):Map<T,U>
count:number;
}
var provider = new firebase.auth.GoogleAuthProvider();
document.getElementById('signIn').addEventListener('click', function (e) {
firebase.auth().signInWithRedirect(provider);
});
document.getElementById('signOut').addEventListener('click', function (e) {
firebase.auth().signOut()
.then(function () {
console.log('User signed out');
}).catch(function (error) {
var storageRef = firebase.storage().ref('media_content');
document.getElementById('fileUpload').addEventListener('change', function (e) {
var fileToUpload = e.target.files[0];
var fileToUploadRef = storageRef.child(fileToUpload.name);
var task = fileToUploadRef.put(fileToUpload);
// The put method returns an observer called state_changed that can raise the events: running / progress / pause.
// We can use these events to manage UI elements like a progress bar.
// A template for that would be:
// Credits to the awesome Brad Traversy, check out this video at: https://www.youtube.com/watch?v=PP4Tr0l08NE
var messagesRef = firebase.database().ref('messages');
document.getElementById('contactForm').addEventListener('submit', submitForm);
function submitForm(e) {
e.preventDefault(); //prevent reloading the html page
var name = getInputVal('name');
// This is the index.js file in which we write our cloud functions
const https = require('https');
const functions = require('firebase-functions');
// Function that listens to a firestore events
exports.messageSniffer = functions.firestore
.document('forms/{userName}')
.onCreate(event => {
var dataWritten = event.data.data();
import { firestore } from './firebase'
export function updateDocument(path, data) {
return firestore.doc(path).update(data);
}
export function deleteDocument(path) {
return firestore.doc(path).delete();
}