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
class Solution(object): | |
def reverse(self, x): | |
""" | |
:type x: int | |
:rtype: int | |
""" | |
result = 0; | |
if x > 0: | |
result = int(str(x)[::-1]) | |
else: |
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
/** | |
* @param {string} s | |
* @return {string} | |
*/ | |
var longestPalindrome = function(s) { | |
var longest = s[0]; | |
for(var i = 0; i < s.length;i++){ | |
palen = ''; | |
var j = -1; | |
var k = -1; |
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
using System.Collections.Generic; | |
using System.Linq; | |
using Xunit; | |
namespace IsBST | |
{ | |
public class BSTTester | |
{ | |
public static bool IsBST(Node root) | |
{ |
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
/// <summary> | |
/// Extensions for memory cache. | |
/// </summary> | |
public static class MemoryCacheExtensions | |
{ | |
/// <summary> | |
/// Add result to memory cache. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="cache"></param> |
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
import random | |
import string | |
minLen = 3 | |
maxLen = 8 | |
vowels = ['a', 'e', 'i', 'o', 'u'] | |
consonantExclude = ['q'] | |
consonants = [a for a in string.ascii_lowercase if a not in vowels and a not in consonantExclude] | |
charpairs = ['qu', 'th', 'ch'] |
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
/* Jquery function to create guids. | |
* Guid code from | |
* http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript | |
*/ | |
(function ( $ ) { | |
$.fn.newguid = function () { | |
this.val('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8; return v.toString(16); })); | |
return this; | |
}; |
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 static class Fakes | |
{ | |
public static ODataQueryOptions ODataQueryOptionsFake(Type itemtype, HttpRequestMessage request, string expandValue, string inlineCountValue) | |
{ | |
var odataQueryOptionsFake = new ODataQueryOptions(Substitute.For<ODataQueryContext>(Substitute.For<IEdmModel>(), itemtype), request); | |
var rawValuesFake = new ODataRawQueryOptions(); | |
typeof(ODataRawQueryOptions).GetProperty("Expand").SetValue(rawValuesFake, expandValue); | |
typeof(ODataRawQueryOptions).GetProperty("InlineCount").SetValue(rawValuesFake, inlineCountValue); | |
typeof(ODataQueryOptions).GetProperty("RawValues").SetValue(odataQueryOptionsFake, rawValuesFake); | |
return odataQueryOptionsFake; |
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
<# | |
.SYNOPSIS | |
This is a powershell script to ping a website and log the response | |
.DESCRIPTION | |
The script will send a web request to the site specified in the parameters, and log to the file specified in the parameters (if any) | |
.EXAMPLE | |
./api.warmup.ps1 -url http://api.mysite.com/ -logFile logfile.txt |
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 static class DictionaryExtensions | |
{ | |
/// <summary> | |
/// Add a range of items to a dictionary. | |
/// </summary> | |
/// <typeparam name="T">type</typeparam> | |
/// <typeparam name="TU">type</typeparam> | |
/// <param name="source">the dictionary</param> | |
/// <param name="dictionary">the range to be added</param> | |
public static void AddRange<T, TU>(this IDictionary<T, TU> source, IDictionary<T, TU> dictionary) |
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
using System; | |
namespace Utils | |
{ | |
public abstract class MessageWriter | |
{ | |
public Action<string, object[]> Writer { get; set; } | |
/// <summary> | |
/// If the Writer method is not null, writes the message to it. |
NewerOlder