Skip to content

Instantly share code, notes, and snippets.

Daniel Sockwell codesections

Block or report user

Report or block codesections

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@codesections
codesections / 10.dyalog
Created Dec 11, 2019
Advent of Code day 10
View 10.dyalog
in⎕nget '10.input' 1 p'#'=in
can_see{:0
0=+/¯1{p[[0];[1]]}¨ els_btwn }
els_btwn{ :
n+( slope_btwn )
(n),(n ) }
slope_btwn{{÷(/)}--}
@codesections
codesections / 09.dyalog
Created Dec 10, 2019
Advent of Code day 9
View 09.dyalog
intcode{
0 0 (i rb) val[0] addr[1]
get{ <0: 'ERR: invalid negative index'
(addr)<(addr):(addr)val
addr, val,0 }
set{ (addr)<(addr):((addr)val)
addr, val, }
instr(10 10 10 10 10)(get i) opcode(10 10)¯2instr p_modes3instr
p{modep_modes[-1]
@codesections
codesections / 05.dyalog
Last active Dec 6, 2019
Advent of Code day 5
View 05.dyalog
⎕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 Dec 3, 2019
Advent of Code day 2
View 02.dyalog
⎕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 Aug 21, 2019
Output of `xmodmap -pke`
View xmodmap.sh
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 Aug 27, 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.
*
*/
You can’t perform that action at this time.