Skip to content

Instantly share code, notes, and snippets.

View calvinmetcalf's full-sized avatar

Calvin Metcalf calvinmetcalf

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Class MyStream extends stream.Writable {
constructor() {
super({objectMode: true})
}
_write(chunk, _, next) {
next();
}
_final(done) {
done();
}
const fs = require('fs');
const stream = require('stream')
const {Transform, Writable} = stream;
const util = require('util');
const pipeline = util.promisify(stream.pipeline);
const csvParser = = require('csv-parser'); // best csv parser
const db = require('./connection');
const readStream = fs.createReadStream('./path/to.csv');
const csv = csvParser(); // turns binary stream into object stream
export default async (knex) => {
const foreignKeys = await knex('pg_constraint')
.select('pg_constraint.conname', 'pg_class.relname')
.where('contype', '=', 'f')
.join('pg_class').on('pg_class.oid', 'pg_constraint.conrelid');
return Promise.all(foreignKeys.map(({relname, conname}) =>
knex.schema.raw(`
ALTER TABLE ??
ALTER CONSTRAINT ??
DEFERRABLE INITIALLY DEFERRED;
/*

#Promises

This file is both legal JavaScript and markdown, so if there are a few quirks like that open comment up there, that is why.

This code is from a [promise library called 'lie'][lie]. You can install it from npm with npm install lie.

The intent of this code is to implement promises in a straightforward way that is as close to the spec as possible while also being readable and performance. The version of promises that ended up being settled on is (as of 10/27/13) a simple constructor which takes as its sole argument a function with 2 arguments, 'fulfill' and 'reject'. Gone are the earlier notions of promises and deferred objects (which is good a I kept trying to spell deferred with 2 Fs and 1 R).

function addPromise(a,b){
var def = deferred();
asyncAdd(a,b,function(err,success){\
if(err){
def.reject(e);
}else{
def.resolve(e);
}
});
return def.promise
// Dollar-Quoted String Constants: see 4.1.2.4 https://www.postgresql.org/docs/9.0/static/sql-syntax-lexical.html
function tagRegex(tag) {
return new RegExp('\\$' + tag + '\\$');
}
function getBase(input) {
var tagBase = 'cartodb';
if (!input.toString().match(tagRegex(tagBase))) {
return tagBase;
}
var i = 0;
fractalModule =function(stdlib){
"use asm";
var pow = stdlib.Math.pow;
var abs = stdlib.Math.abs;
var atan2 = stdlib.Math.atan2;
var cos = stdlib.Math.cos;
var sin = stdlib.Math.sin;
function mandlebrot(cx, cy, maxIter) {
cx = +cx;
cy = +cy;
let x = 'foo'
async function test() {
console.log('top of func', x);
x+= await 'baz'
console.log('bottom of func', x)
}
test()
x = 'bar';
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<title>FazMaraneyRGB_transparent_mosaic_group1</title>
<!-- Leaflet -->
<link rel="stylesheet" href=/home/gabrielschubert/Documents/hawkit_app/guis/pyqt_gui/leaflet/leaflet.css />
<script src=/home/gabrielschubert/Documents/hawkit_app/guis/pyqt_gui/leaflet/leaflet.js ></script>