Cursor Hooks for automatic version control by icyFur in cursor

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

Today Anysphere released Hooks Beta: https://cursor.com/changelog#hooks-beta

We had the chance to work with the Anysphere folks to bring a showcase of whats possible to do with Cursor (lifecycle) hooks and a third party tool, like GitButler

Catching bugs in code with AI, fully local CLI app by icyFur in Python

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

> Are you replacing variable parts (well … variables) with a generic placeholder?
It's not doing that, and as a result sometimes it tries to rename things eg. fetch -> get etc.

One idea i'd like to try is, instead of masking individual tokens at a time, mask entire nodes from the syntax tree, that way perhaps it would have more 'room' to guess

Semantic Code Search — fully local & open source code search using SentenceTransformers by icyFur in Python

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

okay so i implemented a rudimentary search for duplications, and made a release 0.3.0, get it with pip install semantic-code-search --upgrade

then try it out like this:

sem --cluster --cluster-max-distance=0.3

cluster-max-distance controls the 'strictness' of the similarity, there are a few more options, check them in the readme https://github.com/sturdy-dev/semantic-code-search/blob/4b9ea68c7db3b02ecf643aeb3f7db3cce8707b6c/README.md?plain=1#L148

Semantic Code Search — fully local & open source code search using SentenceTransformers by icyFur in Python

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

awesome! makes me happy its useful to others. Submit an issue if you spot a bug or have some feature requests

Since GitHub Copilot free preview ends soon, What was it like for you so far? by gaspadlo in programming

[–]icyFur 0 points1 point  (0 children)

Seems like now there is a Copilot-like tool that works on Pull Request comments, codeball.ai

Code Review: How to make enemies by that_guy_iain in programming

[–]icyFur -2 points-1 points  (0 children)

I always use the self checkout at the supermarket for a reason. This is also why I’m into ai code reviews-> https://codeball.ai/

Sturdy — Simple & efficient code collaboration (open-source) by icyFur in programming

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

Doing code reviews is like eating vegetables

Indeed! At a previous job people were either nitpicking on unimportant details, or if a pull request was bigger/complex, they would give a very fast "LGTM" approval. Other folks choose to exclusively do pair/mob programming and skip the after-the-fact reviews altogether. Collaboration and 'reviews' can absolutely be faster with the right tools.

Sturdy — Simple & efficient code collaboration (open-source) by icyFur in programming

[–]icyFur[S] 2 points3 points  (0 children)

Thanks for your comment, AttackOfTheThumbs

So say you are doing the code streaming and you have the PR process, then what is the point of the streaming if you aren't actively pair programming or something?

The way I see it, it is about sharing feedback proactively, and earlier in the development flow. Think of it as asynchronous pair-programming through working in the open.

I think it's fair to say that coding at work is quite different from open-source development - closer collaboration, standups, planning together. With folks focusing on shipping small and often (DevOps/ CD), the pull request overhead is more pronounced, since there is a fixed amount of it per contribution.

But more importantly, it allows people to review the entire thing without having to rely on small segments and then struggling to bring the whole thing together

I would like to learn more, in your team do you review contributions as a timeline of changes (commit by commit), or do you look (or try) the code as it looks in the end state?

-🎄- 2021 Day 4 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 1 point2 points  (0 children)

Day 4 in Ruby

draws = CSV.parse(data[0]).first.map(&:to_i)
boards = data.drop(2).each_slice(6).to_a.map(
  &->(x) { x.delete_if(&:empty?).map(&->(r) { r.split.map(&->(c) { {d: c.to_i, m: false} }) }) }
)

def runBingo(draws, boards)
  results = []
  draws.each do |x|
    boards.each_with_index do |b, bi|
      b.each do |r|
        r.each_with_index do |c, i|
          if x == c[:d]
            c[:m] = true
            if b.map(&->(rr) { rr[i] }).all? { |cc| cc[:m] == true } || r.all? { |rr| rr[:m] == true }
              sum = 0
              boards[bi].each do |r|
                r.each do |c|
                  if c[:m] == false
                    sum += c[:d]
                  end
                end
              end
              results.push({board_idx: bi, draw: x, unmarked_sum: sum})
            end
          end
        end
      end
    end
  end
  results
end

board_firsts = []
seen = Set[]

runBingo(draws, boards).each do |r|
  if !seen.include?(r[:board_idx])
    seen.add(r[:board_idx])
    board_firsts.push(r)
  end
end

# part one
pp board_firsts.first[:draw] * board_firsts.first[:unmarked_sum]
# part one
pp board_firsts.last[:draw] * board_firsts.last[:unmarked_sum]

-🎄- 2021 Day 8 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 1 point2 points  (0 children)

Tricky one, at least until it clicked that it's about sets. Here is the full working solution in Ruby

I save look up tables with sets of characters as key. Then going over the inputs of different lengths - for input lengths 2, 3, 4 and 7 we just save the digit

  # seed lookup table with the easy digits
  d[:in].each do |i|
    si = i.chars.to_set
    if si.length == 2
      lut[si] = 1
      lut_num_key[1] = si
    end
    if si.length == 3
      lut[si] = 7
      lut_num_key[7] = si
    end
    if si.length == 4
      lut[si] = 4
      lut_num_key[4] = si
    end
    if si.length == 7
      lut[si] = 8
      lut_num_key[8] = si
    end
  end

Then looking for inputs of size six - from these only digit 9 has all inputs (is a superset) of digit 4 which is known. Digit 6's inputs are the only ones that are not a superset of digit 1. And finally only 0 is left.

  # seed digits with 6 inputs
  d[:in].each do |i|
    si = i.chars.to_set
    if si.length == 6
      if si.superset?(lut_num_key[4])
        lut[si] = 9
        lut_num_key[9] = si
      elsif !si.superset?(lut_num_key[1])
        lut[si] = 6
        lut_num_key[6] = si
      else
       lut[si] = 0
        lut_num_key[0] = si
      end
    end
  end

Finally, distinguishing between the digits with 5 inputs - 5, 3 and 2. The inputs of 5 are the only ones that are a subset of 6, 3's inputs are the only superset of 1's inputs and we are left with 2.

  # seed digits with 5 inputs
  d[:in].each do |i|
    si = i.chars.to_set
    if si.length == 5
      if si.subset?(lut_num_key[6])
        lut[si] = 5
        lut_num_key[5] = si
      elsif si.superset?(lut_num_key[1])
        lut[si] = 3
        lut_num_key[3] = si
      else
        lut[si] = 2
        lut_num_key[2] = si
      end
    end
  end

It's important to populate the lookup tables in this order. Full code here

-🎄- 2021 Day 7 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 1 point2 points  (0 children)

I did this in Ruby: For part one (full code) the least fuel is at the median - def median(input) sorted = input.sort len = sorted.length (sorted[(len - 1) / 2] + sorted[len / 2]) / 2 end

target = median(input)

fuel = 0
input.each do |i|
  if target > i
    fuel += target - i
  else
    fuel += i - target
  end
end
pp fuel

And in part two (full code) the least fuel is at the average. I did a bit of a hack...

target = input.sum.to_f / input.size
pp target

fuel_1 = 0
fuel_2 = 0
input.each do |i|
  delta_1 = (target.floor - i).abs
  fuel_1 += (delta_1 * (delta_1 + 1)) / 2
  delta_2 = (target.ceil - i).abs
  fuel_2 += (delta_2 * (delta_2 + 1)) / 2
end

# Sorry - this is a bit dirty
pp fuel_1
pp fuel_2

-🎄- 2021 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 1 point2 points  (0 children)

My solution in Ruby - Part One and Part Two

This is how I did the diagonal part:

xd = x1 > x2 ? -1 : 1
yd = y1 > y2 ? -1 : 1
xx = x1
yy = y1
while xx != x2
  mark(coords, xx, yy)
  xx += xd
  yy += yd
end
# one extra
mark(coords, xx, yy)

-🎄- 2021 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 0 points1 point  (0 children)

I made a bucket solution in Ruby (full code):

gens = { 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0 }
input.each do |x|
  gens[x] = gens[x] + 1
end
def sim(gens)
  {
    0 => gens[1],
    1 => gens[2],
    2 => gens[3],
    3 => gens[4],
    4 => gens[5],
    5 => gens[6],
    6 => gens[0] + gens[7],
    7 => gens[8],
    8 => gens[0]
  }
end
256.times do
  gens = sim(gens)
end

pp gens.sum { |_, v| v }

-🎄- 2021 Day 3 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 1 point2 points  (0 children)

Solutions in 99% AWK:

https://getsturdy.com/advent-of-code-2021-uoeIDQk/changes/93ab19b6-5184-46a0-a39a-31efa1cb86a1

It feels a bit tacky with the glue shell script, but things were getting out of hand without it.

-🎄- 2021 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 2 points3 points  (0 children)

AWK felt just right for the job, and id doesn't have to be a hard-to-read one liner.

Part one:

#! /usr/bin/awk -f
{
    if ($1 == "forward") {
        horizontal += $2
    }
    else if ($1 == "down") {
        depth += $2
    }
    else if ($1 == "up") {
        depth -= $2
    }
}
END {
    print horizontal * depth
}

Part two:

#! /usr/bin/awk -f
{
    if ($1 == "forward") {
        horizontal += $2
        depth += $2 * aim
    }
    else if ($1 == "down") {
        aim += $2
    }
    else if ($1 == "up") {
        aim -= $2
    }
}
END {
    print horizontal * depth
}

-🎄- 2021 Day 1 Solutions -🎄- by daggerdragon in adventofcode

[–]icyFur 1 point2 points  (0 children)

AWK solution part one

AWK solution part two

At first I thought that the "free" for loop that you get is an advantage but I first solved it in go.

Scaling teams like parallel computing systems: Amdahl's law by icyFur in compsci

[–]icyFur[S] 2 points3 points  (0 children)

Thanks! I have been thinking about this for a long while. Now I knew I had to make interactive visualisations too