Skip to content

Instantly share code, notes, and snippets.

View matematikaadit's full-sized avatar

Adit Cahya Ramadhan matematikaadit

View GitHub Profile
@matematikaadit
matematikaadit / lib.rs
Last active June 3, 2020 03:28
Array literal, but using enum for indexing
#[macro_export]
macro_rules! varmap {
($enum_ty:ty => $val_ty:ty ; $($enum:pat => $val:expr),+ $(,)?) => {
{
const SIZE: usize = $crate::varmap!(@count $($val),*);
struct Wrapper([$val_ty; SIZE]);
impl std::ops::Index<$enum_ty> for Wrapper {
type Output = $val_ty;
@matematikaadit
matematikaadit / hidden
Created April 2, 2020 15:12
Directory is hidden?
hidden

Command

java -cp '*' net.sf.saxon.Transform -x:org.ccil.cowan.tagsoup.Parser example.html example.xsl

(I have saxon9he.jar and tagsoup-1.2.1.jar in the current directory)

Success

@matematikaadit
matematikaadit / README.md
Last active September 23, 2019 09:48
How stuff is implemented in Rust
@matematikaadit
matematikaadit / README.md
Last active September 20, 2019 10:49
Weechat Plugin API Summary

Entry/Exit Point of The Plugin

The place where you your code will be executed when it's loaded and unloaded, respectively

int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]);

int weechat_plugin_end (struct t_weechat_plugin *plugin);

Does this works?

// plugin.rs
// This code should be compiled into a shared library
#![crate_type="dylib"]
#![allow(dead_code, unused_variables)]
use std::os::raw;
// function provided by the glue code
extern "C" {
fn hook_event(
1 2 3 4
5 6 7 8
9 10 11 12
<title>https://gistpreview.github.io/?1f5e8c81b22063ad38682a36852ce6a9/index.html</title>
"Bohemian Rhapsody"
Is this the real life?
Is this just fantasy?
Caught in a landslide,
No escape from reality.
Open your eyes,
Look up to the skies and see,
I'm just a poor boy, I need no sympathy,