This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pg = require('pg'); | |
var request = require('request'); | |
var async = require('async'); | |
function getUrl(location) { | |
return 'https://maps.googleapis.com/maps/api/geocode/json?address=' + location.address + ', ' + location.city + ', ' + location.state + ' ' + location.zip_code; | |
} | |
var count = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logAndNext() { | |
app.get('log').pageRequested({ ip : ip, pos : req.session.pos, page : req.url, method : req.method }, function(err) { | |
if (err) throw err; | |
next(); | |
}); | |
} | |
if (!req.session.pos) { | |
app.get('db').getPosByIp(ip, function(err, pos) { | |
req.session.pos = pos; | |
logAndNext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.postClassified = function(data, callback) { | |
var tx = new Transaction(client); | |
async.waterfall([ | |
function(cb) { tx.begin(cb); }, | |
function(result, cb) { | |
if (!data.image_name) return cb(null, null); | |
tx.query("INSERT INTO images (file_name) VALUES ($1) RETURNING id", [data.image_name], cb); | |
}, | |
function(result, cb) { | |
tx.query("INSERT INTO classifieds (email, phone_number, name, posting_title, price, address, image, posting_body, condition) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var moment = require('moment'); | |
var queryBuilder = require('./queryBuilder.js').bind(null, 'https://someurl.com'); | |
module.exports = helpers = {}; | |
/* delete all key/value pairs on obj that are equal to the provided val */ | |
helpers.deleteAll = function(obj, val) { | |
for (var key in obj) | |
if ((typeof obj[key] === 'string' ? obj[key].trim() : obj[key]) === val) | |
delete obj[key]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* app.js */ | |
var express = require('express'); | |
var app = express(); | |
app.set('db', myDbHandle) | |
var login = require('./lib/login'); | |
app.use(login(app)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS items ( | |
id serial PRIMARY KEY | |
); | |
CREATE TABLE IF NOT EXISTS industries ( | |
id serial PRIMARY KEY, | |
name text UNIQUE NOT NULL | |
); | |
CREATE TABLE IF NOT EXISTS items_industries ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cb() { | |
console.log(iNeedThis); | |
} | |
var myModule = { | |
myMethod : function() { | |
var iNeedThis; | |
setTimeout(cb, 0); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS items_industries ( | |
item integer REFERENCES items(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, | |
industry integer REFERENCES industries(id) ON DELETE CASCADE | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TYPE feedback_type AS ENUM('rolloffs', 'waste', 'hauling', 'commerical', 'residential'); | |
CREATE TABLE IF NOT EXISTS company_feedback ( | |
id serial PRIMARY KEY, | |
company integer REFERENCES companies(id) NOT NULL, | |
ip text NOT NULL, | |
"type" feedback_type NOT NULL, | |
affirmative boolean NOT NULL | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package data_structures; | |
import java.util.Iterator; | |
import java.util.Arrays; | |
import java.lang.*; | |
public class OrderedVector<E> implements Iterable<E> { | |
private E[] arr; | |
private int size; | |
private static final int DEFAULT_MAX_CAPACITY = 2; |