Skip to content

Instantly share code, notes, and snippets.

View starfys's full-sized avatar
🤖
foo

Starfys starfys

🤖
foo
View GitHub Profile
@starfys
starfys / hashmapdifference.rs
Last active May 22, 2020 22:44
Comparing hash maps (fully generic)
use std::collections::hash_map::{self, HashMap};
use std::hash::Hash;
pub struct HashWrap<K, V>(HashMap<K, V>);
impl<K, V> From<HashMap<K, V>> for HashWrap<K, V> {
fn from(value: HashMap<K, V>) -> Self {
Self(value)
}
}
#![feature(iterator_step_by)]
extern crate rayon;
use rayon::prelude::*;
use std::time::SystemTime;
fn is_prime(n: i64) -> bool {
if n == 1 || (n > 2 && n % 2 == 0) {
false
} else {
let mut rbool = true;
from math import sqrt
import time
def is_prime(n):
if n == 1 or (n > 2 and n % 2 == 0):
return False
else:
rbool = True
sroot = int(sqrt(n) + 1)
for i in range(3,sroot,2):
/// Determines whether something is a robot
fn is_robot(entity: Entity) -> bool {
// TODO: Write this for real
unimplemented!()
}
#[test]
fn test_robot_detector() {
assert_eq!(is_robot(Entity::SamRemedios), false);
assert_eq!(is_robot(Entity::Roomba), true);
/// Performs nuclear fission by reference
void atom_splitter(Atom atom, Atom& atom_out_1, Atom& atom_out_1) {
// Oak Ridge won't let us show this
}
int main() {
Atom uranium = Atom::Uranium;
Atom krypton, barium;
atom_splitter(uranium, &krypton, &barium);
}
std::string day_name;
switch(day_number) {
case 0:
day_name = "Sunday";
break;
case 1:
day_name = "Monday";
break;
case 2:
day_name = "Tuesday";
let day_name = match day_number {
0 => "Sunday",
1 => "Monday",
2 => "Tuesday",
3 => "Wednesday",
4 => "Thursday",
5 => "Friday",
6 => "Saturday"
_ => panic!("There are only 7 days in a week.")
};
@starfys
starfys / keybase.md
Created July 25, 2016 04:56
keybase.md

Keybase proof

I hereby claim:

  • I am starfys on github.
  • I am starfys (https://keybase.io/starfys) on keybase.
  • I have a public key ASBwKh51bcXg42N0IEnsQmLlLapOB-qIEN0nDwV8SBvYvwo

To claim this, I am signing this object:

@starfys
starfys / analyze.py
Created June 29, 2016 19:01
Does cool analysis stuff
#!/bin/env python3
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import numpy as np
from math import log
with open('resilience.txt','r') as res_file:
data = list(map(str.rstrip, res_file.readlines()))
data = list(map(lambda line: tuple(map(float, line.split(',')))[1], data))
@starfys
starfys / bf2c.py
Created May 16, 2016 04:12
Brainfuck to C compiler, Takes Brainfuck at stdin, prints c to stdout
#!/usr/bin/env python3
import sys
print("//This converts brainfuck in stdin to c on stdout")
brainfuck_program = sys.stdin.read().rstrip()
#Print the starting code
print("#include <stdio.h>")
print("int main(){")