Skip to content

Instantly share code, notes, and snippets.

@johnnncodes
johnnncodes / postgres_queries_and_commands.sql
Created August 20, 2021 13:40 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@johnnncodes
johnnncodes / nginx.conf
Created September 20, 2019 17:43 — forked from tompave/nginx.conf
commented nginx.conf for Ruby on Rails
# A commented nginx configuration file for Ruby on Rails
#
# Author: Tommaso Pavese
# tommaso@pavese.me
# http://tommaso.pavese.me
#
# License: http://www.wtfpl.net/
#
#
# Tested with:
@johnnncodes
johnnncodes / nginx.conf
Created September 20, 2019 17:43 — forked from tompave/nginx.conf
commented nginx.conf for Ruby on Rails
# A commented nginx configuration file for Ruby on Rails
#
# Author: Tommaso Pavese
# tommaso@pavese.me
# http://tommaso.pavese.me
#
# License: http://www.wtfpl.net/
#
#
# Tested with:
@johnnncodes
johnnncodes / rails_asset_pipeline_compiled_files.rb
Created September 15, 2019 15:57 — forked from mitio/rails_asset_pipeline_compiled_files.rb
Where the Rails' asset pipeline searches for asset files and how the config.assets.precompile directive works
# Test the result of config.assets.precompile
#
# Check which files will be regarded as "manifests" and thus precompiled and be
# available for standalone use via the /assets/<asset> URL when in production.
# Execute this code in your Rails console.
# First, you'll probably be in development mode, so add here your
# additional production precompile patterns you want to test against.
precompile = Rails.configuration.assets.precompile + [/^.+\.css$/, 'active_admin.js']
@johnnncodes
johnnncodes / setup-postgresql-vagrant.md
Created July 11, 2019 06:03 — forked from carymrobbins/setup-postgresql-vagrant.md
Configure PostgreSQL in a Vagrant guest to allow connections from the host.

Configure Postgres

  • Update pg_hba.conf (most likely in /etc/postgresql/9.4/main) with -
    • host all all 0.0.0.0/0 trust
  • Update postgresql.conf to use listen_addresses = '*'
  • Be sure to sudo service postgresql restart

Configure Vagrant

@johnnncodes
johnnncodes / README.md
Created April 10, 2019 06:20 — forked from wankdanker/README.md
Walmart Drop Ship Vendor Supplier DSV Carrier Method Codes

Walmart Drop Ship Vendor Supplier DSV Carrier Method Codes

As part of the Walmart DSV API, there are carrier method codes in the order xml, but the only documentation I found was in this PDF. That document is referenced from Supplier Help.

That PDF file is of course not easily consumable and it was a wicked pain in the ass to get the data out of there. But, it's done now, and if you happen to find this file I hope I saved you some time.

1 Tipperary (IRE)
2 Musselburgh
3 Epsom
4 Santa Anita (USA)
5 Caulfield (AUS)
6 Sha Tin (HK)
7 Chantilly (FR)
8 Dusseldorf (GER)
9 Hanover (GER)
10 Chantilly (fr) (ARAB)
@johnnncodes
johnnncodes / db_backup.sh
Created February 1, 2017 15:14 — forked from bendavis78/db_backup.sh
A simple database backup / rotation / prune script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
package main
import (
"fmt"
"reflect"
"net/url"
)
type ExampleType struct {
Name string `url:"name"`
@johnnncodes
johnnncodes / gist:2275096cd3409da2ee73
Created March 13, 2016 01:42 — forked from jayuen/gist:6787780
DateWithTimezone
define("DateWithTimezone", function(module) {
var DateWithTimezone = function(moment){
this.moment = moment
moment.tz(DateWithTimezone.getTimezone())
}
_.extend(DateWithTimezone.prototype, {
toISO: function(){
return this.format()
},