This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original inspiration (verbatim code): | |
void combatManager::ArcShot(icon *icn, int fromX, int fromY, int targX, int targY) | |
{ | |
bool firingLeft = false; | |
if (fromX > targX) | |
firingLeft = true; | |
int imageIdx = 0; // changes the sprite when its angle changes | |
// temporarily save the screen so we can clear it from the projectile sprite later |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signed int __thiscall iconWidget::Main(iconWidget *this, tag_message *evt) | |
{ | |
iconWidget *thisa; // esi@1 | |
__int16 v3; // cx@1 | |
signed int result; // eax@4 | |
INPUT_EVENT_CODE evtCode; // edx@6 | |
heroWindow *parent; // ebp@14 | |
__int16 xRelParent; // ax@14 | |
__int16 yRelParent; // bx@14 | |
resource *v9; // ST00_4@36 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void army::Walk(signed int dir, int last, int notFirst) { | |
int targCell = this->GetAdjacentCellIndex(this->occupiedHex, dir); | |
gCloseMove = IsCloseMove(targCell); | |
// Bridge opening | |
if (this->owningSide == 1 | |
&& gpCombatManager->isCastleBattle | |
&& (targCell == 58 || targCell == 59 || targCell == 60 && this->owningSide == 1 && this->creature.creature_flags & TWO_HEXER) | |
&& gpCombatManager->drawBridgePosition == BRIDGE_CLOSED) { | |
this->animationType = ANIMATION_TYPE_STANDING; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs #-} | |
module HowAreEqualityConstraintsCompiled where | |
data TypeEq a b where | |
Refl :: (a ~ b) => TypeEq a b | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From "Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015" | |
# Bad code | |
import jnettools.toolselements.NetworkElement, \ | |
jnettools.tools.Routing, \ | |
jnettools.tools.RouteInspector | |
ne=jnettools.tools.elements.NetworkElement( '171.0.2.45' ) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |