Skip to content

Instantly share code, notes, and snippets.

View NoraCodes's full-sized avatar
🦀
rusting away

Leonora Tindall NoraCodes

🦀
rusting away
View GitHub Profile
@NoraCodes
NoraCodes / functional_squares.rs
Created March 28, 2017 04:19
A sample of functional computations in Rust.
// Generates the first 10 odd squares, lazily.
// [1, 9, 25, 49, 81, 121, 169, 225, 289, 361]
// That is, it takes an infinite sequence of squares and
// checks if each subsequent one is odd, until it finds
// ten that are.
fn main() {
let vector: Vec<_> = (1..) // Instructions to produce
// integers forever
.map(|x| x * x) // This is now instructions for
@NoraCodes
NoraCodes / fizzbuzz.rs
Last active January 27, 2017 14:12
A parallel FizzBuzz implementation with Rust. Requires Rayon ^0.6
extern crate rayon;
use rayon::prelude::*;
fn fizzbuzz(i: i32) {
match (i % 3 == 0, i % 5 == 0) {
// Added showing instances where there is no valid divisor on /u/XANI_'s suggestion
// I really like it, actually, because it lets you see how the parallel iterator has
// chunked up the problem. Very cool.
(false, false) => {println!("{} ", i); },
(true, true) => { println!("{}: FizzBuzz", i); },
@NoraCodes
NoraCodes / Cargo.toml
Created January 3, 2017 17:41
A simple greeter app with Rocket
[package]
name = "rocket_test"
version = "0.1.0"
authors = ["SilverWingedSeraph <lfstindall@gmail.com>"]
[dependencies]
rocket = "0.1.3"
rocket_codegen = "0.1.3"
@NoraCodes
NoraCodes / time_download.py
Created December 22, 2016 15:56
A Python script using Requests to time downloads
#!/usr/bin/env python3
# time_download.py
# A simple script to time downloads in order to determine
# variances in the speed of the network connection used
# by the sensor machine. Reports in CSV
# YOU NEED TO CHANGE THE TARGET_URI VARIABLE
# Please, please, please don't use my cdn for more than a few downloads.
# You will end up getting your IP blocked.
import requests
@NoraCodes
NoraCodes / pronouns.py
Last active February 24, 2019 03:18
An example of proper handling of pronoun replacement for, e.g., text games.
################################################################
# pronouns.py - Leonora Tindall
#
# An example of proper handling of pronoun replacement in
# Python, including a selection menu. This handles only
# singular pronouns, providing a simple .format() based
# interface for replacing pronouns in prose.
# This script is limited to English, but a similar technique
# should work for most languages using a similar grammar.
################################################################
@NoraCodes
NoraCodes / raserver-cipher.py
Last active July 30, 2019 17:23
Asynchronous Reverse Shell and Server in Python using asyncio
#!/usr/bin/env python3
"""
An async server for base64-encoded reverse shells
Allows rashell-cipher clients to connect and get commands
Expects network data in base64 wrapping xor enciphered data
The XOR key in this script needs to match the client key.
Written by Leo Tindall / SilverWingedSeraph
This code is covered by a CC-BY-SA 4.0 license.
Give attribution and share under the same license.
@NoraCodes
NoraCodes / numerica.py
Last active August 29, 2016 21:52
Numerica - Practice Japanese numbers with the help of a computer!
#!/usr/bin/env python3
"""
This is a program to help you study the Japanese numbers.
It currently goes from 0 to 99; I will extend it at a later date.
It can be executed as follows:
./numerica.py
@NoraCodes
NoraCodes / blinky_grid_programmer.ino
Last active August 9, 2016 22:27
Blinky Grid wired programmer sketch
// Data and clock lines for the BlinkyGrid
#define BG_CLOCK 2
#define BG_DATA 8
// How long to take for each half cycle
#define CL_DELAY 50
// Keep track of the current state of the clock
bool c = false;
// Hello! I'm Leo Tindall, the SilverWingedSeraph, and this is a follow-up to my tutorial on
// using match expressions in Rust.
// In my last video, we created a finite state machine to parse and modify some simple markup.
// In this video, we'll make the machine more abstract and more concise.
// We'll start out the same way: defining the four states of the machine.
// However, we'll use a neat trick that Rust
// provides to make things easier later on. We'll ask the compiler to derive the Copy and Clone
// traits on MachineState, so we don't have to worry about borrowing and ownership.

Keybase proof

I hereby claim:

  • I am silverwingedseraph on github.
  • I am lfstindall (https://keybase.io/lfstindall) on keybase.
  • I have a public key whose fingerprint is 1908 B58F 1281 9BD8 A6CB 804B D842 5D4D 2DF2 DD84

To claim this, I am signing this object: