Skip to content

Instantly share code, notes, and snippets.

View uzytkownik's full-sized avatar

Maja Piechotka uzytkownik

View GitHub Profile
@uzytkownik
uzytkownik / main.rs
Created March 16, 2018 00:20
Block WebSocket stream for a time
extern crate actix;
extern crate actix_web;
extern crate tokio;
use actix::*;
use actix_web::*;
use std::cell::RefCell;
use std::rc::Rc;
use std::time::Duration;
#[feature(macro_registrar)]
extern mod syntax;
use syntax::ast::{Name};
use syntax::ext::base::{SyntaxExtension};
#[macro_registrar]
fn macro_registrar(register: |Name, SyntaxExtension|) {
use syntax::ext::base::{SyntaxExpanderTTExpanderWithoutContext,NormalTT};
@uzytkownik
uzytkownik / test.rs
Created January 5, 2014 21:18
Casting unsafe pointer to struct containing borrowed pointer
struct Test<'t> {
i: &'t int
}
unsafe fn cast<'t>(test: &'t *mut std::libc::c_void) -> &'t mut Test<'t> {
&*(test.clone() as *mut Test<'t>)
}
pub fn main() {
unsafe {
@uzytkownik
uzytkownik / test.rs
Created January 5, 2014 16:16
Borrowing of owned pointer
pub fn get_str() -> ~str {
return ~"test";
}
pub fn test(st : &str) {
let s = get_str();
let s2 : &str = s;
assert_eq!(st, s2);
}
@uzytkownik
uzytkownik / lib.rs
Created January 3, 2014 12:41
Problem with traits
/*
* Copyright (C) 2014 Maciej Piechotka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
% RUST_LOG=rustpkg::util rustpkg build
WARNING: The Rust package manager is experimental and may be unstable
compile_crate: crate=/home/mpiechotka/Projects/xml-rs/lib.rs, workspace=/home/mpiechotka/Projects/xml-rs/.rust
compile_crate: short_name = xml-rs-0.0, flags =...
compile_input: /home/mpiechotka/Projects/xml-rs/lib.rs / Lib
flags:
cfgs:
compile_input's sysroot = /usr
rustc flags: extra::getopts::Matches{opts: ~[extra::getopts::Opt{name: Short('c'), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"cfg"), hasarg: Yes, occur: Multi, aliases: ~[]}, extra::getopts::Opt{name: Long(~"emit-llvm"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Opt{name: Long(~"help"), hasarg: No, occur: Optional, aliases: ~[extra::getopts::Opt{name: Short('h'), hasarg: No, occur: Optional, aliases: ~[]}]}, extra::getopts::Opt{name: Short('L'), hasarg: Yes, occur: Multi, aliases: ~[]}, extra::getopts::Opt{name: Long(~"bin"), hasarg: No, occur: Optional, aliases: ~[]}, extra::getopts::Op
Thread 9 (Thread 0x7ffff03ff700 (LWP 11431)):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
No locals.
#1 0x00007ffff3dcf5da in uv__epoll_wait (epfd=<optimized out>,
events=events@entry=0x7ffff03fbb70, nevents=nevents@entry=1024,
timeout=timeout@entry=-1)
at ../../../../src/libuv/src/unix/linux-syscalls.c:282
No locals.
#2 0x00007ffff3dcdf33 in uv__io_poll (loop=loop@entry=0x7ffff2038300,
timeout=-1) at ../../../../src/libuv/src/unix/linux-core.c:166
@uzytkownik
uzytkownik / airfoil.ispc
Created August 2, 2011 14:51
Testcase of gather loads
/********************************* Primitives ********************************/
// aos(dim, length, remote, idx, iidx)
// soa(dim, length, remote, idx, iidx)
@uzytkownik
uzytkownik / airfoil.c
Created July 8, 2011 13:49
Testcase for ISPC #63
#include "airfoil.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
float gam, gm1, cfl, eps, mach, alpha, air_const, qinf[4];
void initialise_flow_field(int ncells, float *q, float *res)
{