Skip to content

Instantly share code, notes, and snippets.

View Azerothian's full-sized avatar
♾️
Over thinking, over analyzing separates the body from the mind

Matthew Mckenzie Azerothian

♾️
Over thinking, over analyzing separates the body from the mind
View GitHub Profile
#!/usr/bin/env sh
TEMPLATE_FILE=$1
ENV_PREFIX=$2
env | grep "^$ENV_PREFIX" | while IFS="=" read -r name value; do
printf "s/%s/%q/\n" "${name}" "$value"
done > sed-script.txt
cat sed-script.txt # Optional
sed -f sed-script.txt "$TEMPLATE_FILE"
@Azerothian
Azerothian / duplicates.sql
Created September 16, 2015 01:58
How to delete rows that are duplicates over a set of columns, keeping only the one with the lowest ID.
DELETE FROM tablename
WHERE id IN (SELECT id
FROM (SELECT id,
ROW_NUMBER() OVER (partition BY column1, column2, column3 ORDER BY id) AS rnum
FROM tablename) t
WHERE t.rnum > 1);
debug = require "debug"
debug.enable('mrc:*')
module.exports = (prefix="", suffix=":") ->
return {
log: debug "#{prefix}log#{suffix}"
debug: debug "#{prefix}debug#{suffix}"
sql: debug "#{prefix}debug:sql#{suffix}"
info: debug "#{prefix}info#{suffix}"
error: debug "#{prefix}error#{suffix}"
@Azerothian
Azerothian / launcher.coffee
Last active September 14, 2015 07:55
Expects target file to export a Promise. use stdin and stdout for comms between new instance of node
log = require("./logger")("mrc:launcher:")
if require.main == module
file = process.argv[2]
console.log "start", file
target = require file
process.on "message", (args) ->
sendResponse = (status, data) ->
process.send { status, data }
process.exit(0)
return target.apply(undefined, args).then (result) ->
char *at = strchr(ifName, '@');
char *topic = (char*)"flow", *endpoint;
if(at != NULL)
endpoint = &at[1];
else
endpoint = ifName;
iface = new CollectorInterface(endpoint, topic);
WITH x AS (
SELECT count(*) AS ct
,sum(length(t::text)) AS txt_len -- length in characters
,'TABLENAME'::regclass AS tbl
FROM TABLENAME t
)
, y AS (
SELECT ARRAY [
pg_relation_size(tbl)
save = () ->
return new Promise (resolve, reject) ->
# do save shit
return resolve()
promises = []
for i in array
promises.push save(i)
/*
Promise = require "native-or-bluebird"
checkDatabase = (db) ->
return new Promise (resolve, reject) ->
return db.exists (err, exists) ->
if err?
return reject(err);
if exists
return resolve(db)
Promise = require "native-or-bluebird"
checkDatabase = (db) ->
return new Promise (resolve, reject) ->
return db.exists (err, exists) ->
if err?
return reject(err);
if exists
return resolve(db)
var ECT, app, ectRenderer, express, rc, reacta;
express = require('express');
reacta = require("reacta");
app = express();
ECT = require('ect');