Skip to content

Instantly share code, notes, and snippets.

View neenjaw's full-sized avatar
:shipit:
Shippin' code

Tim Austin neenjaw

:shipit:
Shippin' code
View GitHub Profile
@neenjaw
neenjaw / netrw.txt
Created July 4, 2023 19:46 — forked from danidiaz/netrw.txt
Vim's netrw commands.
--- ----------------- ----
Map Quick Explanation Link
--- ----------------- ----
< <F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file |netrw-cr|
<del> Netrw will attempt to remove the file/directory |netrw-del|
<c-h> Edit file hiding list |netrw-ctrl-h|
<c-l> Causes Netrw to refresh the directory listing |netrw-ctrl-l|
<c-r> Browse using a gvim server |netrw-ctrl-r|
<c-tab> Shrink/expand a netrw/explore window |netrw-c-tab|
@neenjaw
neenjaw / aoc-2020-d5.rb
Created December 5, 2020 06:23 — forked from SleeplessByte/aoc-2020-d5.rb
aoc-2020-d5.rb
require 'benchmark'
class BoardingPass
def self.from_binary(binary_position)
rows = binary_position[0...7].gsub("F", "0").gsub("B", "1")
columns = binary_position[7..].gsub("L", "0").gsub("R", "1")
row = rows.to_i(2)
column = columns.to_i(2)
@neenjaw
neenjaw / ES5 class.js
Created November 9, 2020 03:04 — forked from apal21/ES5 class.js
Example for blog to show the difference between ES5 and ES6 javascript classes using inheritance and prototypes use cases.
'use strict';
/**
* Person class.
*
* @constructor
* @param {String} name - name of a person.
* @param {Number} age - age of a person.
* @param {String} gender - gender of a person.
*/
@neenjaw
neenjaw / composing-software.md
Created November 5, 2020 07:04 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@neenjaw
neenjaw / dyanmic_or_di_elixir.md
Created June 11, 2020 04:23 — forked from timruffles/dyanmic_or_di_elixir.md
Approaches to dependency-injection/dynamic dispatch in elixir

In many production systems you'll want to have one module capable of talking to many potential implementations of a collaborator module (e.g a in memory cache, a redis-based cache etc). While testing it's useful to control which module the module under test is talking to.

Here are the approaches I can see. The two points that seem to divide the approaches are their tool-ability (dialyzer) and their ability to handle stateful implementations (which need a pid).

Passing modules

Modules are first class, so you can pass them in. Used in EEx, where passed module must implement a behaviour.

@neenjaw
neenjaw / test_helper.exs
Created June 10, 2020 20:16 — forked from henrik/test_helper.exs
Improved `assert_compile_time_raise` based on this comment by Andrea Leopardi: http://andrealeopardi.com/posts/compile-time-work-with-elixir-macros/#comment-2347206739
ExUnit.start()
defmodule CompileTimeAssertions do
defmacro assert_compile_time_raise(expected_exception, expected_message, fun) do
# At compile-time, the fun is in AST form and thus cannot raise.
# At run-time, we will evaluate this AST, and it may raise.
fun_quoted_at_runtime = Macro.escape(fun)
quote do
assert_raise unquote(expected_exception), unquote(expected_message), fn ->
@neenjaw
neenjaw / GitHub-Forking.md
Last active August 9, 2019 17:08 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@neenjaw
neenjaw / canada_states_titlecase.json
Created November 30, 2018 22:54 — forked from pbojinov/canada_states_titlecase.json
US states & Canadian Provinces in JSON form
[
{
"name": "Alberta",
"abbreviation": "AB"
},
{
"name": "British Columbia",
"abbreviation": "BC"
},
{
# A function that shows the results of running competitions consisting of 2 to 4 runners.
def save_ranking(first, second, third=None, fourth=None):
rank = {}
rank[1], rank[2] = first, second
rank[3] = third if third is not None else 'Nobody'
rank[4] = fourth if fourth is not None else 'Nobody'
print(rank)
# Pass the 2 positional arguments
save_ranking('ming', 'alice')
# Initialize the zero-valued list with 100 length
zeros_list = [0] * 100
# Declare the zero-valued tuple with 100 length
zeros_tuple = (0,) * 100
# Extending the "vector_list" by 3 times
vector_list = [[1, 2, 3]]
for i, vector in enumerate(vector_list * 3):
print("{0} scalar product of vector: {1}".format((i + 1), [(i + 1) * e for e in vector]))