Skip to content

Instantly share code, notes, and snippets.

@monolithed
monolithed / gist:3229123
Created August 1, 2012 17:40 — forked from abozhilov/gist:1339681
setPrototypeOf
/*
Object.setPrototypeOf is not going to happen. Writable __proto__
is a giant pain to implement (must serialize to cycle-check)
and it creates all sorts of type-confusion hazards (Brendan Eich).
*/
Object.setPrototypeOf = function (object, proto) {
var __proto__ = proto;
do {
@monolithed
monolithed / main.mm
Created October 11, 2012 23:44 — forked from iamleeg/main.mm
Using operator overloading with Objective-C. Erm, ++.
#include "objc_id.hpp"
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString *s1 = @"hello";
NSString *s2 = [@"hell" stringByAppendingString: @"o"];
if ((objc_id(s1) == objc_id(s2))) {
NSLog(@"win");
@monolithed
monolithed / gist:4096202
Created November 17, 2012 14:06 — forked from biot023/gist:2318842
Failing cppcms build
~/src/cppcms-1.0.1/build$ make
[ 0%] Building CXX object booster/CMakeFiles/booster.dir/lib/ptime/src/posix_time.cpp.o
[ 0%] Building CXX object booster/CMakeFiles/booster.dir/lib/ptime/src/ctime.cpp.o
[ 1%] Building CXX object booster/CMakeFiles/booster.dir/lib/regex/src/pcre_regex.cpp.o
[ 1%] Building CXX object booster/CMakeFiles/booster.dir/lib/system/src/posix_error.cpp.o
[ 1%] Building CXX object booster/CMakeFiles/booster.dir/lib/system/src/windows_error.cpp.o
[ 2%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/aio_category.cpp.o
[ 2%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/deadline_timer.cpp.o
[ 2%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/endpoint.cpp.o
[ 3%] Building CXX object booster/CMakeFiles/booster.dir/lib/aio/src/io_service.cpp.o
/**
* Watcher leaks for jQuery
* RubaXa <trash@rubaxa.org>
* MIT Licensed.
*
* API:
* $.leaks.get();
* $.leaks.watch();
* $.leaks.unwatch();
* $.leaks.remove();
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
body#-webkit-web-inspector #main{background-color:#002b36!important}body#-webkit-web-inspector #main .panel.network,body#-webkit-web-inspector #main .panel.timeline,body#-webkit-web-inspector #main .panel.profiles,body#-webkit-web-inspector #main .panel.audits,body#-webkit-web-inspector #main .panel.extension{background-color:#fff!important}body#-webkit-web-inspector #console-messages a:hover,body#-webkit-web-inspector #console-messages .console-formatted-function,body#-webkit-web-inspector #console-messages .console-formatted-object{color:#93a1a1!important}body#-webkit-web-inspector #console-prompt,body#-webkit-web-inspector #console-messages a,body#-webkit-web-inspector #console-messages .console-message,body#-webkit-web-inspector #console-messages .console-group-messages .section .header .title{color:#839496!important}body#-webkit-web-inspector #console-messages .console-formatted-null,body#-webkit-web-inspector #console-messages .console-formatted-undefined{color:#657b83!important}body#-webkit-web-inspect

How Fast if Git?

The web is full of benchmarks showing the supernatural speed of Git even with very big repositories, but unfortunately they use the wrong variable. Size is not important, but the number of files in the repository really is!

Why is that? Well, that's because Git works in a very different way compared to Synergy. You don't have to checkout a file in order to edit it; Git will do that for you automatically. But at what price?

The price is that for every Git operation that requires to know which files changed (git status, git commmit, etc etc) an lstat() call will be executed for every single file

Wow! So how does that perform on a fairly large repository? Let's find out! For this example I will use an example project, which has 19384 files in 1326 folders.

@monolithed
monolithed / entypo.css
Created November 17, 2013 18:30 — forked from pnull/entypo.css
@font-face {
font-family: 'EntypoRegular';
src: url('font/entypo.eot');
src: url('font/entypo.eot?#iefix') format('embedded-opentype'),
url('font/entypo.woff') format('woff'),
url('font/entypo.ttf') format('truetype'),
url('font/entypo.svg#EntypoRegular') format('svg');
font-weight: normal;
font-style: normal;
}
/**
* User Timing polyfill (http://www.w3.org/TR/user-timing/)
* @author RubaXa <trash@rubaxa.org>
*/
(function (window){
var
startOffset = Date.now ? Date.now() : +(new Date)
, performance = window.performance || {}
, _entries = []
var _hasOwn = Object.prototype.hasOwnProperty;
var _toString = Object.prototype.toString;
var _hasGOPD = typeof Object.getOwnPropertyDescriptor === 'function';
var _hasDP = typeof Object.defineProperty === 'function';
function _getOwnPropertyDescriptor(obj, prop) {
if ( _hasGOPD ) {
return Object.getOwnPropertyDescriptor(obj, prop)
}
else {