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
private static bool IsWholeNumericType(Type t) | |
{ | |
var numericTypes = new[] { | |
typeof(Byte), typeof(Int16), typeof(Int32), | |
typeof(Int64), typeof(SByte), typeof(Single), | |
typeof(UInt16), typeof(UInt32), typeof(UInt64) | |
}; | |
return numericTypes.Contains(t); | |
} |
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
if (!Number.prototype.padLeft) { | |
// Pad the left of a number with a character | |
Number.prototype.padLeft = function (len, chr) { | |
var self = Math.abs(this) + ''; | |
return (this < 0 && '-' || '') + | |
(String(Math.pow(10, (len || 2) - self.length)) | |
.slice(1).replace(/0/g, chr || '0') + self); | |
}; | |
} |
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
if (!String.prototype.format) { | |
// Equivalent to C# String.Format | |
String.prototype.format = function () { | |
var args = arguments; | |
return this.replace(/{(\d+)}/g, function (match, number) { | |
return typeof args[number] != 'undefined' | |
? args[number] | |
: match | |
; | |
}); |
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
struct Range | |
{ | |
private int _min; | |
public int Min | |
{ | |
get { return _min; } | |
set | |
{ | |
_min = value > _max ? _max : value; | |
} |
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
import os | |
import re | |
import sys | |
import urllib.error | |
import urllib.request | |
if len(sys.argv) != 2: | |
print("Please specify destination directory as an argument") | |
sys.exit(-1) |
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
Get-ChildItem $env:TEMP -Recurse | Remove-Item -Force -Recurse -WhatIf |
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
#!/bin/bash | |
wget -O- http://www.oreilly.com/programming/free/ | tr '"' \\n | grep http | grep free | cut -d "?" -f1 | sed 's/free/free\/files/' | sed 's/\.csp/\.pdf/' | xargs wget -P ebook |
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
def Ackermann(x, y): | |
answer = 0 | |
if x == 0: | |
answer = y + 1 | |
elif y == 0: | |
answer = Ackermann(x - 1, 1) | |
else: | |
answer = Ackermann(x - 1, Ackermann(x, y - 1)) | |
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
if (!String.prototype.padLeft) { | |
String.prototype.padLeft = function(c, size) { | |
var s = this.valueOf(); | |
while (s.length < size) s = c + s; | |
return s; | |
}; | |
} |
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
echo "g(i,x,t,o){return((3&x&(i*((3&i>>16?\"BY}6YB6%\":\"Qj}6jQ6%\")[t%8]+51)>>o))<<4);};main(i,n,s){for(i=0;;i++)putchar(g(i,1,n=i>>14,12)+g(i,s=i>>17,n^i>>13,10)+g(i,s/3,n+((i>>11)%3),10)+g(i,s/5,8+n-((i>>10)%3),9));}"|gcc -xc -&&./a.out|aplay |
OlderNewer