Skip to content

Instantly share code, notes, and snippets.

View Xinayder's full-sized avatar

Alexandre Oliveira Xinayder

View GitHub Profile
@Xinayder
Xinayder / playground.rs
Last active January 22, 2016 21:38 — forked from anonymous/playground.rs
Shared via Rust Playground
trait Substring {
fn substr(&self, start_index: u32, length: u32) -> &str;
fn substring(&self, start_index: u32) -> &str;
}
impl Substring for str {
fn substr(&self, start_index: u32, length: u32) -> &str {
if length == 0 { return ""; }
if start_index == 0 && length == self.len() as u32 { return &self; }
return &self[start_index as usize .. start_index as usize + length as usize];
// ==UserScript==
// @name Auto Steam Discovery Queue
// @namespace RockyTV
// @description Go to next game queued as soon as page is done loading.
// @version 1.5
// @include http://store.steampowered.com/explore/*
// @match *://store.steampowered.com/explore*
// @match *://store.steampowered.com//explore*
// @run-at document-end
// @grant none
@Xinayder
Xinayder / substring.rs
Last active November 29, 2015 14:27 — forked from anonymous/playground.rs
Shared via Rust Playground
fn main() {
println!("{:?}", substr("abcdef", 2, 4));
}
fn substr(string: &str, start_index: u32, length: u32) -> String {
let mut result: String = String::new();
let index: usize = start_index as usize;
let mut lusize: usize = length as usize;
result.push_str(&string[index..lusize+index]);
@Xinayder
Xinayder / caesar-cipher.rs
Last active June 28, 2018 12:39 — forked from anonymous/playground.rs
Caesar's cipher implemented in Rust
// Caesar's cipher implemented in Rust
// Made by Xinayder with the help of folks from #rust at irc.mozilla.org
//
fn encrypt(msg: &str, shift: u32) -> String {
let alphabet_upper: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let alphabet_lower: &str = "abcdefghijklmnopqrstuvwxyz";
let mut result: String = String::new();
for c in msg.chars() {
if c.is_whitespace() {