Skip to content

Instantly share code, notes, and snippets.

View Paretkf's full-sized avatar
🏠
Working from home

Rachata Paretkf

🏠
Working from home
View GitHub Profile
@Paretkf
Paretkf / index.js
Created June 10, 2018 15:02
cloud function (No transaction)
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp({ credential: admin.credential.applicationDefault() })
var db = admin.firestore()
exports.getBalance = functions.https.onRequest((req, res) => {
let data = db.collection('Bank').doc('1').get() // collection ของ DB ที่มี Document ที่ชื่อว่า 1
.then(c => {
if (c.exists) {
@Paretkf
Paretkf / index.js
Created June 10, 2018 14:18
Learn Firestore
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp({ credential: admin.credential.applicationDefault() })
var db = admin.firestore()
exports.getBalance = functions.https.onRequest((req, res) => {
let data = db.collection('Bank').doc('1').get() // collection ของ DB ที่มี Document ที่ชื่อว่า 1
.then(c => {
if (c.exists) {
#--------------------------------------------------
# VRT Rule Packages Snort.conf
#
# For more information visit us at:
# http://www.snort.org Snort Website
# http://vrt-blog.snort.org/ Sourcefire VRT Blog
#
# Mailing list Contact: snort-sigs@lists.sourceforge.net
# False Positive reports: fp@sourcefire.com
# Snort bugs: bugs@snort.org
# Copyright 2001-2018 Sourcefire, Inc. All Rights Reserved.
#
# This file contains (i) proprietary rules that were created, tested and certified by
# Sourcefire, Inc. (the "VRT Certified Rules") that are distributed under the VRT
# Certified Rules License Agreement (v 2.0), and (ii) rules that were created by
# Sourcefire and other third parties (the "GPL Rules") that are distributed under the
# GNU General Public License (GPL), v2.
#
# The VRT Certified Rules are owned by Sourcefire, Inc. The GPL Rules were created
# by Sourcefire and other third parties. The GPL Rules created by Sourcefire are
var express = require('express')
const Todo = require('../models/todo')
const User = require('../models/user')
var session = require('express-session')
const app = express()
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true
const mongoose = require('mongoose')
const Schema = mongoose.Schema
const User = new Schema({
email: String,
password: String
})
module.exports = mongoose.model('User', User)
var express = require('express')
const Todo = require('../models/todo')
const app = express()
app.get('/todos', (request, response) => {
Todo.find().then(todos => {
response.json({todos})
})
})
app.post('/post', (request, response) => {
require('dotenv').config()
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
const todos = require('./app/routers/todos')
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
const mongoose = require('mongoose')
const Schema = mongoose.Schema
const Todo = new Schema({
description: String,
done: Boolean
})
module.exports = mongoose.model('Todo', Todo)
require('dotenv').config()
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
mongoose.connect(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@${process.env.MONGO_HOST}/Todo`, { useMongoClient: true })