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
# Ethiopian Multiplication | |
# usage: ruby em.rb 673 7 | |
m, n = ARGV.map(&:to_i) | |
product = 0 | |
while m >= 1 | |
puts "%4d : %4d %s" % [m, n, m.even? ? "Ignore" : ""] | |
product += n unless m.even? | |
m = m / 2 | |
n = n * 2 | |
end |
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
The 10 longest user-agent strings from my access log. | |
All of the are from Internet Explorer and the longest is 370 characters. This is silly! | |
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS129735; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; WWTClient2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; InfoPath.2; InfoPath.3; .NET4.0C; .NET4.0E) | |
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS125042; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; BO1IE8_v1;ENUS) | |
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; YPC 3.2.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.0.3705; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; msn OptimizedIE8;ENGB) | |
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5. |
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 EnumTest | |
{ | |
public enum Cities { AnkhMorpork = 1, Ampridatvir, Lankhmar }; | |
public Cities cities { get; set; } | |
public void WriteCities() | |
{ | |
Cities test = (Cities)4711; | |
Console.WriteLine(test); | |
Console.WriteLine(cities); |
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
<?xml version="1.0"?> | |
<!DOCTYPE b [ | |
<!ENTITY a "na "> | |
<!ENTITY t "&a;&a;&a;&a;&a;&a;"> | |
<!ENTITY na "&t;&t;&t;&t;&t;&t;">]> | |
<b>&na; BATMAN!</b> |
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 numbers = new[] { 8, 12, 21 }; | |
var biggerThan12 = numbers.Where(n => n > 12); | |
numbers[1] = 13; | |
foreach (var number in biggerThan12) | |
{ | |
Console.WriteLine(number); |
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; | |
using System.Diagnostics; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace test | |
{ | |
class Person | |
{ | |
public int Number { get; set; } |
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; | |
using System.Diagnostics; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace test | |
{ | |
class Person | |
{ | |
public int Number { get; set; } |
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
b,a=$*;a.to_i.times{|l|puts (0..b.to_i).map{|n|x=y=i=0;(x,y,i=x*x-y*y+n/38.0-1.5,2*x*y+l/14.0-1,i+1)until(x*x+y*y>4||i>78);(32+i).chr}*""} |
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
baiduspider-180-76-5-49.crawl.baidu.com plea.se - [05/Nov/2012:15:06:34+0100] GET /robots.txt HTTP/1.1 200 37 - Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 | |
baiduspider-180-76-5-156.crawl.baidu.com plea.se - [05/Nov/2012:15:06:35+0100] GET /robots.txt HTTP/1.1 200 37 - Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 | |
119.63.196.76 plea.se - [05/Nov/2012:15:15:36+0100] GET /robots.txt HTTP/1.1 200 37 - Baiduspider+(+http://www.baidu.com/search/spider.htm) | |
119.63.196.14 plea.se - [05/Nov/2012:15:15:41+0100] GET /robots.txt HTTP/1.1 200 37 - Baiduspider+(+http://www.baidu.com/search/spider.htm) |
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 results = []; | |
for (var i = 0; i < 60000; i++) { | |
var arr = ['A', 'B', 'C']; | |
arr.sort( function() { return 0.5 - Math.random() } ); | |
results.push(arr); | |
}; | |
var dict = {}; | |
for (var i = results.length - 1; i >= 0; i--) { |