Skip to content

Instantly share code, notes, and snippets.

View ndastur's full-sized avatar

Neville Dastur ndastur

  • Clinical Software Solutions
View GitHub Profile
@ndastur
ndastur / pg_table_fields_dump.txt
Last active February 23, 2020 01:39
Output list of Postgresql tables and their fields on a single bash line
PGUSER=<user> PGPASSWORD=<pw> PGHOST=<host> PGDATABASE=<database> bash -c 'psql -Atc "select tablename from pg_tables where schemaname='\''public'\''" $PGDATABASE | while read TBL; do echo \"$TBL\": { \"keyFields\": [ ; psql -c "COPY (select * from public.$TBL where false) TO STDOUT WITH (FORMAT CSV, HEADER, DELIMITER '\'','\'')" $PGDATABASE | sed '\''s/[^,]*/"&"/g'\'' ; echo ] }, ; done
@ndastur
ndastur / preRequestScript.js
Created July 24, 2019 23:50 — forked from ptrstpp950/preRequestScript.js
Calculate TOTP in Postman
//Article about TOTP on my blog https://stapp.space/generate-totp-in-postman/
/**
* @preserve A JavaScript implementation of the SHA family of hashes, as
* defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
* HMAC implementation as defined in FIPS PUB 198a
*
* Copyright Brian Turek 2008-2017
* Distributed under the BSD License
* See http://caligatio.github.com/jsSHA/ for more information
@ndastur
ndastur / gist:fb997265efd5042aba14c995de3a5407
Created July 12, 2019 00:26
PostgreSQL - Generate a short GUID in a column
CREATE EXTENSION IF NOT EXISTS "hstore";
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE TABLE IF NOT EXISTS tbl (
t_id serial PRIMARY KEY
,txt text
,shortid text
);
@ndastur
ndastur / spectre.c
Created January 6, 2018 12:35 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@ndastur
ndastur / README.md
Created March 9, 2017 14:53 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@ndastur
ndastur / log.js
Last active March 26, 2018 14:42
Server and Client side logging in Meteor using Winston
/*
Add package:
meteor add votercircle:winston
Then use in server or client code as
logger.[debug|info|warn|error]
*/
if(Meteor.isServer) {
//- Ref: https://atmospherejs.com/votercircle/winston
//- Setup Winston logging
@ndastur
ndastur / LegacyAppceleratorCLIAlias.md
Last active August 29, 2015 14:01
Better alias for defining the Legacy Appcelerator CLI

Instructions in the Appcelerator Legacy CLI docs suggest setting up aliases. But these require manual adjustment when new versions are installed. This automacitally links to the latest legacy CLI.

LATEST_TI=$(ls -1 $HOME/Library/Application\ Support/Titanium/mobilesdk/osx/ | sort -r | head -1)
alias titanium.py="$HOME/Library/Application\ Support/Titanium/mobilesdk/osx/$LATEST_TI/titanium.py"
alias ios_builder="$HOME/Library/Application\ Support/Titanium/mobilesdk/osx/$LATEST_TI/iphone/builder.py"
@ndastur
ndastur / Generate alloy controller and add to git
Created August 26, 2013 18:53
Add this function to your .profile file to ease making alloy controllers and adding to git
function alloy_generate_ctrl {
alloy generate controller $1 && git add app/controllers/$1.js && git add app/views/$1.xml && git add app/styles/$1.tss
}
/*
The MIT License
Copyright (c) 2010 Roger Chapman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
// add all items to collection
Alloy.Collections.Fugitive.reset([{
"name" : "Jeff Haynie"
}, {
"name" : "Nolan Wright"
}, {
"name" : "Don Thorp"
}, {
"name" : "Marshall Culpepper"
}, {