Skip to content

Instantly share code, notes, and snippets.

// Version 1: Prints "1"
function foo() {
x = 1;
}
foo();
console.log(x);
//------------------------------------
@jkoppel
jkoppel / java_samples.java
Created October 16, 2016 01:42
Test cases from hell
/* Original samples:
Sample 7:
Query rangeQuery(String field, Object lowerTerm, Object upperTerm,
boolean includeLower, boolean includeUpper) {
double l = Double.NEGATIVE_INFINITY;
double u = Double.POSITIVE_INFINITY;
if (lowerTerm != null) {
l = parse(lowerTerm);
pragma options "--bnd-inline-amnt 5 --bnd-inbits 2 --bnd-cbits 3 ";
int BASE = 4;
int[2*N] mult(int N, int[N] x, int[N] y){
int[2*N] out = 0;
for(int i=0; i<N; ++i){
for(int j=0; j<N; ++j){
from test import multibytecodec_support
import unittest
# Inlining t5 makes the test pass
t5 = multibytecodec_support.TestBase_Mapping
class TestGB18030Map(t5, unittest.TestCase):
encoding = 'gb18030'
mapfileurl = 'http://www.pythontest.net/unicode/gb-18030-2000.xml'
t7 = __name__ == "__main__"
data Exp = Lit String
pprint :: Exp -> String
pprint = (\(Lit s) -> a ++ "'" ++ s ++ "'") where a free
pprint = (\(Lit s) -> a ++ "\"" ++ s ++ "\"") where a free
parse :: String -> (Exp, Exp -> String)
parse s | s =:= f x = (x, f)
where
f = pprint
adt Prog {
Var1 {}
Var2 {}
Const {int val; }
Add { Prog left; Prog right; }
Mul { Prog left; Prog right; }
}
int interpret(Prog prog, int x, int y) {
switch(prog) {
{-# LANGUAGE GADTs, TypeOperators, DeriveFunctor, DataKinds, KindSignatures, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, OverlappingInstances, TypeFamilies, UndecidableInstances, FunctionalDependencies, ScopedTypeVariables #-}
module ConstMemDlc where
import qualified Data.Map as Map
import Data.Proxy
import GHC.TypeLits
import Data.Type.Equality
{-# LANGUAGE GADTs #-}
module HowAreEqualityConstraintsCompiled where
data TypeEq a b where
Refl :: (a ~ b) => TypeEq a b
@jkoppel
jkoppel / debug.cpp
Created October 9, 2017 20:24
Example of making debug output in Ironfist
extern int __fastcall InitMenuHandler_orig(struct tag_message & msg);
extern font* smallFont;
extern font* bigFont;
extern heroWindow* gpInitWin;
extern void __fastcall FillBitmapArea(class bitmap *, int, int, int, int, int);
int __fastcall InitMenuHandler(struct tag_message & msg) {
if (msg.eventCode == INPUT_MOUSEMOVE_EVENT_CODE) {
@jkoppel
jkoppel / InitMenuHandler
Created October 10, 2017 07:31
Challenge: Find the use of rectangles
signed int __thiscall InitMenuHandler(tag_message *msg)
{
signed int result; // eax@26
int v2; // ST48_4@29
int v3; // [sp+Ch] [bp-24h]@27
signed int v5; // [sp+1Ch] [bp-14h]@40
signed int v6; // [sp+20h] [bp-10h]@4
signed int v7; // [sp+24h] [bp-Ch]@1
int highID; // [sp+2Ch] [bp-4h]@32
signed int highIDa; // [sp+2Ch] [bp-4h]@40