Skip to content

Instantly share code, notes, and snippets.

View ryanwinchester's full-sized avatar
⚗️
Working on open-source and side projects

Ryan Winchester ryanwinchester

⚗️
Working on open-source and side projects
View GitHub Profile
@ryanwinchester
ryanwinchester / keymap.jsonc
Created April 20, 2024 12:56
Zed keymap working on my vim stuff
[
// -----------------------------------------------------------------------
// Vim keybindings
// -----------------------------------------------------------------------
{
// NORMAL and VISUAL modes
"context": "Editor && (vim_mode == normal || vim_mode == visual) && !VimWaiting && !menu",
"bindings": {
// Tab things. Almost as good as harpoon.
"space 1": ["pane::ActivateItem", 0],
@ryanwinchester
ryanwinchester / install_elixir_phoenix.sh
Last active March 26, 2024 17:01
Install Elixir and Phoenix on macOS
# Update brew
brew update
# Need postgres
brew install postgresql
# Install elixir
brew install elixir
# Install hex package manager
@ryanwinchester
ryanwinchester / 1brc.exs
Last active March 18, 2024 15:11 — forked from ethanniser/1brc.exs
1 billion row challenge in a SINGLE EXPRESSION!
Mix.install([
{:explorer, "~> 0.8.0"}
])
filepath = "./measurements.txt"
defmodule Challenge do
import Explorer.Series
require Explorer.DataFrame, as: DF
@ryanwinchester
ryanwinchester / erlang-elixir.md
Last active March 12, 2024 11:25
Joe Armstrong on Elixir (and Erlang)

The good thing about Elixir (and Erlang) lies in the concurrency - it’s all about creating parallel process and sending messages - and this (as Alan Kay has pointed out on numerous occasions) is the essence of OO programming.

OO programming is all about objects. Objects are things that respond to messages (or should be) - to get an object to do something you send it a message - how it does it is totally irrelevant - think of objects as black boxes, to get them to do something you send them a message, they reply by sending a message back.

How they work is irrelevant - whether the code in the black box is functional or imperative is irrelevant - all that is important is that they do what they are supposed to do.

Unfortunately the first big OO language based on this model (smalltalk) talked about objects and messages but messages in smalltalk were not real messages but disguised synchronous function calls - this mistake was repeated in C++ and Java and the “idea” of OO programming morphed into some weird idea

@ryanwinchester
ryanwinchester / bandit_mask.exs
Last active December 8, 2023 18:44
Benchmark Bandit WebSocket Frame Mask
Mix.install([
{:benchee, "~> 1.2"}
])
# ------------------------------------------------------------------------------
# Original code
# ------------------------------------------------------------------------------
defmodule Original do
# Masking is done @mask_size bits at a time until there is less than that number of bits left.
@ryanwinchester
ryanwinchester / stop keybase from auto launching.sh
Created February 7, 2018 21:35
Stop keybase from auto launch
keybase uninstall --components service
@ryanwinchester
ryanwinchester / keymap.jsonc
Last active September 21, 2023 15:09
Zed Config
[
{
"context": "Editor",
"bindings": {
// -----------------------------------------------------------------------
// VS Code keybindings
// -----------------------------------------------------------------------
// https://code.visualstudio.com/docs/getstarted/keybindings#_basic-editing
//
// In VS Code this moves either the current line or selection up or down.
@ryanwinchester
ryanwinchester / bitwise.php
Last active August 15, 2023 05:16
BITWISE FLAGS for Custom PHP Objects
<?php
/**
* BITWISE FLAGS for Custom PHP Objects
*
* @link http://php.net/manual/en/language.operators.bitwise.php#108679
*
* Sometimes I need a custom PHP Object that holds several boolean TRUE or FALSE values.
* I could easily include a variable for each of them, but as always, code has a way to
* get unweildy pretty fast. A more intelligent approach always seems to be the answer,
@ryanwinchester
ryanwinchester / README.md
Last active May 5, 2023 16:21
Comparing `Enum.join/2` vs `Enum.instersperse/2` + `IO.iodata_to_binary/1`....

Question

I know IO.iodata_to_binary performs well and is used in string building situations where performance matters.

However, I had a question if Enum.intersperse/2 and then IO.iodata_to_binary/1 Is better than just Enum.join/2 + string interpolation.

Here are my results.

Results

@ryanwinchester
ryanwinchester / telnet_client.ex
Created January 9, 2023 16:57
Elixir (clunky) Telnet Client
defmodule TelnetClient do
use GenServer
require Logger
@doc """
Starts a connection to the telnet server.
"""
def start_link({host, port}) do
GenServer.start_link(__MODULE__, {host, port}, name: __MODULE__)