Skip to content

Instantly share code, notes, and snippets.

View blaix's full-sized avatar

Justin Blake blaix

View GitHub Profile
@blaix
blaix / elm-language-server.md
Last active October 21, 2023 10:42
Troubleshooting issues with elm language server
  • Sometimes it just gets flat-out confused and needs to be restarted.
    • :lsp-restart in helix
    • Ctrl + Shift + P and search restart language language server in vscode
  • Are you using lamdera? or elm-pages (which uses the lamdera compiler)?
    • Tell your editor to use lamdera as the elm path/command.
    • Try lamdera reset
    • ...you may need to trigger a build afterwards (e.g. by loading site after lamdera live)
    • Try copying ~/.lamdera to ~/.elm (supposedly this will be fixed in a future version)
  • Sometimes setting up elm-tooling in the project will work when the global elm tools won't. Don't know why.
  • Check logs. Search google and elm channels (below) for errors.

I like to mirror the process of "going to work" even when I'm working from home. Get dressed. Brush teeth. Etc. and physically move to a dedicated work space. Same for "coming home". And keeping consistent working hours. Basically anything you can do to put a line between "at work" and "at home" in your mind, and and it helps with your kids/family if you have them.

You have to fight the urge to "power through" when you start to get stuck. Since no one is looking over your shoulder it's easy to waste time spinning your wheels. Work on your "ask questions" reflex.

On that note, prefer asking in public channels over DMs. Better chance that you'll get an answer, and it can help others. And it also provides positive pressure to make sure you'll asking the question well, and combats the feeling that you might be bothering someone in particular.

The pomodoro technique is great. Focus on one thing for 25 mins (or any length that works for you) , then take a 5 min break. Physically get out of your chair and look at

@blaix
blaix / selfie.rb
Last active November 21, 2022 09:18
How to understand `extend self` and `class << self` in ruby.
# Everything in ruby is an object which is an instance of a class. Even classes
# themselves are objects that are instances of the class `Class`.
class Dog
end
puts Dog.class # => Class
# When you use the class keyword, you are opening a class to define instance
# methods for any instance of the class:
module Stomach
def eat(food)
@contents ||= []
@contents << food
end
def vomit
@contents.pop
end
end

My experience is mostly with server-side web frameworks, so that's how I'll describe it:

  1. I start in an "outer" TDD loop:
  2. Write a functional test that hits the URL of the feature I'm testing This fails for a silly reason: no route, no template, etc. (scaffolding)
  3. I add only the piece of scaffolding that's causing the failure I'm seeing. At this point I'm just dealing with "glue" that the framework provides me.
  4. Repeat steps 3 until I hit some logic that isn't solved with simply writing together things the framework gives me.
  5. I call a function (or whatever) that doesn't exist yet but named for the logic I'm introducing. My integration test is now failing because it doesn't exist.
@blaix
blaix / whatversionoftmuxamirunning.txt
Created August 18, 2017 17:44
I just wanted to know what version of tmux I'm running...
$ tmux --version
tmux: illegal option -- -
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name]
[-S socket-path] [command [flags]]
$ tmux --help
tmux: illegal option -- -
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name]
[-S socket-path] [command [flags]]
@blaix
blaix / adventure.md
Last active August 12, 2017 21:06
Adventure

Adventure

An RPG for our entire family.

Requirements

  • Use weapons like swords and bows (C), but without hurting or killing (N)
  • Gameplay that works for both young (3) and old (10+) kids
  • Just enough structure to avoid chaos while still focusing on having fun
@blaix
blaix / cool.py
Created May 2, 2017 16:13
turning a function into a method
class User:
def __init__(self, coolness_factor)
self.coolness_factor = coolness_factor
cool_user = User(coolness_factor=100)
uncool_user = User(coolness_factor=1)
def user_is_cool(user):
return user.coolness_factor > 50
@blaix
blaix / asdf.py
Last active February 17, 2017 19:48
class MyClass:
def __init__(one, two, three):
self.one = one
self.two = two
self.three = three
@classmethod
def my_factory_method(one, two, three=None):
if three is None:
return MyClassWithoutThree(one, two)
class BaseModel:
fields = ()
def __init__(self, **data):
for key, val in data.items():
setattr(self, key, val)
class MyModel(BaseModel):
fields = ('field1', 'field2', 'field3')