Skip to content

Instantly share code, notes, and snippets.

kkspeed

Block or report user

Report or block kkspeed

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kkspeed
kkspeed / main.rs
Last active Apr 4, 2019
Protobuf 3 decode raw
View main.rs
use std::str::from_utf8;
fn main() {
println!(
"{}",
read_proto_raw(&[0x12, 0x07, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67]).unwrap()
);
println!(
"{}",
read_proto_raw(&[0x1a, 0x03, 0x08, 0x96, 0x01]).unwrap()
@kkspeed
kkspeed / simple_plot.cljs
Created Mar 25, 2019
Use D3 with Reagent
View simple_plot.cljs
;; Assumes D3 is provided as foreign lib. Add following to :compiler section of build.
;; :foreign-libs [{:file "lib/d3.v5.js"
;; :provides ["d3"]
;; :requires ["d3"]}]
;; Then (require [d3]) in the code namespace.
(def performance-data [{:group 0
:name "Update()"
:start 200
:end 240}
{:group 0
@kkspeed
kkspeed / type_list_fun.cc
Created Jan 27, 2019
Func with C++ type list
View type_list_fun.cc
// Demonstrates C++ type list.
// Author: Bruce Li (github.com/kkspeed)
// Licensed under BSD.
// Requires C++ 11 except Filter. Filter requires C++14.
#include <string>
#include <type_traits>
// A typelist is a list of types. The list is similar to
// lists in functional languages like Lisp.
@kkspeed
kkspeed / naive.rs
Created Jan 18, 2019
A naive Rust Functional Reactive Programming Framework
View naive.rs
use std::cell::RefCell;
use std::rc::Rc;
struct Core<T> {
observers: Vec<Box<Fn()>>,
value: Option<T>,
}
impl<T> Core<T>
where
@kkspeed
kkspeed / toy_frp.cpp
Last active Feb 11, 2019
A toy C++ FRP framework
View toy_frp.cpp
// A toy C++ FRP framework.
// Author: Bruce Li (github.com/kkspeed)
// Licensed under BSD.
//
// Note:
// 1. Compiles with C++ 17
// 2. Signal values are copy-constructable. Non-copyconstructable values
// could be wrapped in shared_ptr.
// 3. Signal graph is statically connected and unsubscription is not
// an option.
@kkspeed
kkspeed / my_bind.hpp
Last active Jan 12, 2019
C++ Possible Alternate Bind Implementation
View my_bind.hpp
// Alternative implementation of bind without using placeholders.
// usage:
// Given void func(int a, int b, int c);
// auto f = my_bind(func, 3, 2);
// Then f(5) is the same as func(3, 2, 5);
// Also if first parameter is a weak pointer, this bind does the
// weak check automatically.
// For weak check to work successfully, the function needs to have void
// return type.
@kkspeed
kkspeed / render.py
Created Jan 17, 2016
Adding TOC automatic display for Google IO-2012 slide template
View render.py
#!/usr/bin/env python
# Original template: Google io 2012:
# https://code.google.com/p/io-2012-slides/
# Now you can add section to your slide's metadata, which makes it
# easier to adapt to academic presentation
# e.g:
# ---
# section: foo bar
# title: .....
#
@kkspeed
kkspeed / blackjack.hs
Created Jan 11, 2016
Blackjack simple simulation
View blackjack.hs
{-# Language GeneralizedNewtypeDeriving #-}
import Data.Maybe (fromJust)
import System.Random (randomIO)
import Control.Applicative
import Control.Monad.State.Strict
newtype GameAction s a = GameAction { getAction :: StateT s Maybe a }
deriving (Monad, Applicative, Functor, MonadState s, Alternative)
condition :: (s -> Bool) -> GameAction s ()
@kkspeed
kkspeed / menumanager.lua
Created Nov 24, 2015
More Weapon Stats menumanager.lua
View menumanager.lua
-- More Weapon Stats menumanager.lua
-- by TdlQ and KarateF22
-- at http://paydaymods.com/mods/138/MWS
_G.MoreWeaponStats = _G.MoreWeaponStats or {}
MoreWeaponStats._path = ModPath
MoreWeaponStats._data_path = SavePath .. "more_weapon_stats.txt"
MoreWeaponStats.settings = {
show_dlc_info = true,
separate_extended_stats = false,
show_spread_and_recoil = true,
@kkspeed
kkspeed / menumanager.moon
Created Nov 24, 2015
Moonscript implemenation of More Weapon Stats's menumanager
View menumanager.moon
-- More Weapon Stats Moonscript Trial
-- orignally modified from menumanager.lua from TdlQ and KarateF22's MoreWeaponStats
-- at http://paydaymods.com/mods/138/MWS
-- translated into moonscript by kkspeed
class MoreWeaponStats extends _G.MoreWeaponStats
@_path = ModPath
@_data_path = "#{SavePath}more_weapon_stats.txt"
@settings = {
show_dlc_info: true,
separate_extended_stats: false,
You can’t perform that action at this time.