Skip to content

Instantly share code, notes, and snippets.

View mattysmith22's full-sized avatar

Matthew Smith mattysmith22

  • Hull, United Kingdom
View GitHub Profile
@mattysmith22
mattysmith22 / Lens.BaseTypes.idr
Last active August 15, 2023 21:04
Profunctor optics
module Lens.BaseTypes
public export
data SumType = Opt1 String Double | Opt2
public export
record RecordType where
constructor MkRecordType
recValue1 : String
recValue2 : Double
{-# LANGUAGE DataKinds, TypeFamilies, MultiParamTypeClasses, FlexibleContexts #-}
module ExampleLookup where
import Lookup
import Data.Proxy
data ExampleConstant
instance IsLookup ExampleConstant where
type instance LookupType ExampleConstant = Int

I have been thinking of ways to improve the apache mod discord, and so far the plan I have developed is as follows:

Channel organisations

We split the channels out into the following groups:

Lobby

  • Home
  • Announcements
  • Rules (new read-only channel where the below rules are also shown)

The error value in addition of values in configs (my guess due to it being implemented with a float as the data type for computation) increases to a large enough value that the DIK codes cannot be accurately calculated.

Here is an MRE with 3 examples that should resolve to the same key combo, but instead resolve to 3 different ones.

Packed with binarize

image

import pyvis
bonesRaw = ["velka vrtule","","blade1", "velka vrtule", "blade1_rise1","blade1", "velka vrtule", "blade1","blade1_rise2","blade1","blade1_rise3","blade1","blade1_rise4","blade1","blade1_rise5","blade1","blade2","velka vrtule","blade2_rise1","blade2","blade2_rise2","blade2","blade2_rise3","blade2","blade2_rise4","blade2","blade2_rise5","blade2","blade3","velka vrtule","blade3_rise1","blade3","blade3_rise2","blade3","blade3_rise3","blade3","blade3_rise4","blade3","blade3_rise5","blade3","blade4","velka vrtule","blade4_rise1","blade4","blade4_rise2","blade4","blade4_rise3","blade4","blade4_rise4","blade4","blade4_rise5","blade4","swashplate_up","","swup_arm1","swashplate_up","swup_arm2","velka vrtule","swup_arm3","swashplate_up","swup_arm4","velka vrtule","swashplate_dn","","mr_act","","skin_fcr","","longbow","skin_fcr","mala vrtule","","tr_blade1","mala vrtule","tr_blade2","mala vrtule","tr_blade3","mala vrtule","tr_blade4","mala vrtule","tr_swashplate","mala vrtule","otocvez","","otochlaven","oto
@mattysmith22
mattysmith22 / 5mintimer.sqf
Last active January 15, 2021 17:12
5 Minute timer MMFW Script
_trigger = createTrigger ["EmptyDetector",[0,0,0], true];
_trigger setTriggerStatements ["!(missionNamespace getVariable ['mmfw_endconditions_timelimit_enabled',false])|| {((missionNamespace getVariable ['mmfw_endconditions_timelimit',-1]) - 5) * 60 < CBA_missionTime }", "if (missionNamespace getVariable ['mmfw_endconditions_timelimit_enabled',false]) then { hint '5 minutes remaining'; }", ""];
_trigger setTriggerInterval 10;
@mattysmith22
mattysmith22 / Dfa.hs
Created July 18, 2020 16:24
Deterministic Finite Automaton implementation in Haskell
module Dfa (DFA, State, transition, runString, match, findEquivalent, nequivalent, automaton1, automaton2, minimise) where
import Data.List
import Text.Layout.Table
type State = Int
data DFA = DFA
{ states :: [State]
, initial :: State
, final :: [State]
import System.Environment
import System.Exit
import System.FilePath.Posix
import System.Directory
import Data.Char
isComment :: String -> Bool
isComment xs = "--" == (take 2 $ dropWhile isSpace xs)
stripComment :: String -> String
@mattysmith22
mattysmith22 / monte-carlo.py
Last active July 18, 2020 16:26
Monte-carlo risk analysis implementation
import random
class Project:
risks = []
def add(self, risk):
self.risks.append(risk)
def run_simulation(self, num_runs=1000):
result = ProjectResult()

Singleton pattern

The singleton pattern is useful when you only want one instance of an object. Examples of this include shared resources (database connections, hardware access etc.), configurations and logging. I used the latter for our example here.

In essence you should only try to get an instance of an object through the getInstance method. This method should only construct a new instance if none have been used, otherwise it should reuse the already created one.

Here is an implementation of the singleton pattern:

package singleton;