Skip to content

Instantly share code, notes, and snippets.

View jeffjohnson9046's full-sized avatar

Jefe Johnson jeffjohnson9046

View GitHub Profile
@jeffjohnson9046
jeffjohnson9046 / heroku-db-backup-copy.sh
Created March 31, 2015 18:55
Heroku: Take Database Backup and Restore Locally
# NOTE: These steps assume the following:
# * The heroku toolbelt is installed: https://toolbelt.heroku.com/
# * A postgres server is installed and running: http://www.enterprisedb.com/products-services-training/pgdownload#osx
# STEP 1: Login to herku:
heroku login
# provide credentials
# STEP 2: Create database backup
heroku pg:backups public-url b001 --app <the name of your heroku application>
@jeffjohnson9046
jeffjohnson9046 / sp_configure-options.sql
Created May 14, 2015 18:24
A collection of some commonly-used options for sp_configure in MSSQL Server
sp_configure 'show advanced options', 1
reconfigure;
-- show advanced options
-- backup compression default -- always compress backups.
-- blocked process threshold (s) -- only capture blocking scenarios that block this threshold.
-- clr enabled -- allows CLR user-defined stored procedures and functions.
-- Database Mail XPs
-- fill factor (%) -- useful for reducing fragmentation (for frequently updated tables). Reduces page-splitting when a record has be inserted in the middle of the page
-- max degree of parallelism -- set the max number of CPUs that are available for a single query. Can be overridden by MAX DOP setting on a query
-- remote access -- grant/revoke ability to allow remote users to access the SQL Server from external connections
@jeffjohnson9046
jeffjohnson9046 / sql-server-foreign-key-references.sql
Created June 3, 2015 19:48
Find all tables that reference a table via foreign key relationship in MSSQL.
SELECT
OBJECT_NAME(f.parent_object_id) TableName,
COL_NAME(fc.parent_object_id,fc.parent_column_id) ColName
FROM
sys.foreign_keys AS f
INNER JOIN
sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id
INNER JOIN
sys.tables t
@jeffjohnson9046
jeffjohnson9046 / supervisord-sample-program.ini
Created June 30, 2015 18:16
A sample INI/configuration file for programs that should be monitored by Supervisor
[program:your_program_name_here]
command=;command to start your program
user=;user that your program should run as
autostart=true
autorestart=true
startsecs=10
startretries=3
stdout_logfile=;path to log file, e.g. /var/log/your_program_name_here-stdout.log
stdout_logfile_maxbytes=128MB
stdout_logfile_backups=32
@jeffjohnson9046
jeffjohnson9046 / index-fill-factor.sql
Created July 27, 2015 06:14
MSSQL: Inspect Indexes and their fill factor settings
SELECT OBJECT_NAME(object_id) as table_name, name, type_desc, is_primary_key, fill_factor FROM sys.indexes;
USE [whatever database]
GO
ALTER INDEX PK_GeoRoot ON GeoRoot
REBUILD WITH (FILLFACTOR = 80);
/* Check existing indexes */
SELECT
@@SERVERNAME AS [ServerName]
, DB_NAME() AS [DatabaseName]
, [SchemaName]
, [ObjectName]
, [ObjectType]
, [IndexID]
, [IndexName]
, [IndexType]
@jeffjohnson9046
jeffjohnson9046 / .gitignore
Created August 11, 2015 21:12
Visual Studio .gitignore used @ Fairway
Thumbs.db
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
@jeffjohnson9046
jeffjohnson9046 / ImageSelectListItem.cs
Created August 16, 2012 19:00
Describes the ImageListItem class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace System.Web.Mvc.Html
{
public class ImageSelectListItem : SelectListItem
{
public string ImageFileName { get; set; }
@jeffjohnson9046
jeffjohnson9046 / ListItemToOption.cs
Created August 16, 2012 19:03
Describes how the title attribute is added to the option element
internal static string ListItemToOption(ImageSelectListItem item, string imagePath = "")
{
//if (!(item is ImageSelectListItem))
//{
// throw new InvalidCastException(string.Format("Cannot cast {0} to System.Web.Mvc.Html.ImageImageSelectListItem.", item.GetType()));
//}
//ImageSelectListItem imageImageSelectListItem = item as ImageSelectListItem;
TagBuilder builder = new TagBuilder("option")
@jeffjohnson9046
jeffjohnson9046 / sql-server-product-info.sql
Created December 23, 2015 07:51
SQL Server Product Information
/* Run this query against any database on a SQL Server instance to get version details*/
SELECT
SERVERPROPERTY('productversion') AS ProductVersion,
SERVERPROPERTY('productlevel') AS ProductLevel,
SERVERPROPERTY('edition') AS Edition,
@@VERSION AS VerboseVersion;