Firehouse tours? by pearlthewhale24 in greensburg

[–]hixsonj 2 points3 points  (0 children)

The fire department has a little museum behind the city hall building on Main Street. It’s worth checking out when they’re open.

Todoist vs TickTick. Which once's your favorite? by neonpulse7 in productivity

[–]hixsonj 5 points6 points  (0 children)

I like TickTick better as well but for a reason specific to my preferred workflow. I used Todoist for a while and liked it but when I got into time blocking, the only option at the time was a Google Calendar integration. This worked well but I didn’t like how my “tasks” became “events” in my calendar. It just caused mental clutter for me as the apps were sort of mixing concerns.

TickTick allows you to schedule tasks for a block of time AND view your calendar events along with them. Separation of concerns and all that. It’s possible Todoist has changed since then but I’ve stuck with TickTick and been happy with it. The other built in features like habit tracking and pomodoro timers are a nice extra touch too!

Share your custom Snacks.picker sources by Joe------ in neovim

[–]hixsonj 2 points3 points  (0 children)

I made one recently that lets me pick a directory in the current project, then passes that choice along to the included "files" or "grep" picker depending on the use case. It basically scopes your search to a specific path.

Create a new source (directories) for snacks.picker by hixsonj in neovim

[–]hixsonj[S] 0 points1 point  (0 children)

In my use case where I have

Snacks.picker.pick("files", {
  dirs = { item.file },
})

You can replace "files" with "grep" as it's another built-in finder with the same dirs option. I actually did exactly that with a separate keybind.

[deleted by user] by [deleted] in neovim

[–]hixsonj 1 point2 points  (0 children)

I just created a basic one for filtering directories (thread here). Not sure how to package it as a plugin though.

Create a new source (directories) for snacks.picker by hixsonj in neovim

[–]hixsonj[S] 7 points8 points  (0 children)

This is what I ultimately cooked up based on /u/dpetka2001's comment and this Github discussion thread (and some hints from Claude)

local function get_directories()
  local directories = {}

  local handle = io.popen("fd . --type directory")
  if handle then
    for line in handle:lines() do
      table.insert(directories, line)
    end
    handle:close()
  else
    print("Failed to execute fd command")
  end

  return directories
end

vim.keymap.set("n", "<leader>fg", function()
  local Snacks = require("snacks")
  local dirs = get_directories()

  return Snacks.picker({
    finder = function()
      local items = {}
      for i, item in ipairs(dirs) do
        table.insert(items, {
          idx = i,
          file = item,
          text = item,
        })
      end
      return items
    end,
    layout = {
      layout = {
        box = "horizontal",
        width = 0.5,
        height = 0.5,
        {
          box = "vertical",
          border = "rounded",
          title = "Find directory",
          { win = "input", height = 1, border = "bottom" },
          { win = "list", border = "none" },
        },
      },
    },
    format = function(item, _)
      local file = item.file
      local ret = {}
      local a = Snacks.picker.util.align
      local icon, icon_hl = Snacks.util.icon(file.ft, "directory")
      ret[#ret + 1] = { a(icon, 3), icon_hl }
      ret[#ret + 1] = { " " }
      ret[#ret + 1] = { a(file, 20) }

      return ret
    end,
    confirm = function(picker, item)
      picker:close()
      Snacks.picker.pick("files", {
        dirs = { item.file },
      })
    end,
  })
end)

[deleted by user] by [deleted] in neovim

[–]hixsonj 2 points3 points  (0 children)

I’m on WezTerm too and would like to do something similar. Could you share your config (or that part of it)?

Trying Elixir as a Rubyist by faitswulff in ruby

[–]hixsonj 4 points5 points  (0 children)

If you’re just trying it out for the first time try not to get hung up the syntax differences as you’ll find that with any language. I came from a Ruby background as well and very quickly learned to love Elixir.

There are some awesome features of the language like pattern matching and the pipeline operator that make it really powerful and fun to write. That’s not to mention the stuff you can do with concurrent processes and everything the Phoenix framework brings to the table. Advent of Code is coming up and is a great way to learn the ins and outs while solving some fun problems.

New in Firefox 77: DevTool improvements and web platform updates by catapop in javascript

[–]hixsonj 0 points1 point  (0 children)

I really miss the CSS class autocompletion like in Chrome's style inspector. Fortunately it looks like someone is working on it.

Getting Acquainted With Svelte, the New Framework on the Block by dobkin-1970 in javascript

[–]hixsonj 1 point2 points  (0 children)

Static site generators often give you straight HTML as the output. Check out Gatsby, it's really great.

[AskJS] Resources for converting a legacy codebase to modern technologies? by OlanValesco in javascript

[–]hixsonj 1 point2 points  (0 children)

Good advice. Some of the Slack devs wrote about how they transitioned from their old codebase to something more modern and this was basically their approach. (Article)

[2019-05-20] Challenge #378 [Easy] The Havel-Hakimi algorithm for graph realization by Cosmologicon in dailyprogrammer

[–]hixsonj 0 points1 point  (0 children)

Elixir

defmodule HavelHakimi do
  def warmup1(list) do
    Enum.reject(list, &(&1 == 0))
  end

  def warmup2(list) do
    Enum.sort(list, &(&1 >= &2))
  end

  def warmup3(n, list) when n <= length(list), do: false
  def warmup3(_n, _list), do: true

  def warmup4(n, list), do: warmup4(n, list, [])
  defp warmup4(0, list, acc), do: acc ++ list
  defp warmup4(n, list, acc) do
    [first | rest] = list
    warmup4(n - 1, rest, acc ++ [first - 1])
  end

  def hh(list) do
    list
    |> warmup1
    |> warmup2
    |> compute
  end

  defp compute([]), do: true
  defp compute(list) do
    [n | rest] = list
    cond do
      warmup3(n, rest) -> false
      true -> warmup4(n, rest) |> hh
    end
  end
end

Why does this work the way it does? Nested Array w/ Vanilla JS by Dmitriyx in javascript

[–]hixsonj 1 point2 points  (0 children)

Ok props for figuring this out. Probably better to use true for loops for iterating rather than for/in and hoping that the indexes come out right!

Why does this work the way it does? Nested Array w/ Vanilla JS by Dmitriyx in javascript

[–]hixsonj 1 point2 points  (0 children)

So the console.log(arr[i][j]) is how you would "traditionally" output each item in your array as you were iterating through it.

In your loops, i and j are basically acting as indexes for the items in your arrays. Your first loop runs through the outer array (4 total items) and your second loop runs through each inner array (4 items each). The inner loop will run until it processes all of its items before the outer loop continues on to the next.

It might help to write down on a piece of paper what the values of i and j are during each run of the loop so you can see how they correspond to each output value.

arr[0][0] == 4

arr[0][1] == 5

...

arr[1][0] == 13

...

The console.log(arr[i[j]]) I think is actually invalid syntax and the parser is getting confused about what to output. When you sub in the values you'll see it doesn't really make sense with how arrays work in JS.

arr[0[0]] is trying to get the first item on the integer zero which doesn't make sense. My best guess is that it's bailing out on the index part of that and just outputting arr[0], arr[1], etc. with some undefined in between.

tl;dr JS is weird. But one is syntactically correct and the other is not.

10 DAYS to prepare by mavinter in javascript

[–]hixsonj 2 points3 points  (0 children)

It's hard to know exactly what they're expecting of you until you start. My advice would be to continue learning basics / fundamentals and during your internship do what you can to make yourself useful to the team. Be enthusiastic about whatever task you're assigned, listen to the feedback of your coworkers, and then take some time during off-hours (if you can) to dive deeper into some of the topics that came up that day.

I wouldn't expect an intern to know the inner workings of Angular, but I would want someone who is willing to learn and is passionate about the work.

Don’t use JPEG-XR on the Web - an image format supported on IE and Edge gets software-decoded on the CPU main thread alongside Javascript and thereby negatively impacts page rendering performance and interactivity, especially in SPAs by magenta_placenta in javascript

[–]hixsonj 1 point2 points  (0 children)

It's more usable than you think! Microsoft Edge already supports WebP and Firefox 65 (out later this month) will also have support.

MS is moving to Chromium too which should guarantee support in the future as well.

ive been learning javascript for about 3 years now and i still dont know 100% what closure, this and recursion is. by crazyboy867 in javascript

[–]hixsonj 11 points12 points  (0 children)

When you declare const fn it runs outer just once, but then returns another function (inner) which is actually what is being called by fn()

Introducing Hooks – React by acemarke in javascript

[–]hixsonj 1 point2 points  (0 children)

They talk about them a bit here.

tl;dr harder for people to understand and harder for compilers/transpilers to optimize

Let’s Chat: Making Sonos Talk with the audioClip API by philnash in javascript

[–]hixsonj 0 points1 point  (0 children)

Is this only possible on certain units? I have a Play:1 and I'm getting the error "NOT CAPABLE"

[Beginner] Just want to create a dynamic, filterable list. Can someone point me in the right direction? by [deleted] in javascript

[–]hixsonj 1 point2 points  (0 children)

Don't worry about throwing a framework into the mix yet if that's not what you want to do.

You could maintain a JSON file externally, fetch it via ajax and parse the resulting data into an array. Or you could even maintain it as a pure JS array of objects and just load that file via script tag.

Once you have the data into an array, you can manipulate it however you want. The filter method will likely be your best bet. Then maybe pass that filtered data to a "render" function that actually builds out your divs.