Skip to content

Instantly share code, notes, and snippets.

View codesections's full-sized avatar

Daniel Sockwell codesections

View GitHub Profile
@codesections
codesections / 05.dyalog
Last active December 6, 2019 04:13
Advent of Code day 5
⎕IO0
intcode{
0 i s instr'0'(,{4<}) opcode¯2instr p_modes¨3instr
p{modep_modes[-1]
mode=0:s[i+]
mode=1:i+
'ERR: Unknown parameter mode',mode}
is:'ERR: no HALT opcode'
@codesections
codesections / 02.dyalog
Last active December 3, 2019 02:30
Advent of Code day 2
⎕IO0
find{
0
in(,(100).,100) set 0
(1)=0intcode in:in[1 2]
(+1)in (1)
}
set{s s[1 2][0 1] s}
intcode{
0 sstate
@codesections
codesections / xmodmap.sh
Created August 21, 2019 22:26
Output of `xmodmap -pke`
keycode 8 =
keycode 9 = Escape NoSymbol Escape
keycode 10 = 1 exclam 1 exclam
keycode 11 = 2 at 2 at
keycode 12 = 3 numbersign 3 numbersign
keycode 13 = 4 dollar 4 dollar
keycode 14 = 5 percent 5 percent
keycode 15 = 6 asciicircum 6 asciicircum
keycode 16 = 7 ampersand 7 ampersand
keycode 17 = 8 asterisk 8 asterisk
@codesections
codesections / main.rs
Last active May 16, 2022 23:48
Warp_proof_of_concept
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 November 4, 2021 10:04
A proof of concept showing streaming from a Redis pub/sub channel to Server Sent Events
use futures::{Async, Poll};
use redis;
use std::time::Duration;
use warp::{path, Filter, Stream};
struct OutputStream {
con: redis::Connection,
}
impl OutputStream {
@codesections
codesections / factorial.lisp
Created February 23, 2019 16:43
Lisp example
(defun factorial (n)
(if (zerop n) 1 (* n (factorial (1- n)))))
@codesections
codesections / robot_paths.rs
Last active January 10, 2019 16:07
A rust implementation of a simple exercise
fn main() {
println!("{:?}", robot_paths(6));
}
#[derive(Clone)]
struct Board {
squares: Vec<Vec<bool>>,
}
impl Board {
@codesections
codesections / robotPaths.js
Created January 8, 2019 19:59
A javascript solution to a simple practice problem
/**
*
* 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 January 6, 2019 23:02
A simple linked list implemented in Rust
#[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 January 6, 2019 23:01
A simple linked list implemented in JavaScript
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;