Skip to content

Instantly share code, notes, and snippets.

View chrismwendt's full-sized avatar

Chris Wendt chrismwendt

View GitHub Profile
@chrismwendt
chrismwendt / JoystickMouse
Created March 15, 2015 04:46
Maps joystick and buttons to mouse movement, buttons, and scroll
; Using a Joystick as a Mouse
; http://www.autohotkey.com
; This script converts a joystick into a three-button mouse. It allows each
; button to drag just like a mouse button and it uses virtually no CPU time.
; Also, it will move the cursor faster depending on how far you push the joystick
; from center. You can personalize various settings at the top of the script.
; Increase the following value to make the mouse cursor move faster:
JoyMultiplier = 30
JoyWheelMultiplier = 50
@chrismwendt
chrismwendt / gist:af939e82cdb54814de82
Last active August 29, 2015 14:22
simulator for a particular machine with a single operation
// http://jsfiddle.net/hfn5w1je/1/
// TODO step through instructions on key press
// TODO step through program on timer
// TODO highlight the next instruction and components (a, b, c, true, false)
// TODO highlight jumps
// TODO dynamically resize memory
// TODO compress memory representation via run-length encoding
// TODO add I/O capabilities (e.g. keyboard and terminal view)
@chrismwendt
chrismwendt / point.idr
Created October 24, 2015 12:00
Demonstrating a Point (x, y) of natural numbers where both x and y must be >= 2
--proof that 8 >= 2
eight_GTE_two : 8 `GTE` 2
eight_GTE_two = proof search
--proof that 8 >= 3
eight_GTE_three : 8 `GTE` 3
eight_GTE_three = proof search
--this doesn't work since it fails with the error "Can't solve goal LTE 2 1" (GTE is defined in terms of LTE in Idris)
--one_GTE_two : 1 `GTE` 2
@chrismwendt
chrismwendt / one_hundred.hs
Last active January 22, 2016 21:30
Programming puzzle (expressions that evaluate to 100)
{-# LANGUAGE LambdaCase #-}
import Data.List
import Text.Parsec.Prim hiding ((<|>), many)
import Text.Parsec.Expr
import Text.Parsec.Pos
import Text.Parsec.Combinator
import Text.Parsec.Error
import Data.Functor
import Data.Functor.Identity
@chrismwendt
chrismwendt / render.py
Created March 7, 2016 20:49
Render font characters as PNGs
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from PIL import ImageEnhance
# pip install Pillow
def render(text, filename):
width=128
height=128
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
@chrismwendt
chrismwendt / Main.hs
Last active September 9, 2016 04:29
Example of ghc-mod's auto command being slow
{-# LANGUAGE OverloadedStrings #-}
module AFoo where
import qualified Database.Bloodhound as B
import Network.HTTP.Client (defaultManagerSettings)
import Control.Monad
import Control.Lens ((^.), (^?), (^..))
import Data.Aeson
import Data.Aeson.Lens
@chrismwendt
chrismwendt / pMapM.hs
Created October 13, 2016 09:00
pMapM for streaming in Haskell
import Streaming
import qualified Streaming.Prelude as S
import Streaming.Prelude (next, yield, each)
import Control.Concurrent hiding (yield)
import Control.Concurrent.Async
import qualified Control.Concurrent.SSem as Sem
main :: IO ()
main = return ()
@chrismwendt
chrismwendt / README.md
Last active October 21, 2016 06:19
Mysterious rise in CPU usage and execution time when run on multiple cores
+RTS -N1 -RTS
2.31s, 36% CPU, 108128 bytes of memory

+RTS -N8 -RTS
8.42s, 423% CPU, 131308 bytes of memory

Why does increasing the core count from 1 to 8 cause such drastic rise in CPU usage?

@chrismwendt
chrismwendt / 3waydiff.hs
Created February 4, 2018 09:24
Shows changes from both sides in a file with 3-way merge conflicts
#!/usr/bin/env stack
{-
stack
--resolver lts-10.4
--install-ghc
script
--package temporary
--package megaparsec
--package rainbow
--package typed-process