Skip to content

Instantly share code, notes, and snippets.

@t81lal
t81lal / BasePrinter.java
Created September 9, 2020 17:53
Text editor output utility
public abstract class BasePrinter<Self extends BasePrinter<Self>> {
private static final String WORD_SEP = " ";
private static final String INDENT_STR = " ";
private final String wordSep, indentStr;
private boolean built;
private StringBuilder builder;
private String builtString;
@t81lal
t81lal / SpadePipeline.java
Created July 8, 2020 23:27
First prototype of Spade mainline pipeline
static class TestModule extends AbstractModule {
private final GenerationCtx ctx;
public TestModule(GenerationCtx ctx) {
this.ctx = ctx;
}
@Override
protected void configure() {
bind(GenerationCtx.class).toInstance(ctx);
@t81lal
t81lal / TestPipeline2WithGuice.java
Created July 8, 2020 15:31
TestPipeline2WithGuice.java
package com.krakenrs.spade.pipeline;
import java.util.function.Function;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
public class TestPipeline2 {
@t81lal
t81lal / TestPipeline2.java
Last active July 8, 2020 14:43
TestPipeline2.java
package com.krakenrs.spade.pipeline2;
import java.util.function.Function;
public class TestPipeline2 {
static interface PipelineStep<I, O> extends Function<I, O> {
}
static interface PipelineProducer<S, I> {
@t81lal
t81lal / TestPipeline.java
Created July 8, 2020 13:03
TestPipeline.java
package com.krakenrs.spade.pipeline;
public class TestPipeline {
public interface PipelineBuilder<I> {
<O> PipelineBuilder<O> then(PipelineStep<I, O> step);
void run();
}
@t81lal
t81lal / io-ts brands.ts
Created August 8, 2019 01:28
Two different ways to provide runtime type support for the username field
import * as t from 'io-ts';
import { withMessage } from 'io-ts-types/lib/withMessage';
import { Either, either } from 'fp-ts/lib/Either';
interface UsernameBrand {
readonly Username: unique symbol;
}
type ErrorOrString = Either<t.Errors, string>
Option Explicit
Public Const BankDateCol = "A"
Public Const BankNameCol = "C"
Public Const BankAmountCol = "D"
Public Const BankPropertyCol = "F"
Sub CopyValue(BankRow As Long, PropRow As Long, BankCol As String, PropertyCol As Long, PropertySheet As Worksheet)
PropertySheet.Cells(PropRow, PropertyCol).Value = Sheet1.Range(BankCol & BankRow).Value
@t81lal
t81lal / luhn.c
Created December 24, 2018 22:51
luhn.c
#include <stdio.h>
#include <ctype.h>
int checksum(char *str) {
int cs = 0;
int length = 0;
char *c;
/* get sequence length and validate chars in it */
for(c=str; *c; c++, length++) {
class ComputeLinearScanOrder : public StackObj {
private:
int _max_block_id; // the highest block_id of a block
int _num_blocks; // total number of blocks (smaller than _max_block_id)
int _num_loops; // total number of loops
bool _iterative_dominators;// method requires iterative computation of dominatiors
BlockList* _linear_scan_order; // the resulting list of blocks in correct order
ResourceBitMap _visited_blocks; // used for recursive processing of blocks
@t81lal
t81lal / IteratorIterator.java
Created February 19, 2017 00:09
IteratorIterator.java
package org.mapleir.stdlib.collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public abstract class IteratorIterator<T> implements Iterator<T> {
protected Iterator<T> current;