Skip to content

Instantly share code, notes, and snippets.

View bioduds's full-sized avatar
🦉
Night Owling...

Eduardo Capanema bioduds

🦉
Night Owling...
  • Universidade Federal de Minas Gerais - UFMG - Matemática Computacional
  • Belo Horizonte, MG
View GitHub Profile
@bioduds
bioduds / p008.p6
Created May 11, 2019 15:00
won't multiply
=begin comment
Project Euler
Problem: 8
Title: Largest product in a series
Description:
The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IOTA Wallet by bitworkers</title>
<link rel="stylesheet" href="foundation/src/css/foundation.css">
<link rel="stylesheet" href="foundation/src/css/app.css">
<link rel="stylesheet" href="css/main.css">
### client sending message async
use v6;
use lib 'lib/network';
use client;
say "Running Test...";
loop {
sleep-until now+2;
### So, I got this to listen to incoming requests
#unit package EC::Network:auth<github:bioduds>;
unit module EC::Network;
class Socket {
has $.listener;
method run {
loop {
my $conn = $!listener.accept;
my $socket = IO::Socket::Async.listen('192.168.1.106', 5000);
react {
whenever $socket.Supply -> $v {
say "Working";
}
}
@bioduds
bioduds / gist:7d3d3f7e91e36b506f9e6e6254110929
Created June 11, 2017 02:20
this is responsive, I mean it responds to a signal dying
my $socket = IO::Socket::Async.listen('192.168.1.106', 5000);
react {
whenever $socket.Supply -> $v {
if $v.chars > 0 {
say $v;
}
}
}
my $socket = IO::Socket::Async.bind-udp('localhost', 5000);
react {
whenever $socket.Supply -> $v {
if $v.chars > 0 {
say $v;
}
}
}
##### THIS RUNS IT
unit package EC::Network:auth<github:bioduds>;
use message;
## register class - rule is must be readable once
class Reader {
has $.message;
method read {
say "Message Network system reading " ~ $!message;
@bioduds
bioduds / gist:cff61d5071e53e3b1ada177c9c4cc107
Created June 10, 2017 14:51
reuse grammar in grammar?
## reusable grammars
grammar TIMESTAMP {
rule TOP { <WEEK-DAY> <MONTH> <DAY> <TIME> <PLACE> <PLACE> <YEAR> }
token WEEK-DAY { \S+ }
token MONTH { \S+ }
token DAY { \d+ }
token TIME { \d+ \: \d+ \: \d+ }
token PLACE { \S+ }
token YEAR { \d+ }
}
#### SO, I have this grammar
unit package EC::Grammars:auth<github:bioduds>;
grammar ADDR {
rule TOP { <IDENTIFIER> <TIMESTAMP> <LINKER> <ADDRESS>+ }
token IDENTIFIER { 'Right now, ' }
rule TIMESTAMP { <WEEK-DAY> <MONTH> <DAY> <TIME> <PLACE> <YEAR> }
token WEEK-DAY { \S+ }
token MONTH { \S+ }