Skip to content

Instantly share code, notes, and snippets.

@yuri91
yuri91 / .vimrc
Last active December 28, 2017 21:57
my vimrc
set nocompatible " be iMproved, required
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@yuri91
yuri91 / virtual_ring_buffer.c
Created June 14, 2014 12:37
Virtual Ring Buffer
#include <sys/mman.h>
#include <stdlib.h>
#include <unistd.h>
#define report_exceptional_condition() abort ()
struct ring_buffer
{
@yuri91
yuri91 / .bashrc
Last active December 28, 2017 21:51
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Enable color and human friendly output.
@yuri91
yuri91 / .bash_prompt
Created February 7, 2016 13:05
solarized colors bash prompt
# Sexy Solarized Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Customized for the Solarized color scheme by Sean O'Neil
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
BASE03=$(tput setaf 234)
BASE02=$(tput setaf 235)
BASE01=$(tput setaf 240)

Keybase proof

I hereby claim:

  • I am yuri91 on github.
  • I am yuri91 (https://keybase.io/yuri91) on keybase.
  • I have a public key ASB4MR76aIfv0ATg-hh7t6r2Z5N9QTfpBn_Z-2hJvJcucgo

To claim this, I am signing this object:

@yuri91
yuri91 / rust1.rs
Last active June 14, 2018 15:56
interop blog post 1
/// Allocate space for a mappings string of the given size (in bytes).
///
/// It is the JS callers responsibility to initialize the resulting buffer by
/// copying the JS `String` holding the source map's "mappings" into it (encoded
/// in ascii).
#[no_mangle]
pub extern "C" fn allocate_mappings(size: usize) -> *mut u8 {
// Make sure that we don't lose any bytes from size in the remainder.
let size_in_units_of_usize = (size + mem::size_of::<usize>() - 1) / mem::size_of::<usize>();
JavaScript WebAssembly

conditional
branching
if (cond()) {
@yuri91
yuri91 / anyref1.cpp
Last active May 15, 2020 08:24
Basic example: pass anyref as parameter and return value
#include <cheerp/client.h>
namespace [[cheerp::genericjs]] client {
void jsFunc(client::Element* elem);
}
[[cheerp::wasm]]
[[cheerp::jsexport]]
client::Element* passAndReturn(client::Element* elem)
{
(module
(type (;0;) (func (param anyref)))
(type (;1;) (func))
(type (;2;) (func (param anyref) (result anyref)))
(import "i" "__ZN6client6jsFuncEPNS_7ElementE" (func (;0;) (type 0)))
(func $__wasm_nullptr (type 1)
unreachable)
(func $_Z13passAndReturnPN6client7ElementE (type 2) (param anyref) (result anyref)
local.get 0
call 0
@yuri91
yuri91 / anyref2.cpp
Last active May 15, 2020 09:40
Call methods on anyref values
#include <cheerp/client.h>
namespace [[cheerp::genericjs]] client {
void jsFunc(client::Element* elem);
}
[[cheerp::wasm]]
[[cheerp::jsexport]]
void callMethods(client::Element* elem)
{