Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# USAGE: sh whois.sh /path/to/file.txt
# RESULT: domain.com ORG_NAME
for domain in `cat $1`
do
# str_domain=${domain#www.} # strip a leading www.
@sgraham785
sgraham785 / auto-git-tag
Created May 24, 2018 16:54
auto-git-tag the npm version when publishing
{
"scripts": {
"postpublish" : "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push --tags"
}
}
Where node binary is available:
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
@sgraham785
sgraham785 / pgsql_upsert.sql
Created March 23, 2018 15:45
Examples of PostgreSQL Upsert
INSERT INTO users (id, level)
VALUES (1, 0)
ON CONFLICT (id) DO UPDATE
SET level = users.level + 1;
INSERT INTO users (id, email)
VALUES (1, somenew@email.com)
ON CONFLICT (id) DO UPDATE
SET email = EXCLUDED.email;
@sgraham785
sgraham785 / pg_premissions.sql
Created February 22, 2018 06:15
Postgres DB Permissions example
--ACCESS DB
REVOKE CONNECT ON DATABASE nova FROM PUBLIC;
GRANT CONNECT ON DATABASE nova TO user;
--ACCESS SCHEMA
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT USAGE ON SCHEMA public TO user;
--ACCESS TABLES
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM PUBLIC ;
message ObjectId {
// Unordered map of dynamically typed values.
map<string, Value> id = 1;
string _bsontype = 2; // should return "ObjectId"
}
// The JSON representation for `Value` is JSON value.
enum Value {
VALUE = 1;
}
@sgraham785
sgraham785 / README.md
Last active January 10, 2017 21:35
Project README.md Starter Template

Project Title

TODO: Write a project description

Prerequisites

TODO: Add requirements and dependencies

Installation

change to postgres user and open psql prompt

sudo -u postgres psql postgres`

list databases

postgres=# \l
@sgraham785
sgraham785 / dig_domains.sh
Created January 21, 2015 20:12
Dig domains from txt file
#!/bin/bash
## HOW TO USE
# sh dig_domains.sh A "8.8.8.8" (this returns the A records)
# domain.com 1224 IN A 127.0.0.1
# sh dig_domains.sh A "8.8.8.8" "mail." (returns the mail. subdomain A records)
# mail.domain1.com. 14399 IN CNAME domain1.com.
# mail.domain2.com. 3599 IN A 127.0.0.1
@sgraham785
sgraham785 / rm-rf_svn
Created January 21, 2015 20:02
Recursively rm .svn
find . -type d -name .svn -exec rm -rf {} \;
#!/bin/sh
rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
curl -L https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.0.0
rvm use 2.0.0@global --default
### install bundler and rails
gem install bundler --no-ri --no-rdoc