Skip to content

Instantly share code, notes, and snippets.

Avatar

Calvin Metcalf calvinmetcalf

View GitHub Profile
View marbles.csv
Team Marble Role
Mellow Yellow Yellow Captain
Mellow Yellow Yelley Member
Mellow Yellow Yellah Member
Mellow Yellow Yellup Member
Mellow Yellow Yellim Reserve
Savage Speeders Speedy Captain
Savage Speeders Rapidly Member
Savage Speeders Swifty Member
Savage Speeders Velocity Member
View w10fix.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View wards1876_1894.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View class.js
Class MyStream extends stream.Writable {
constructor() {
super({objectMode: true})
}
_write(chunk, _, next) {
next();
}
_final(done) {
done();
}
View csv-to-postgres.js
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
View knexDeferAllForeignKeys.js
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;
View quote.js
// 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;
View spoiler.js
let x = 'foo'
async function test() {
console.log('top of func', x);
x+= await 'baz'
console.log('bottom of func', x)
}
test()
x = 'bar';
View index.html
<!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>
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Display buildings in 3D</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.41.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.41.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
You can’t perform that action at this time.