This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Modified from https://www.snoyman.com/blog/2018/10/raii-better-than-bracket-pattern | |
import Control.Exception (bracket) | |
import Text.Printf (printf) | |
data MyResource = MyResource { handle :: Int } | |
newMyResource :: IO MyResource | |
newMyResource = do | |
putStrLn "Creating a new MyResource" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inductive nzbin : Type := | |
| O | |
| A (b: nzbin) | |
| B (b: nzbin). | |
Fixpoint nzincr (b : nzbin) : nzbin := | |
match b with | |
| O => A O | |
| A c => B c | |
| B c => A (nzincr c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.reddit.com/r/rust/comments/a0g730/new_to_rust_discouraged_by_slowrunning_code/ | |
fn nth_prime_bad(initial: u64) -> u64 { | |
let mut prime_count = 0; | |
let mut curr = 2; | |
let mut prime = None; | |
while prime_count < initial { | |
let mut denom = 2; | |
while denom < curr { | |
if curr % denom == 0 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright © 2018 Bart Massey | |
// This program is licensed under the "MIT License". | |
// Please see the file LICENSE in this distribution | |
// for license terms. | |
// Advent of Code Day 11. | |
"use strict"; | |
function power_level(x, y, gsn) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
inline static void | |
incref(int32_t *refp) { | |
asm volatile("addl $1, (%0)" : : "r" (refp) : "memory"); | |
} | |
inline static void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 'a' | |
def f1(): | |
global a | |
a = 'af1' | |
f1() | |
# prints af1 | |
print(a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
class Some { | |
constructor(value) { | |
this.value = value; | |
} | |
is_some(self) { | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![deny(unused)] | |
use std::io::{self, Read}; | |
#[derive(PartialEq, Copy, Clone)] | |
enum Tile { | |
None, | |
Wall, | |
Goal, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright © 2019 Jeff Austin, Kamakshi Nagar | |
// [This program is licensed under the "MIT License"] | |
// Please see the file LICENSE in the source | |
// distribution of this software for license terms. | |
/* | |
citations: | |
Mark Morrissey --CS333 Operating Systems--Portland State University practice exams: | |
https://web.cecs.pdx.edu/~markem/CS333/exams/Final%202019-01.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use serde::{Deserialize, Serialize}; | |
use std::collections::HashMap; | |
use std::io::Read; | |
#[derive(Serialize, Deserialize)] | |
#[serde(rename_all="camelCase")] | |
struct Item { | |
transfer_status : u64, | |
dismantle_permission : u64, |