Skip to content

Instantly share code, notes, and snippets.

void gral_window_warp_cursor(struct gral_window *window, float x, float y) {
NSRect window_rect = [[(GralWindow *)window contentView] convertRect:NSMakeRect(x, y, 0, 0) toView:nil];
NSRect screen_rect = [(GralWindow *)window convertRectToScreen:window_rect];
//CGWarpMouseCursorPosition(screen_rect.origin);
CGPoint point = [[(GralWindow *)window contentView] convertPoint:NSMakePoint(x, y) toView:nil];
NSRect frame = [(GralWindow *)window frame];
point = CGPointMake(NSMinX(frame) + point.x, NSMaxY(NSScreen.screens[0].frame) - (NSMinY(frame) + point.y));
//CGPoint display_point = CGPointMake(NSMinX(frame) + window_point.x, NSMaxY(NSScreen.screens[0].frame) - (NSMinY(frame) + window_point.y));
CGWarpMouseCursorPosition(point);
}
#include <nitro.hpp>
using namespace nitro;
class DemoAnimation: public Animation {
Node* node;
public:
DemoAnimation(Node* node): node(node) {}
bool apply() override {
float t = (time % 2000) / 1000.f;
#!/bin/sh
pdftocairo -svg $1 /tmp/print.svg
sed -i 's/rgb(0%,0%,0%)/rgb(12%,12%,12%)/g' /tmp/print.svg
rsvg-convert -f pdf /tmp/print.svg > $1.print.pdf
// library code
enum SystemEvent {
Draw,
Mouse
}
enum Event<E> {
SystemEvent(SystemEvent),
UserEvent(E)
@eyelash
eyelash / quine.rs
Last active March 18, 2018 22:45
Rust Quine
const S: &str = r#"
fn main() {
print!("const S: &str = r#\x22{}\x22#;{}", S, S);
}
"#;
fn main() {
print!("const S: &str = r#\x22{}\x22#;{}", S, S);
}
#include <cstdio>
class A {
public:
A() {
method();
}
virtual void method() {
printf("A\n");
}
sieve (x:xs) = x : sieve (filter (\y -> mod y x /= 0) xs)
primes = sieve [2..]
{
"app-id": "com.github.alecaddd.akira",
"runtime": "org.gnome.Platform",
"runtime-version": "3.26",
"sdk": "org.gnome.Sdk",
"command": "com.github.alecaddd.akira",
"finish-args": [
"--socket=x11",
"--socket=wayland",
"--filesystem=home"
@eyelash
eyelash / meson.build
Created November 14, 2017 13:21
scintilla meson build files
project('scintilla', 'cpp', 'c', default_options: ['cpp_std=c++14'])
scintilla = library(
'scintilla',
files(
'lexlib/Accessor.cxx',
'lexlib/CharacterSet.cxx',
'lexlib/DefaultLexer.cxx',
'lexlib/LexerBase.cxx',
'lexlib/LexerModule.cxx',
template <typename T> struct A {
virtual void foo() = 0;
};
template <typename T> struct B: A<T> {
template <typename T2> void foo(A<T2>& a) {
a.foo();
}
};