Skip to content

Instantly share code, notes, and snippets.

View kbridge's full-sized avatar

kq kbridge

  • Sunnydale
View GitHub Profile
@kbridge
kbridge / rluaguide.md
Created November 12, 2021 15:09
A list of tutorials and references so you can learn Roblox Lua

Roblox Scripting Guide

Written by Greenman#0001

The Roblox Wiki is one of the best ways to learn how to script but unfortunately, all of the tutorials on there have been scrambled due to the redesign so this guide is just sorting out the tutorials again so you can read them in the correct order. This guide should cover everything you need to become competent or at least confident with Roblox Lua.

Disclaimer

This will not guarantee that you will learn Lua quickly or even at all. It's your responsibility to use the resources here effectively by taking your time, taking notes, practicing, etc. This list will be updated as I find articles on important concepts that I overlooked so make sure you check back frequently.

import Data.IORef
newCounter :: IO (IO Int)
newCounter = do
n <- newIORef 0
return $ do
modifyIORef' n (+1)
readIORef n
-- GHCi:
@kbridge
kbridge / ForeverDemo.hs
Created September 25, 2021 17:11
Forever/MaybeT Demo
maybeBind :: IO (Maybe a) -> (a -> IO (Maybe b)) -> IO (Maybe b)
maybeBind x f =
x >>= \a ->
case a of
Just y -> f y
Nothing -> return Nothing
getLineMaybe :: IO (Maybe String)
getLineMaybe = getLine >>= \line -> return $ if null line then Nothing else Just line
@kbridge
kbridge / lens.clj
Created August 14, 2021 14:32
lens implementation
(def p1
{:name "Danny",
:address {:country "Finland",
:city "Helsinki"}})
(defn lens [key]
(let [getter key
setter (fn [s a] (assoc s key a))]
(fn [fmap]
(fn [f]
@kbridge
kbridge / periodic_worker-inl.h
Created August 30, 2019 09:40
spdlog periodic_worker workaround for MSVC
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include "spdlog/details/periodic_worker.h"
#endif
namespace spdlog {
@kbridge
kbridge / try_uv1.cpp
Last active February 11, 2019 12:25
uv different behavior under windows/linux
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
#include <chrono>
#include <thread>
using std::chrono::seconds;
using std::this_thread::sleep_for;
uv_fs_t open_req;