Skip to content

Instantly share code, notes, and snippets.

@sean3z
sean3z / main.rs
Created April 13, 2017 19:04
Example Rocket route
#[get("/hello/<name>/<age>/<cool>")]
fn hello(name: &str, age: u8, cool: bool) -> String {
if cool {
format!("You're a cool {} year old, {}!", age, name)
} else {
format!("{}, we need to talk about your coolness.", name)
}
}
@sean3z
sean3z / server.js
Created April 13, 2017 19:05
Example Restify route
app.get('/hello/:name/:age([0-9]+)/:cool(true|false)', (req, res, next) => {
let {name, age, cool} = req.params;
cool = (cool === 'true');
age = parseInt(age);
if (cool) {
res.send(`You're a cool ${age} year old, ${name}`);
} else {
res.send(`${name}, we need to talk about your coolness.`);
}
@sean3z
sean3z / Registry.php
Last active August 9, 2017 00:13
Zephir Zend Registry fill
<?php
/**
* Here we conditionally defined Zend_Registry
* When our custom Zephir module is installed, Zend\Registry becomes available.
* https://github.com/sean3z/zendframework-zephir
*/
if (class_exists('Zend\\Registry')) {
class Zend_Registry extends Zend\Registry {
// No code block needed here since we extend Zend\Registry
@sean3z
sean3z / tsf.msl
Last active February 28, 2021 00:29
Tiberian Sun Filter (TSF) 3.01
;##
;# ==============
;# Tiberian Sun Filter - TSF
;# $Id: 3.01 02/02/11 14:55:01 Sean Wragg <seanwragg@gmail.com> - sean3z $
;# http://triggsolutions.com/mirc-snippets/tiberian-sun-filter-3-01/415/
;# ==============
;#
;# INSTALLTION -
;# 1) open mIRC/load 'tsf.msl' into remotes - type /tsf
;# 2) append "127.0.0.1 servserv.westwood.com" to hosts configuration file
@sean3z
sean3z / fetch.js
Last active September 9, 2017 22:41
Basic fetch example
fetch('https://api.chucknorris.io/jokes/random')
.then(response => response.json())
.then(body => {
console.log(body);
});
@sean3z
sean3z / gist:185806fdde8b1d8eae50348dddfb0897
Created October 5, 2017 23:30
Rocket 0.3.3 & Rust 1.22.0-nightly
[sean@lappy486:~] $ wrk -d1m http://localhost:8080/
Running 1m test @ http://localhost:8080/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 133.90us 26.21us 2.64ms 84.63%
Req/Sec 36.23k 1.02k 39.12k 75.58%
4326188 requests in 1.00m, 602.36MB read
Requests/sec: 72103.47
Transfer/sec: 10.04MB
@sean3z
sean3z / gist:23632125fa559e5441767866d6e88ec2
Created October 5, 2017 23:37
Restify 6.0.1 & Node.js 8.6.0
[sean@lappy486:~] $ wrk -d1m http://localhost:8080/
Running 1m test @ http://localhost:8080/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 696.69us 1.47ms 157.02ms 99.76%
Req/Sec 7.53k 1.00k 8.90k 66.58%
898973 requests in 1.00m, 140.60MB read
Requests/sec: 14981.94
Transfer/sec: 2.34MB
@sean3z
sean3z / server.js
Created October 5, 2017 23:42
Restify 6.0.1 Example
"use strict";
const restify = require('restify');
const app = restify.createServer();
app.get('/', (req, res, next) => {
res.send('Hello, world!');
});
app.listen(8080, () => {
@sean3z
sean3z / main.rs
Last active March 18, 2018 15:37
Rocket Getting Started snippet
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
#[get("/<name>/<age>")]
fn hello(name: String, age: u8) -> String {
format!("Hello, {} year old named {}!", age, name)
}
@sean3z
sean3z / main.rs
Last active March 17, 2018 16:28
Adding our Hero endpoints
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
#[macro_use] extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
use rocket_contrib::{Json, Value};
mod hero;