Skip to content

Instantly share code, notes, and snippets.

View Luiz-Monad's full-sized avatar
💭
computing

Luiz Luiz-Monad

💭
computing
View GitHub Profile
@Luiz-Monad
Luiz-Monad / Y.cs
Created November 20, 2017 19:47
Y y
void Main()
{
foreach(var t in typeof(test).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(test))))
((test)(Activator.CreateInstance(t))).TestMethod();
}
private abstract class test
{
public abstract void TestMethod();
}
@Luiz-Monad
Luiz-Monad / fixpoint.cs
Created November 20, 2017 23:34
csharp recursive fixpoint
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace t1
{
static class Program
{
@Luiz-Monad
Luiz-Monad / ifixpoint.cs
Created November 20, 2017 23:42
csharp iterative fixpoint
using System;
using System.Collections.Generic;
namespace t1
{
static class Program
{
static void Main(string[] args)
{
@Luiz-Monad
Luiz-Monad / dump.cs
Created November 30, 2017 18:09
dump dll
System.Reflection.Assembly.LoadWithPartialName("o.dll")
.GetTypes()
.SelectMany(x => x.GetConstructors())
.Select(x => { try { return x.Invoke(null); } catch { return null; } })
.Where(x => x != null)
.ToList()
.ForEach(x => { try { x.Dump(); } catch {} });
@Luiz-Monad
Luiz-Monad / fp.c
Last active January 24, 2018 13:40
FP in C
#include <stdio.h>
void map(void (*fn)(void *, void *), size_t len,
void * in_vals, size_t in_len,
void * out_vals, size_t out_len) {
for (int i = 0; i < len; i++)
fn(in_vals + i * in_len, out_vals + i * out_len);
}
void reduce(void (*fn)(void *, void *), void * acc,
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "jni.h"
int __system_property_get(const char* name, char* value) { strcpy(value, "8.0.0"); return 0; }
@Luiz-Monad
Luiz-Monad / verify.fs
Created June 13, 2018 18:33
parse basic
open FParsec
open FParsec.Primitives
type Block = Lines of string list
type Method = Name of string * Block
type Class = Methods of Method list
type Namespace = Classes of Class list
type VbFile = Namespaces of Namespace list
type p<'t> = Parser<'t, unit>
@Luiz-Monad
Luiz-Monad / fib.cs
Created July 31, 2018 14:43
csharp fixpoint fib
using System;
public class Program
{
delegate T id<T>(T arg0);
static id<T> Y<T>(id<id<T>> f)
{
//Y f = f ( Y f )
@Luiz-Monad
Luiz-Monad / pentagon.js
Last active August 31, 2018 21:16
rendering a pentagon
const edge = (a, b, c) =>
((c[0] - a[0]) * (b[1] - a[1]) - (c[1] - a[1]) * (b[0] - a[0]) >= 0)
const test = v => p =>
edge(v[0], v[1], p) & edge(v[1], v[2], p) & edge(v[2], v[0], p);
const point = (r, tst) => (p, i) =>
tst([i / 2, r]) ? '*' : p
loop@ for (info in infos) info.apply {
val startingCount = info.mCurrentBytes
//variables with mStatus are either from info or DownloaderService
if (mStatus != STATUS_SUCCESS)
DownloadThread(info, this@DownloaderService, mNotification!!).run
{
cancelAlarms()
scheduleAlarm(Constants.ACTIVE_THREAD_WATCHDOG)
run()