Skip to content

Instantly share code, notes, and snippets.

// convertJSONValues.js 10/17/16
// node.js file to convert values in a json object / array to the specified format
// This came about because the powershell cmdlets import-csv, ConvertTo-Json store
// numbers as strings
var fs = require("fs")
// input #1 - specify file path
var jsonFilePath = "./activities.json";
@brianvp
brianvp / name_that_rabbit.py
Created January 24, 2016 00:10
Name_that_rabbit
#"You forgot to give Professor Boolean's favorite rabbit specimen a name?
# You know how picky the professor is! Only particular names will do! Fix this immediately, before you're... eliminated!"
# Luckily, your minion friend has already come up with a list of possible names, and we all know that the professor
# has always had a thing for names with lots of letters near the 'tail end' of the alphabet, so to speak. You realize
# that if you assign the value 1 to the letter A, 2 to B, and so on up to 26 for Z, and add up the values for all of the
# letters, the names with the highest total values will be the professor's favorites. For example,
# the name Annie has value 1 + 14 + 14 + 9 + 5 = 43, while the name Earz, though shorter, has value 5 + 1 + 18 + 26 = 50.
# If two names have the same value, Professor Boolean prefers the lexicographically larger name.
# For example, if the names were AL (value 13) and CJ (value 13), he prefers CJ.
# Write a function answer(names) which takes a list of names and re
@brianvp
brianvp / solution.py
Created January 22, 2016 03:38
backward_and_forward
# write a function answer(n) which returns the smallest positive integer base b, at least 2,
# in which the integer n is a palindrome. The input n will satisfy "0 <= n <= 1000."
def answer(n):
base = 1
num1 = -1
num2 = 0
while num1 != num2:
base = base + 1
@brianvp
brianvp / SqlServerTip1_BasicTableTemplate.sql
Created October 7, 2015 02:13
SQL Server Tip #1: Basic Table Template
CREATE TABLE tempdb.dbo.temp1
(
Temp1Id INT IDENTITY(1,1) NOT NULL
CONSTRAINT temp1PrimaryKey PRIMARY KEY CLUSTERED,
VALUE VARCHAR(25),
DateModified datetime2,
DateCreated datetime2 default getdate()
)
GO
@brianvp
brianvp / sql_2012_string_functions.sql
Created June 1, 2015 16:48
SQL Server 2012 String Handling Functions
-- SQL Server 2012 New String Functions
-- CONCAT
select concat('Hello', ', ','World!') -- Hello, World!
select 'Hello' + ', ' + 'World!' -- Hello, World!
select concat('Hello', null,'World!') -- HelloWorld!
select 'Hello' + null + 'World!' -- NULL
@brianvp
brianvp / sql_2012_logical_functions.sql
Created June 1, 2015 13:24
SQL 2012 new Logical Functions
-- SQL 2012 Logical functions
-- 6/1/15
-- CHOOSE
-- must be an integer
declare @Index_Value int
set @Index_Value = 1
@brianvp
brianvp / SQL_2012_2014_Date_Functions.sql
Created June 1, 2015 12:38
SQL Server 2012 Date Functions
-- SQL Server 2012, 2014 new date time functions
-- 6/1/2015
declare @date_example_1 datetime
set @date_example_1 = DATETIMEFROMPARTS(
2015, -- year
6, -- month
1, -- day
7, -- hours
16, -- minutes
@brianvp
brianvp / sql_2014_parse_convert_examples.sql
Created May 29, 2015 16:51
SQL Server 2012 Parse, Try_Convert
-- SQL Server 2012 / 2014 Parsing examples
-- Parsing
declare @String_To_Date_Example_1 datetime2
set @String_To_Date_Example_1 = parse('Friday, May 29 2015 11:21 AM' as datetime2)
select @String_To_Date_Example_1
/* -- Fails
declare @String_To_Date_Example_2 datetime2
@brianvp
brianvp / Create Standard Table.snippet
Created May 29, 2015 16:13
SQL Server 2014 Code Snippet - Create new Tables
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio">
<_locDefault _loc="locNone" />
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag>
<_locTag _loc="locData">Author</_locTag>
<_locTag _loc="locData">ToolTip</_locTag>
</_locDefinition>
<CodeSnippet Format="1.0.0">
@brianvp
brianvp / Create Stored Procedure With Header.snippet
Last active August 29, 2015 14:22
SQL Server 2014 Code Snippet Example - Basic Sproc with Header
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio">
<_locDefault _loc="locNone" />
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag>
<_locTag _loc="locData">Author</_locTag>
<_locTag _loc="locData">ToolTip</_locTag>
</_locDefinition>
<CodeSnippet Format="1.0.0">