Skip to content

Instantly share code, notes, and snippets.

Avatar

Calvin Metcalf calvinmetcalf

View GitHub Profile
@calvinmetcalf
calvinmetcalf / README.md
Last active Jun 9, 2021
arcpy tutorial
View README.md

Let's make a tool!

import arcpy, os, tempfile

import is used to bring in another library, here we bring in:

  • arcpy which is the esri library and
  • os which for Operating system things
  • tempfile is for making temperary files
View wordlist.txt
Wordlist ver 0.732 - EXPECT INCOMPATIBLE CHANGES;
acrobat africa alaska albert albino album
alcohol alex alpha amadeus amanda amazon
america analog animal antenna antonio apollo
april aroma artist aspirin athlete atlas
banana bandit banjo bikini bingo bonus
camera canada carbon casino catalog cinema
citizen cobra comet compact complex context
credit critic crystal culture david delta
dialog diploma doctor domino dragon drama
View alltogether.coffee
class PouchCore
constructor: (@remoteUrl,@onChange)->
if @remoteUrl.slice(0,4)=="http" #did we get a real url?
parts = @remoteUrl.split("/") #split the url bu by the slashes
@_dbName = parts.pop() #assign the last part as the db name
while @_dbName == "" #unless it is an empty string
@_dbName = parts.pop()#repeat until you find one
Pouch @_dbName, (e, db) => #making the local db
unless e #error would imply we are on an old browser
@db = db
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 pbkdf2.js
function pbkdf2(password, salt, iterations, len, hashType) {
hashType = hashType || 'sha1';
if (!Buffer.isBuffer(password)) {
password = new Buffer(password);
}
if (!Buffer.isBuffer(salt)) {
salt = new Buffer(salt);
}
var out = new Buffer('');
var md, prev, i, j;
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;