This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
import io | |
""" | |
Input file might look something like this: | |
cat input.txt | |
some ñ thing | |
foo ñññ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set up an associative array for the error messages. The keys must be the exact name of the | |
// controls that need to have the error message displayed. | |
var errorArray = { | |
SomeProperty: "'SomeProperty' has shit the bed", | |
SomeOtherProperty: "Whoa - TWO errors? You are up the creek" | |
}; | |
// Show the errors next to their associated controls | |
$('#form-to-validate').validate().showErrors(errorArray); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Accepted answer from here: https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-database-if-there-are-active-connections-to-it | |
SELECT pg_terminate_backend(pg_stat_activity.pid) | |
FROM pg_stat_activity | |
WHERE pg_stat_activity.datname = '[your database name goes here]' | |
AND pid <> pg_backend_pid(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Encrypt | |
curl -sbiL -X POST http://localhost:8888/encrypt -d '[the value you want to encrypt]' | |
# Decrypt | |
curl -sbiL -X POST http://localhost:8888/decrypt -d '[the encrypted value, without the "{cipher}" prefix]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Get a value <code>V</code> for the specified key <code>K</code>. If there is no value for the specified | |
/// key, return a default value instead. | |
/// </summary> | |
/// <remarks> | |
/// This code emulates the Java <code>GetOrDefault()</code> method on a <code>Map</code>. It's also a convenient | |
/// way to "inline" the <code>Dictionary#TryParse</code> and have it return some value in the event the key we're | |
/// looking for doesn't exist. | |
/// </remarks> | |
/// <example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// A class for rolling back database transactions after the test has completed. | |
/// </summary> | |
[TestClass] | |
public abstract class TransactionRollbackIntegrationTestBase | |
{ | |
private TransactionScope transactionScope; | |
/// <summary> | |
/// Create the transaction scope to enforce creating a new transaction prior to the test executing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Based on answer from here: | |
-- https://stackoverflow.com/questions/483193/how-can-i-list-all-foreign-keys-referencing-a-given-table-in-sql-server | |
SELECT | |
child.name AS child_table, | |
fk.constraint_column_id AS fk_part_no, | |
c.name AS foreign_key_column | |
FROM | |
sys.foreign_key_columns AS fk | |
JOIN | |
sys.tables child |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Second answer from here: https://stackoverflow.com/questions/14704105/search-text-in-stored-procedure-in-sql-server | |
SELECT | |
name, | |
SCHEMA_NAME(schema_id) AS [schema] | |
FROM | |
sys.procedures | |
WHERE | |
OBJECT_DEFINITION(object_id) LIKE '%whatever text you are looking for%'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
@backupMsg varchar(max), | |
@backupPath varchar(max), | |
@backupCommand varchar(max), | |
@dbName varchar(max); | |
SELECT | |
@backupMsg = 'Full backup', | |
@backupPath = 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- from here: https://gallery.technet.microsoft.com/scriptcenter/Rebuild-and-Reorganize-7ff5624e | |
DECLARE | |
@fragPercentThreshold decimal(11,2), | |
@schemaName nvarchar(128); | |
-- Determine maximum fragmentation threshold and the schema to operate against | |
SET @fragPercentThreshold = 5.0; | |
SET @schemaName = N'dbo'; |