Skip to content

Instantly share code, notes, and snippets.

View Alxandr's full-sized avatar
⁉️
⁉️

Aleksander Heintz Alxandr

⁉️
⁉️
View GitHub Profile
@Alxandr
Alxandr / immutalize.js
Created August 27, 2015 05:12
Immutalize
export function immutalize(props) {
let fields = props.map(name => ({name, symb: Symbol(name)}));
const toObj = (inst) => {
const obj = {};
fields.forEach(({name, symb}) => obj[name] = inst[symb]);
return obj;
};
return base => {
@Alxandr
Alxandr / gist:4ab0475c0e1ec86dbad8
Created May 13, 2014 21:58
Utility-method to enable per-default calling to base-methods in FakeItEasy
public static IFakeOptionsBuilder<TFaked> CallBase<TFaked>(this IFakeOptionsBuilder<TFaked> config)
{
return config.Strict()
.OnFakeCreated(fake =>
A.CallTo(fake).Where(c => !c.Method.IsFinal && !c.Method.IsAbstract)
.CallsBaseMethod());
}
#!/bin/sh
if test `uname` = Darwin; then
# Running on mac
brew update
brew install mono
else
# Running (presumably) on linux
# sudo add-apt-repository -y ppa:directhex/monoxide
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Runt.Bootstrap
{
@Alxandr
Alxandr / crazies.cs
Created June 5, 2014 08:10
Running a WinForms application from K
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test
{
using System;
using System.IO;
using System.Reflection;
namespace Kake
{
class Bootstrap
{
delegate int EntryPoint(string[] args);
@Alxandr
Alxandr / gist:90e8626b810df85eb553
Created December 10, 2014 01:16
Async js loop
async function foo() {
try {
let result = [];
for (let value of await getValues()) {
let newVal = await asyncOperation(value);
console.log(newVal);
result.push(newVal);
}
return result;
} catch (e) {
@Alxandr
Alxandr / gist:df582a764aa736580e50
Created December 13, 2014 20:32
404 Error page in vNext
app.Use(next => async context =>
{
await next(context);
if(context.Response.ContentLength == null)
{
context.Response.StatusCode = 404;
var path = Path.Combine(_hostingEnvironment.WebRoot, "_error", "404.html");
var content = File.ReadAllText(path);
await context.Response.SendAsync(content, "text/html");
}
@Alxandr
Alxandr / asm.ps1
Created December 30, 2014 07:56
List all assembly architecture (.NET)
Get-ChildItem -Filter "*.dll" | ForEach-Object {
$a = [reflection.assemblyname]::GetAssemblyName($_.FullName).ProcessorArchitecture
Write-Host $a $_.Name
}
@Alxandr
Alxandr / (generated) test.js
Last active August 29, 2015 14:14
Source of generated code
var a$0 = 5;
var add$0 = _fun$0('add', 2, function add(_arg0$0, _arg1$0) {
var a$1 = _arg0$0, b$0 = _arg1$0;
return _op$0('+', a$1, b$0);
});
var add1$0 = _call$0(add$0, [1]);
var b$1 = _call$0(add1$0, [a$0]);
var _ref$0 = function () {
var testInner$0 = 15;
return _tupleCreate$0([