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
@monolithed
monolithed / index.js
Created December 7, 2015 12:24 — forked from lygaret/index.js
ES6 Quasi-Literal for JSX
define(function(require) {
var React = require('react');
var paramRegex = /__(\d)+/;
var parser = new DOMParser();
var errorDoc = parser.parseFromString('INVALID', 'text/xml');
var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI;
// turns the array of string parts into a DOM
// throws if the result is an invalid XML document.
/**
* 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
@monolithed
monolithed / nginx.conf
Created December 24, 2015 10:18 — forked from micho/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf:
@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 = []