Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
nomoney4me / gist:fa53ccacf12ff7c2fce8
Created October 23, 2015 15:05 — forked from mhawksey/gist:1276293
Google App Script to insert data to a google spreadsheet via POST or GET
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
<html>
<form>
</form>
<script>
/*
on form submit -> post to index2.js -> console.log(result from index2.js)
*/
</script>
require('dotenv').config()
var express = require('express')
, app = express()
, bodyParser = require('body-parser')
, fetch = require('node-fetch')
, cookieParser = require('cookie-parser')
, Promise = require('bluebird')
const {URLSearchParams} = require('url');
app.use(cookieParser())
<!doctype html>
<html>
<head>
<script src="/js/vue.js"></script>
</head>
<body>
<div id="mycontainer">
<input id="search" type="Submit" value="Search for nearby restaurants" @click="search" />
<div id="err"></div>
<table>
require('dotenv').config()
var ldap = require('ldapjs')
, Promise = require('bluebird')
process.env.NOD_TLS_REJECT_UNAUTHORIZED = "0";
var client = ldap.createClient({
url: process.env.ldaphost
});
require('dotenv').config()
var ldap = require('ldapjs')
, Promise = require('bluebird')
, express = require('express')
, app = express()
//process.env.NOD_TLS_REJECT_UNAUTHORIZED = "0";
var ldapClient = ldap.createClient({
url: process.env.ldaphost
app.get('/conflictMatrix', (req, res) => {
var token = Promise.try(() => {
return tokenPromise()
})
var courses = knex('offered_courses').select('*').where('NumSections','<',3).andWhere('Offered', 1).map((row) => {
row.conflicts = {};
return row
}).then(rows => rows);
Promise.all([courses, token]).then((values) => {
Promise.try(() => {
return Promise.all([
knex('course_requests').select('*'),
knex('course_requests').distinct('CourseTitle').select().groupBy('CourseTitle')
])
}).then(([allrecords, rows]) => {
var obj = rows;
/* I'm trying to take each of the data and insert the object of itself: something like this
Turning [A,B,C,D,E] into => [A: {A,B,C,D,E}, B:{A,B,C,D,E}, C:{A,B,C,D,E}, etc...you get the point..]
Promise.try(() => {
return Promise.all([
knex('course_requests').select('*'),
knex.raw('select distinct(CourseTitle) as courses from course_requests group by CourseTitle')
])
}).then(([allrecords, rows]) => {
console.log(rows)
})
/* Console.log(rows)
Promise.try(() => {
return Promise.all([
knex('course_requests').select('*'),
knex('course_requests').distinct('CourseTitle').select().groupBy('CourseTitle')
])
}).then(([allrecords, rows]) => {
/*
if rows: [
A: {
foo:bar,