Skip to content

Instantly share code, notes, and snippets.

View hazzik's full-sized avatar

Alex Zaytsev hazzik

  • Brisbane, Australia
View GitHub Profile
@hazzik
hazzik / reset.css
Last active December 17, 2015 02:39
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
String.prototype.visualLength = (function() {
var that = this,
ruler = document.getElementById('ruler');
if (!ruler) {
ruler = document.createElement('span');
document.body.appendChild(ruler);
}
ruler.style.visibility = 'hidden';
return function () {
ruler.innerHTML = that;
if (!document.getElementsByClassName) {
document.getElementsByClassName = function(search) {
var d = document, elements, pattern, i, results = [];
if (d.querySelectorAll) { // IE8
return d.querySelectorAll("." + search.replace(/\s+/g, '.'));
}
if (d.evaluate) { // IE6, IE7
pattern = ".//*[contains(concat(' ', @class, ' '), ' " + search + " ')]";
elements = d.evaluate(pattern, d, null, 0, null);
while ((i = elements.iterateNext())) {
def using (v, &block)
begin
block.call
ensure
v.close unless v.nil? if v.class.method_defined? :close
end
end
class Resource
def name ()
public static class EnumerableEx
{
public static bool Any(this IEnumerable e)
{
using (var i = enumerable.GetEnumerator())
{
return i.MoveNext();
}
}
[].concat(
Object.getOwnPropertyNames(Object),
Object.getOwnPropertyNames(window)
).map(function(x){return {name:x,length:JSFuck.encode(x).length};})
.sort(function(x,y) {return x.length-y.length;})
.forEach(function(x) {console.log(x);})
@hazzik
hazzik / Output.txt
Last active December 25, 2015 03:49
SelectMany performance
Compiling the source code....
$mcs main.cs -out:demo.exe 2>&1
main.cs(37,13): warning CS0219: The variable `ids1' is assigned but its value is never used
main.cs(40,13): warning CS0219: The variable `ids1' is assigned but its value is never used
Compilation succeeded - 2 warning(s)
Executing the program....
$mono demo.exe
SelectMany method chain : 00:00:00.7027228
SelectMany linq : 00:00:00.6438793
-pascalCase+
-nativeTypeSystem
-organizeUsings
-separateInterfaceConstants
-junitConversion
-maxColumns 400
-namespaceMapping org.mozilla.javascript Rhino
-fullyQualify Cipher
========
Array.ForEach: 341.4, Min: 338, Max: 346
Array for i != Length; ++i: 355.5, Min: 352, Max: 365
Array for ++i: 356.8, Min: 350, Max: 381
Array for: 397.9, Min: 391, Max: 420
Array for i != Length: 410.6, Min: 398, Max: 468
Array for, cached length: 413.5, Min: 399, Max: 502
Array foreach: 437.9, Min: 433, Max: 447
List<T>.ForEach: 489.7, Min: 480, Max: 540
IList<T> for, cached length: 590.5, Min: 582, Max: 619
@hazzik
hazzik / LSP.cs
Created March 26, 2014 20:32
LSP.cs
public class Rectangle {
public Rectangle(decimal width, decimal height) {
Width = width;
Height = height;
}
public decimal Area() {
return Width * Height;
}
public decimal Width { get; private set; }
public decimal Height { get; private set; }