Skip to content

Instantly share code, notes, and snippets.

@mloc
mloc / netplan.yml
Created September 4, 2020 20:40
vm netplan
network:
ethernets:
ens18:
addresses:
- 148.251.222.76/29
- 2a01:4f8:241:1004:1::107/80
routes:
- to: 0.0.0.0/0
via: 10.9.0.1
on-link: true
@mloc
mloc / main.fs
Created February 21, 2019 11:40
module main
let rand = new System.Random()
let swap (a: _[]) x y =
let tmp = a.[x]
a.[x] <- a.[y]
a.[y] <- tmp
let shuffle a =
@mloc
mloc / main.rs
Created February 20, 2018 12:44
#[macro_use] extern crate nom;
named!(parser<Vec<Vec<&[u8]>>>,
separated_list!(
tag!("def"),
many0!(tag!("abc"))
)
);
fn main() {
error[E0282]: type annotations needed
--> src/main.rs:3:1
|
3 | named!(parser<Vec<Vec<&[u8]>>>,
| _^
| |_|
| ||
4 | || separated_list!(
5 | || tag!("def"),
6 | || many0!(tag!("abc"))
@mloc
mloc / err.log
Created February 17, 2018 13:20
Compiling nbug v0.1.0 (file:///mnt/c/Users/mloc/Desktop/devel/byxml/nbug)
error[E0277]: the trait bound `&[u8]: nom::Compare<u8>` is not satisfied
--> src/main.rs:3:1
|
3 | / named!(ident,
4 | | recognize!(tuple!(
5 | | tag!(b'_'),
6 | | tag!(b'_')
7 | | ))
8 | | );
@mloc
mloc / err.log
Created February 17, 2018 13:13
error[E0277]: the trait bound `&[u8]: nom::Compare<char>` is not satisfied
--> src/main.rs:3:1
|
3 | / named!(ident,
4 | | recognize!(tuple!(
5 | | tag!('_'),
6 | | tag!('_')
7 | | ))
8 | | );
| |__^ the trait `nom::Compare<char>` is not implemented for `&[u8]`
@mloc
mloc / main.rs
Created February 17, 2018 13:12
#[macro_use] extern crate nom;
named!(ident,
recognize!(tuple!(
tag!('_'),
tag!('_')
))
);
fn main() {
def heapsort(l):
heapify(l)
for j in range(len(l) - 1, 0, -1):
l[0], l[j] = l[j], l[0]
i = 0
last = j - 1
while last >= i * 2 + 1:
r = i * 2 + 1
cur_down = i
@mloc
mloc / d5.rs
Created December 6, 2017 13:50
use std::fs::File;
use std::io::Read;
fn main() {
let mut f = File::open("d5.in").expect("input file not found");
let mut s = String::new();
f.read_to_string(&mut s).unwrap();
let mut v: Vec<isize> = s.split("\n")
@mloc
mloc / d1.py
Created December 1, 2017 19:19
s = open("d1.in", "r").read().strip()
count = 0
d = len(s) // 2
for i, c in enumerate(s):
if c == s[i - d]:
count += int(s[i - d])
print(count)