Skip to content

Instantly share code, notes, and snippets.

View kim366's full-sized avatar

Kim Schmider kim366

  • Sydney
View GitHub Profile
sf::Vector2f put_point_on_line(sf::Vector2f point, sf::Vector2f line_point0, sf::Vector2f line_point1)
{
const double new_point_x
{
(
point.x * std::pow(line_point0.x - line_point1.x, 2)
+
(
point.y * (line_point0.x - line_point1.x)
- line_point0.x * line_point1.y
sf::Vector2f put_point_on_line(sf::Vector2f point, sf::Vector2f line_point0, sf::Vector2f line_point1)
{
const sf::Vector2f line_seg{line_point1 - line_point0};
return line_point1 + unitV(line_seg) * dot(unitV(line_seg), point - line_point1);
}
acpi | perl -ne '$_=~m/(\\d+)(?=%)/;print "$1"'
using StaticArrays
mutable struct CAcceleration
a::SVector{2, Float32}
end
mutable struct CPosition
p::SVector{2, Float32}
end
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
@kim366
kim366 / julia-speed-increase.cpp
Created October 31, 2018 17:03
Julia Benchmark comparing the performance of `jl_eval_string` over `jl_get_global` and evaluating every frame. 648x (!) speed increase
#include "/usr/include/julia/julia.h"
#include <chrono>
#include <cstdio>
int main() {
jl_init();
std::chrono::high_resolution_clock c;
jl_eval_string("module Some module Nested module Module function f(a::Int64) "
"end end end end");
auto t1 = c.now();
@kim366
kim366 / debugger.jl
Last active November 17, 2018 08:27
const breakpoints = Int[4, 6]
const registeredvars = Symbol[]
const filename = "testscript.jl"
module Exec end
function evalandregister(line::String)
ast = Meta.parse(line)
typeof(ast) == Expr || return
if length(ast.args) == 2 && typeof(ast.args[1]) == Symbol
#pragma once
#include <Identifiers.hpp>
#include <Inputs.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/View.hpp>
#include <SFML/System/Vector2.hpp>
#include <Utility.hpp>
#include <iostream>
#include <tuple>
template<unsigned, typename...>
struct ntuple_impl;
template<unsigned N, typename E, typename... Es>
struct ntuple_impl<N, std::enable_if_t<(N > 1)>, E, Es...>
{
using type = typename ntuple_impl<N - 1, void, E, E, Es...>::type;
template<unsigned, typename...>
struct ntuple_impl;
template<unsigned N, typename E, typename... Es>
struct ntuple_impl<N, std::enable_if_t<(N > 1)>, E, Es...>
{
using type = typename ntuple_impl<N - 1, void, E, E, Es...>::type;
};
template<typename... Es>