This file contains hidden or 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
//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 |
This file contains hidden or 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
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(); | |
This file contains hidden or 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
# | |
# 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. | |
# |
This file contains hidden or 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
// 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 |
This file contains hidden or 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
var connection = System.Configuration.ConfigurationManager.ConnectionStrings["Test"].ConnectionString; |
This file contains hidden or 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
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(); | |
} |
This file contains hidden or 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
SELECT * | |
INTO NewTable | |
FROM OldTable |
This file contains hidden or 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
// Toggle validator on | |
ValidatorEnable(document.getElementById('rfv_name'), true); | |
// Toggle validator off | |
ValidatorEnable(document.getElementById('rfv_name'), false); |
This file contains hidden or 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
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 |
This file contains hidden or 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
select field1 | |
, field2 | |
, field3 | |
, count(*) as Count | |
from table | |
group by field1,field2,field3 | |
having count(*) > 1 |
NewerOlder