Skip to content

Instantly share code, notes, and snippets.

View drobison's full-sized avatar

David Robison drobison

View GitHub Profile
@drobison
drobison / gist:4165b70faaee71a9ba21965d82af18c6
Created July 15, 2020 05:37
1249 - Minimum Remove to Make Valid Parentheses
//https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/
public class Solution {
public string MinRemoveToMakeValid(string s) {
// use a stack
// store the index of the (
// itterate through string
// when we get to ( push index to stack
// when we get to ), if there is an item on stack, pop
// if there is not mark ) to remove
public class MinIntHeap
{
private static int _capacity = 10;
private int _currentSize = 0;
private int[] _items = new int[_capacity];
public int Peek()
{
if (_currentSize == 0) throw new Exception();
@drobison
drobison / gist:1f321eb55136aba94dad53f32d858c3d
Last active January 11, 2017 19:42 — forked from stevenkuhn/gist:5062660
This PowerShell script generates release notes for Octopus Deploy that contain the GitHub commits and JIRA issues from the current build to the latest production release. It will also create the Octopus release based on the TeamCity build number.
#
# Assumptions
#
# 1. If you have a Octopus release deployed, say 1.0.0.73, there is a git
# tag set for that commit in GitHub that is "v1.0.0.73".
#
# 2. You have TeamCity label each successful build in GitHub with the format
# "v{build number}. Sidenote: it appears that TeamCity only labels the
# default branch, but not feature branches.
#
// http://stackoverflow.com/a/2343659/1674958
// CREATE TABLE table2 LIKE table1;
If the table doesn't exist, you can create one with the same schema like so:
// Then, to copy the data over:
INSERT INTO table2 SELECT * FROM table1
@drobison
drobison / C# Code
Created June 26, 2015 20:23
C# Get A Connection String From Configurations
var connection = System.Configuration.ConfigurationManager.ConnectionStrings["Test"].ConnectionString;
@drobison
drobison / gist:61c4a13ae8d78ff89cc5
Created April 22, 2015 21:33
ASP.NET C# Web Forms File Download
private void PresentFileDownload(byte[] file, string contentType, string fileName, string fileExtension)
{
Response.Clear();
MemoryStream ms = new MemoryStream(file);
Response.ContentType = contentType;
Response.AddHeader("Content-disposition", "attachment;filename=" + fileName);
Response.Buffer = true;
ms.WriteTo(Response.OutputStream);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
@drobison
drobison / gist:9673832
Created March 20, 2014 21:07
Copy a table into a new table in SQL
SELECT *
INTO NewTable
FROM OldTable
@drobison
drobison / gist:9282857
Created March 1, 2014 00:36
Toogle ASP.NET RequiredFieldValidator in Javascript
// Toggle validator on
ValidatorEnable(document.getElementById('rfv_name'), true);
// Toggle validator off
ValidatorEnable(document.getElementById('rfv_name'), false);
@drobison
drobison / gist:9147755
Created February 22, 2014 02:31
Find latest entry in a group SQL
SELECT p.id
FROM Posts as p
JOIN (
SELECT id
, MAX(date_modified) as ModifiedDate
FROM Posts
GROUP BY user_id
) lastPost ON p.id = lastPost.id
AND p.date_modified = lastPost.ModifiedDate
order by p.user_id
@drobison
drobison / gist:9144161
Created February 21, 2014 21:45
Find duplicates in SQL
select field1
, field2
, field3
, count(*) as Count
from table
group by field1,field2,field3
having count(*) > 1