Skip to content

Instantly share code, notes, and snippets.

View idanarye's full-sized avatar

Idan Arye idanarye

View GitHub Profile
@idanarye
idanarye / main.rs
Created February 3, 2020 13:45
Actix with_actor PoC
use actix::prelude::*;
struct WithActor<A: Actor, T, F: FnOnce(&mut A, &mut A::Context) -> T> {
dlg: F,
_phantom: std::marker::PhantomData<A>,
}
fn with_actor<A: Actor, T: 'static, F: FnOnce(&mut A, &mut A::Context) -> T>(dlg: F) -> WithActor<A, T, F>
where A: Handler<WithActor<A, T, F>>
{
@idanarye
idanarye / main.rs
Last active September 26, 2019 21:26
Actix future passing
use actix::prelude::*;
/// This actor needs to handle the message.
struct LeafActor;
impl Actor for LeafActor {
type Context = Context<Self>;
}
/// This actor needs to receive a message, pass it to the leaf actor, and then handle the result
@idanarye
idanarye / ftmedian.m
Last active March 3, 2019 13:35
Median filter on Fourier Transform
% Need to download http://u.cs.biu.ac.il/~kapaho/IP/Images/fftDemo1.tiff
% Uncomment this if you use Octave:
% pkg load image
im = imread('fftDemo1.tiff');
im = double(im) / 255.0;
ff = fft2(im);
ff_abs = abs(ff);
ff_angle = angle(ff);
@idanarye
idanarye / Cargo.toml
Last active March 20, 2018 00:43
Async - not just for IO. Part one - behavior in step function
[package]
authors = ["IdanArye <idanarye@gmail.com>"]
name = "async-not-just-for-io"
version = "0.1.0"
[dependencies]
gfx = "0.17.1"
gfx_device_gl = "0.15.2"
piston2d-gfx_graphics = "0.50.0"
piston_window = "0.77.0"
@idanarye
idanarye / main.rs
Last active December 2, 2017 23:30
Missing nubmers
use std::fs;
use std::io;
use std::io::BufRead;
use std::collections::HashMap;
type Prefixes = Vec<u64>;
type Counters = Vec<u64>;
struct ArgsContext {
filename: String,
#include<stdio.h>
int main() {
double a, b;
int choice;
do {
printf("Enter two numbers: ");
scanf("%lf %lf", &a, &b);
printf("%lf / %lf = %lf\n", a, b, a / b);
#include<stdio.h>
int main() {
int sum = 0;
int digit;
digit = getchar();
while ('0' <= digit && digit <= '9') {
sum += digit - '0';
digit = getchar();
public class MySingleton {
private static MySingleton instance;
public static MySingleton getInstance() {
if (instance == null) {
instance = new MySingleton();
}
return instance;
}
@idanarye
idanarye / Bar.cr
Created June 10, 2015 13:36
Crytal quirks
foo # Why the hell does this even run? I didn't import Foo.cr!
[info ] Import directories: []
[info ] 0 symbols cached.
[info ] Startup completed in 0.748331 milliseconds.
[info ] Getting symbols for /usr/include/dlang/dmd/std/stdio.d
[info ] Getting symbols for /usr/include/dlang/dmd/std/zip.d
[info ] Getting symbols for /usr/include/dlang/dmd/std/outbuffer.d
[info ] Getting symbols for /usr/include/dlang/dmd/std/uuid.d
[info ] Getting symbols for /usr/include/dlang/dmd/std/socketstream.d
[info ] Getting symbols for /usr/include/dlang/dmd/std/exception.d
[info ] Getting symbols for /usr/include/dlang/dmd/std/uni.d