Skip to content

Instantly share code, notes, and snippets.

View halogenandtoast's full-sized avatar

Matthew Mongeau halogenandtoast

View GitHub Profile
@halogenandtoast
halogenandtoast / App.vue
Created December 30, 2023 01:20
Vue SFC showcasing animating between lists
<script setup lang="ts">
import gsap from 'gsap'
import { ref } from 'vue'
const CardStates = ["Above", "Below"] as const
type CardState = typeof CardStates[number]
interface Card {
id: number
@halogenandtoast
halogenandtoast / Main.hs
Last active August 15, 2023 05:04
Simple Yesod Websocket Example
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
import Conduit
import Control.Monad (forever)
import Data.Text (Text)
import UnliftIO.STM
@halogenandtoast
halogenandtoast / Main.hs
Created August 3, 2023 10:18
Scotty/WebSockets example
module Main (main) where
import Control.Concurrent.Async
import Control.Concurrent.Chan
import Control.Monad (forever)
import Data.Text (Text)
import Network.Wai
import Network.Wai.Handler.Warp
import Network.Wai.Handler.WebSockets
import Network.WebSockets
@halogenandtoast
halogenandtoast / paste_helper.rb
Created June 8, 2018 13:44
Paste helper for capybara and chromedriver (may work with other drivers)
def paste_in(field_label, with:)
field = find_field(field_label)
selector = "##{field["id"]}"
script = <<-JS
dt = new DataTransfer();
dt.setData("text/plain", '#{with}');
ev = new ClipboardEvent("paste", { clipboardData: dt });
$('#{selector}')[0].dispatchEvent(ev)
JS
page.execute_script(script)
Monban.configure do |config|
config.no_login_handler = ->(controller) do
notice = Monban.config.sign_in_notice
controller.flash.notice = notice.call
controller.redirect_to controller.login_path
end
end
class PostsController < ApplicationController
before_action :require_login
def show
render plain: "HERE"
end
end
require 'benchmark'
class TrieBuilder
def from_words(words)
TrieNode.new("").tap do |trie|
words.each { |word| trie.push_word(word) }
end
end
end
(ns cljs.pong.main
(:require [goog.dom :as dom]
[goog.events :as events]))
(def animate
(or (.-requestAnimationFrame js/window)
(.-webkitRequestAnimationFrame js/window)
(.-mozRequestAnimationFrame js/window)
#(.setTimeout js/window %1 (/ 1000 60))))
require "json"
require "socket"
require "ipaddr"
require "securerandom"
require "curses"
class Message
attr_reader :client_id, :handle, :content
def self.inflate(json)
@halogenandtoast
halogenandtoast / index.html
Created October 28, 2014 17:21
Includes both examples from the talk. index.html and main.js are the pure WebGL example and three.html is the ThreeJS example.
<!DOCTYPE html>
<html>
<head>
<title>WebGL Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.2.1/gl-matrix-min.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
void main(void) {