Skip to content

Instantly share code, notes, and snippets.

Daniel Sockwell codesections

View GitHub Profile
@codesections
codesections / main.rs
Last active Apr 14, 2019
Warp_proof_of_concept
View main.rs
use futures::{Async, Future, Poll};
use tokio::io::{AsyncRead, AsyncWrite, Error, ReadHalf, WriteHalf};
use tokio::net::TcpStream;
use warp::{path, Filter, Stream};
struct Receiver {
rx: ReadHalf<TcpStream>,
}
impl Stream for Receiver {
type Item = String;
@codesections
codesections / pubsub_poc.rs
Last active Mar 10, 2019
A proof of concept showing streaming from a Redis pub/sub channel to Server Sent Events
View pubsub_poc.rs
use futures::{Async, Poll};
use redis;
use std::time::Duration;
use warp::{path, Filter, Stream};
struct OutputStream {
con: redis::Connection,
}
impl OutputStream {
View factorial.lisp
(defun factorial (n)
(if (zerop n) 1 (* n (factorial (1- n)))))
@codesections
codesections / robot_paths.rs
Last active Jan 10, 2019
A rust implementation of a simple exercise
View robot_paths.rs
fn main() {
println!("{:?}", robot_paths(6));
}
#[derive(Clone)]
struct Board {
squares: Vec<Vec<bool>>,
}
impl Board {
@codesections
codesections / robotPaths.js
Created Jan 8, 2019
A javascript solution to a simple practice problem
View robotPaths.js
/**
*
* A robot located at the top left corner of a 5x5 grid is trying to reach the
* bottom right corner. The robot can move either up, down, left, or right,
* but cannot visit the same spot twice. How many possible unique paths are
* there to the bottom right corner?
*
* make your solution work for a grid of any size.
*
*/
@codesections
codesections / linked_list.rs
Created Jan 6, 2019
A simple linked list implemented in Rust
View linked_list.rs
#[derive(Debug)]
pub struct LinkedList {
head: Option<Box<Node>>,
tail: Option<*mut Node>,
}
#[derive(Debug)]
struct Node {
value: i32,
next: Option<Box<Node>>,
}
@codesections
codesections / linkedList.js
Created Jan 6, 2019
A simple linked list implemented in JavaScript
View linkedList.js
const LinkedList = function() {
this.head = null;
this.tail = null;
};
LinkedList.prototype.addToTail = function(value) {
const newTail = { value, next: null };
if (this.tail) {
this.tail.next = newTail;
@codesections
codesections / main.rs
Created Dec 23, 2018
Linked List with a struct
View main.rs
struct LinkedList {
value: u8,
next: Option<Box<LinkedList>>,
}
impl LinkedList {
fn new(value: u8) -> LinkedList {
LinkedList { value, next: None }
}
@codesections
codesections / nginx.conf
Created Dec 21, 2018
Simple nginx config for static site
View nginx.conf
user root;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@codesections
codesections / actix-web.rs
Created Dec 20, 2018
Basic static file server with actix-web
View actix-web.rs
extern crate actix_web;
use actix_web::{fs, server, App};
fn main() {
server::new(|| {
App::new()
.handler(
"/",
fs::StaticFiles::new("./public")
.unwrap()
You can’t perform that action at this time.