Skip to content

Instantly share code, notes, and snippets.

View phadej's full-sized avatar
🦉
Someone here is possessed by an owl. Who?

Oleg Grenrus phadej

🦉
Someone here is possessed by an owl. Who?
View GitHub Profile
% cat foo.less
#body {
-ms-flex: 1 0 0px;
}
% lessc foo.less
#body {
-ms-flex: 1 0 0px;
}
% recess --compile foo.less
#body {
var C = function(opts) {
opts = opts || {};
function foo() {
return opts.foo;
}
return {
foo: foo,
};
module Main where
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Criterion.Main (defaultMain, bgroup, bench, whnf)
import Debug.Trace
@phadej
phadej / utilities.js
Last active December 17, 2015 09:08
function fin(promise, body) {
return promise.then(function (res) {
return as(body()).then(function() {
return res;
});
}, function(function (err) {
// if body throws something other, that will override current error
return as(body()).then(function() {
throw err;
});
@phadej
phadej / README.md
Last active December 17, 2015 22:39

Forcing compiler to evaluate constexpr expressions

With a code like in constexpr.cc the outputted llvm assember for the main function looks like

Compiled with clang++ -S -emit-llvm -std=c++11 constexpr.cc

define i32 @main() uwtable ssp {
  %1 = call %"class.std::basic_ostream"* @_ZNSolsEi(%"class.std::basic_ostream"* @_ZSt4cout, i32 7)
  %2 = call %"class.std::basic_ostream"* @_ZNSolsEPFRSoS_E(%"class.std::basic_ostream"* %1, %"class.std::basic_ostream"* (%"class.std::basic_ostream"*)* @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="tests/lib/winjs/base.js"></script>
</head>
<body>
</body>
</html>
@phadej
phadej / recurse.js
Created July 29, 2013 10:11
Simple fixed-point combinator
"use strict";
function fix(f) {
console.log("fix", f);
return function () {
console.log("first call", arguments);
return f.apply(undefined, [f].concat(Array.prototype.slice.apply(arguments)));
};
}
var typify = require("typify");
function checklog(type, v, expected) {
var result = typify.check(type,v);
if (result !== expected) {
console.error(type, v, result, expected);
}
}
var aNumber = 123;
/*
copy to jsverify.js
$ npm install underscore
$ node jsverify.js
Example output atm:
Property doesn't hold, counterexample with [ 0 ]
inc failing: false
inc fixed: true
/* jshint indent:4, scopeshadow:true */
(function () {
"use strict";
(function () {
function foo() {
function bar() {}
return {
bar: bar