Skip to content

Instantly share code, notes, and snippets.

@ayosec
ayosec / gradient-term.rs
Created February 24, 2015 22:50
Rust: term gradient
#![feature(core)]
extern crate core;
use core::fmt;
struct Color {
r: u8,
g: u8,
b: u8,
}
@ayosec
ayosec / colors.rs
Created February 24, 2015 17:23
Rust 256 colors
#![feature(core)]
extern crate core;
use core::fmt;
struct Color {
r: u8,
g: u8,
b: u8,
}
@ayosec
ayosec / spray-json-requests
Created January 29, 2015 03:01
Spray JSON requests
scala> :paste
// Entering paste mode (ctrl-D to finish)
import play.api.libs.json._
import spray.http._
import MediaTypes._
import spray.client.pipelining.Post
import spray.httpx.marshalling.Marshaller
case class Foo(a: Int, b: String)
@ayosec
ayosec / tools.md
Last active August 29, 2015 14:14 — forked from nrc/tools.md

Rust developer tools - status and strategy

Availability and quality of developer tools are an important factor in the success of a programming language. C/C++ has remained dominant in the systems space in part because of the huge number of tools tailored to these lanaguages. Succesful modern languages have had excellent tool support (Java in particular, Scala, Javascript, etc.). Finally, LLVM has been successful in part because it is much easier to extend than GCC. So far, Rust has done pretty well with developer tools, we have a compiler which produces good quality code in reasonable time, good support for debug symbols which lets us leverage C++/lanaguge agnostic tools such as debuggers, profilers, etc., there are also syntax highlighting, cross-reference, code completion, and documentation tools.

In this document I want to layout what Rust tools exist and where to find them, highlight opportunities for tool developement in the short and long term, and start a discussion about where to focus our time an

@ayosec
ayosec / UNIXBenchmarks-AWS-C4-C3.md
Last active May 9, 2017 15:30
AWS C3 vs C4: UNIX Benchmarks

BYTE UNIX Benchmarks

Summary

                                             c3.large           c4.large          c4 / c3
===========================================================================================
Dhrystone 2 using register variables       34752053.9 lps     43996767.0 lps       1.2660
Double-Precision Whetstone                     4459.8 MWIPS       8113.5 MWIPS     1.8193
Execl Throughput                               4110.8 lps         7697.1 lps       1.8724
@ayosec
ayosec / vat-check.sh
Created January 9, 2015 03:38
VAT validation using SOAP service
# Replace XXXXXXXXXXXXX with the VAT number
#
# The $valid attribute is in the path `soap:Body / checkVatResponse / valid`
#
# Example:
#
# <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
# <soap:Body>
# <checkVatResponse xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
@ayosec
ayosec / extract-fragments-ffmpeg.rb
Created December 22, 2014 00:22
Extract fragments from a video using FFmpeg
#!/usr/bin/ruby
require "tmpdir"
def usage()
STDERR.puts <<EOU
Usage: #$0 input-file output-file ranges+
Ranges can be defined with:
use std::collections::HashMap;
use std::collections::hash_map::Entry;
fn main() {
let text = [
"The", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog",
"at", "a", "restaurant", "near", "the", "lake", "of", "a", "new", "era"
];
let mut map: HashMap<&str, u32> = HashMap::new();
@ayosec
ayosec / xorshf.rs
Last active August 29, 2015 14:10
Rust implemenation for Xorshift*
extern crate time;
#[deriving(Show)]
struct XorshiftStar {
x: u64
}
impl XorshiftStar {
fn new() -> XorshiftStar {
XorshiftStar { x: time::now().tm_nsec as u64 }
@ayosec
ayosec / 0 Results.md
Last active September 4, 2017 06:12
Rust performance for maps with uint keys

Benchmarks on different Map implementations for uint keys

Environment:

$ rustc --version
rustc 0.13.0-nightly (770378a31 2014-11-20 23:02:01 +0000)
$ uname -sm
Linux x86_64

No optimizations. No debug info